Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#47 design system alert #51

Merged
merged 8 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.suwiki.core.designsystem.component.dialog

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.suwiki.core.designsystem.component.button.SuwikiContainedButtonSmall
import com.suwiki.core.designsystem.component.button.SuwikiContainedGreyButtonSmall

@Composable
fun basicAlertDialog(
onDismissRequest: () -> Unit,
properties: DialogProperties = DialogProperties(),
content: @Composable () -> Unit,
) {
Dialog(
onDismissRequest = onDismissRequest,
properties = properties,
) {
content()
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basicAlertDialog๋ž‘ Dialog๋ž‘ ์™„์ „ํžˆ ๋™์ผํ•œ๋ฐ basic์œผ๋กœ ๋งŒ๋“  ์ด์œ ๊ฐ€ ๊ถ๊ธˆํ•ด์š”~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://sungbin.land/jetpack-compose-%EC%99%84%EB%B2%BD%ED%95%9C-%EC%BB%A4%EC%8A%A4%ED%85%80-%EB%8B%A4%EC%9D%B4%EC%96%BC%EB%A1%9C%EA%B7%B8-%EB%A7%8C%EB%93%A4%EA%B8%B0-79aab4c3023e
์š”๋ธ”๋กœ๊ทธ๋ฅผ ์ฐธ๊ณ ํ•˜๋ฉฐ ๊ตฌํ˜„ํ•˜์˜€๋Š”๋ฐ ํ˜„์žฌ๊นŒ์ง€๋Š” ์™„์ „ํžˆ ๋™์ผํ•˜๋‹ˆ ๋นผ๋„์ข‹์„๊ฑฐ ๊ฐ™์ง€๋งŒ Dialog๊ฐ€ ๋™์ผํ•˜์ง€ ์•Š์„ ์ˆ˜๋„ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•˜์˜€์Šต๋‹ˆ๋‹ค!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์Œ ๊ทผ๋ฐ ์‚ญ๋‹˜์ด ๋งŒ๋“œ์‹  basicAlertDialog๋„ ๊ฑฐ์˜ ๋ฐฑ์ง€์— ๊ฐ€๊นŒ์šด ์ปดํฌ์ €๋ธ”์ด๊ณ  Dialog๋„ ๋ฐฑ์ง€์— ๊ฐ€๊นŒ์šด ์ปดํฌ์ €๋ธ”์ด์–ด์„œ์š”.
basicAlertDialog์— ํ‹€์ด ์žกํ˜€์žˆ๋Š”๊ฒŒ ์•„๋‹ˆ๊ธฐ์— Dialog์™€ ๋™์ผํ•œ ์ปดํฌ์ €๋ธ”์ด๋ผ ์ƒ๊ฐํ•ด์š”.
์ด๋Ÿฐ ์ด์œ ๋กœ ๋‹ค๋ฅธ ํ˜•ํƒœ์˜ Dialog๊ฐ€ ๋‚˜์˜จ๋‹คํ•ด๋„ basicAlertDialog์„ ์‚ฌ์šฉํ•ด์„œ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ๊ณผ Dialog๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ๊ณผ ์ฐจ์ด๊ฐ€ ์—†๋‹ค ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

๋˜ ์ „์ฒด ๋””์ž์ธ์ด ์ด๋ฏธ ๋‚˜์˜จ ์ƒํƒœ์ด๊ธฐ์— ์ƒˆ๋กœ์šด Dialog๊ฐ€ ๋‚˜์˜ฌ ์ผ์€ ์—†์–ด๋ณด์ž…๋‹ˆ๋‹น

BaseActivity์™€ Activity๊ฐ€ ์•„์˜ˆ ๋™์ผํ•˜๋‹ค๋ฉด Activity๋งŒ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ์ข‹์€ ๊ฒƒ ์ฒ˜๋Ÿผ์š”!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ด ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค! ์ˆ˜์ •ํ•ด์„œ ๋‹ค์‹œ ์˜ฌ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค!


@Composable
fun SuwikiDialog(
modifier: Modifier = Modifier,
headerText: String,
bodyText: String,
confirmButtonText: String,
dismissButtonText: String,
onDismissRequest: () -> Unit,
onConfirmClick: () -> Unit,
onDismissClicked: () -> Unit,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clicked๋ž‘ Click ์ฐจ์ด๊ฐ€ ๋ญ”๊ฐ€์š”!?

onClickConfirm, onClickDismiss๋กœ ์ˆœ์„œ ๋ฐ”๊ฟ”์ฃผ์„ธ์š”~!

) {
basicAlertDialog(
onDismissRequest = onDismissRequest,
content = {
Surface(
modifier = modifier
.fillMaxWidth(),
shape = RoundedCornerShape(10.dp),
) {
Column(
modifier = Modifier
.padding(top = 20.dp, bottom = 15.dp, start = 15.dp, end = 22.dp),
) {
Text(
text = headerText,
color = Color(0xFF222222),
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = bodyText,
color = Color(0xFF222222),
)
Spacer(modifier = Modifier.height(37.dp))
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End,
) {
SuwikiContainedGreyButtonSmall(
onClick = onDismissClicked,
text = dismissButtonText,
modifier = Modifier.padding(2.dp),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์š”๊ฑฐ ํ”ผ๊ทธ๋งˆ๋ž‘ ๋‹ค๋ฅธ๊ฑฐ๊ฐ™์€๋ฐ ํ™•์ธ ๊ฐ€๋Šฅํ• ๊นŒ์š”?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SuwikiContainedGreyButtonSmall ๋ฒ„ํŠผ๊ณผ SuwikiContainedButtonSmall ๋ฒ„ํŠผ์˜ ํŒจ๋”ฉ ์ฐจ์ด๊ฐ€ ์žˆ์–ด ์ €๋ ‡๊ฒŒ ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„ํ•˜ PR์— ์ฒจ๋ถ€ํ•œ ์‚ฌ์ง„์„ ๋ณด๋‹ˆ ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ปฌ๋Ÿฌ๊ฐ€ ๋“ค์–ด๊ฐ”๋”๋ผ๊ตฌ์š”!?

SuwikiContainedButtonSmall(
onClick = onConfirmClick,
text = confirmButtonText,
)
}
}
}
},
)
}

@Preview
@Composable
fun DialogPreview() {
SuwikiDialog(
headerText = "Header text",
bodyText = "Body text",
confirmButtonText = "Action 2",
dismissButtonText = "Action 1",
onDismissRequest = { /*TODO*/ },
onConfirmClick = { /*TODO*/ },
) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.suwiki.core.designsystem.component.toast

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@Composable
fun SuwikiToastView(
messageTxt: String,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

messageText๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ• ๊นŒ์š”!?

) {
Box(
modifier = Modifier
.fillMaxSize(),
contentAlignment = Alignment.Center,
) {
Surface(
modifier = Modifier
.wrapContentSize()
.background(
color = Color(0xFF959595),
shape = RoundedCornerShape(25.dp),
),
color = Color.Transparent,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surface ๋งŽ์ด ์ž˜ ๋ชฐ๋ผ์„œ ๊ทธ๋Ÿฐ๋ฐ color = Color.Transparent ์ด๊ฑธ ๋”ฐ๋กœ ์ •์˜ํ•œ ์ด์œ ๊ฐ€ ๋ญ”๊ฐ€์š”???
background๋ž‘ ๋ฌด์Šจ ์ฐจ์ด์ธ์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ์–ด์„œ..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surface๊ฐ€ ํˆฌ๋ช…ํ•œ ๋ฐฐ๊ฒฝ์„ ๊ฐ€์ง€๋„๋ก ํ•„์š”ํ•œ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.
๋ฐฑ๊ทธ๋ผ์šด๋“œ ์„ค์ •์œผ๋กœ ๊ฐ€๋ ค์ง„ ์†์„ฑ์ด ๋ณด์ด์ง€ ์•Š๋Š” ๊ฒƒ์„ ๋ฐฉ์ง€ํ•˜๋Š” ์ฝ”๋“œ ์ž…๋‹ˆ๋‹ค.
์ €์ฝ”๋“œ ์ง€์šฐ๋ฉด ํ† ์ŠคํŠธ ๋ทฐ๋Š” ๋ณด์ด์ง€ ์•Š์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค!

) {
// ์•„์ด์ฝ˜์ด ์ถ”๊ฐ€ ๋ ์ˆ˜ ์žˆ์„๊ฑฐ ๊ฐ™์•„ ์ผ๋‹จ Row๋กœ ํ•ด๋‘์—ˆ์Šต๋‹ˆ๋‹ค.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dryํ•˜๊ฒŒ ๊ฐ€์‹œ์ฃต Row ์ œ๊ฑฐํ•ด์ฃผ์„ธ์š”

Row(
modifier = Modifier
.wrapContentWidth()
.wrapContentHeight(),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = messageTxt,
textAlign = TextAlign.Center,
color = Color(0XFFFFFFFF),
modifier = Modifier.padding(16.dp, 10.dp),
)
}
}
}
}

@Preview
@Composable
fun SetViewPreview() {
SuwikiToastView(
messageTxt = "text",
)
}