-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from 4 commits
9752ab5
52e2977
119a786
8cadfcd
d00c11b
822972c
55432de
6737822
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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() | ||
} | ||
} | ||
|
||
@Composable | ||
fun SuwikiDialog( | ||
modifier: Modifier = Modifier, | ||
headerText: String, | ||
bodyText: String, | ||
confirmButtonText: String, | ||
dismissButtonText: String, | ||
onDismissRequest: () -> Unit, | ||
onConfirmClick: () -> Unit, | ||
onDismissClicked: () -> Unit, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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), | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์๊ฑฐ ํผ๊ทธ๋ง๋ ๋ค๋ฅธ๊ฑฐ๊ฐ์๋ฐ ํ์ธ ๊ฐ๋ฅํ ๊น์? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SuwikiContainedGreyButtonSmall ๋ฒํผ๊ณผ SuwikiContainedButtonSmall ๋ฒํผ์ ํจ๋ฉ ์ฐจ์ด๊ฐ ์์ด ์ ๋ ๊ฒ ๊ตฌํํ์์ต๋๋ค! There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surface ๋ง์ด ์ ๋ชฐ๋ผ์ ๊ทธ๋ฐ๋ฐ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surface๊ฐ ํฌ๋ช
ํ ๋ฐฐ๊ฒฝ์ ๊ฐ์ง๋๋ก ํ์ํ ์ฝ๋์
๋๋ค. |
||
) { | ||
// ์์ด์ฝ์ด ์ถ๊ฐ ๋ ์ ์์๊ฑฐ ๊ฐ์ ์ผ๋จ Row๋ก ํด๋์์ต๋๋ค. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basicAlertDialog๋ Dialog๋ ์์ ํ ๋์ผํ๋ฐ basic์ผ๋ก ๋ง๋ ์ด์ ๊ฐ ๊ถ๊ธํด์~
There was a problem hiding this comment.
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๊ฐ ๋์ผํ์ง ์์ ์๋ ์๋ค๊ณ ์๊ฐํ์์ต๋๋ค!
There was a problem hiding this comment.
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๋ง ์ฌ์ฉํ๋๊ฒ ์ข์ ๊ฒ ์ฒ๋ผ์!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ด ๊ฐ์ฌํฉ๋๋ค! ์์ ํด์ ๋ค์ ์ฌ๋ฆฌ๊ฒ ์ต๋๋ค!