-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from YAPP-Github/feature/MZ-219-check-dialog
Feature/mz 219 check dialog 컴포넌트
- Loading branch information
Showing
6 changed files
with
277 additions
and
66 deletions.
There are no files selected for viewing
154 changes: 154 additions & 0 deletions
154
...signsystem/src/main/java/com/susu/core/designsystem/component/dialog/SusuCheckedDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
package com.susu.core.designsystem.component.dialog | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
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 | ||
import com.susu.core.designsystem.component.button.FilledButtonColor | ||
import com.susu.core.designsystem.component.button.GhostButtonColor | ||
import com.susu.core.designsystem.component.button.SmallButtonStyle | ||
import com.susu.core.designsystem.component.button.SusuFilledButton | ||
import com.susu.core.designsystem.component.button.SusuGhostButton | ||
import com.susu.core.designsystem.component.util.CheckCircle | ||
import com.susu.core.designsystem.theme.Gray10 | ||
import com.susu.core.designsystem.theme.Gray100 | ||
import com.susu.core.designsystem.theme.Gray40 | ||
import com.susu.core.designsystem.theme.Gray80 | ||
import com.susu.core.designsystem.theme.SusuTheme | ||
|
||
@Composable | ||
fun SusuCheckedDialog( | ||
modifier: Modifier = Modifier, | ||
title: String? = null, | ||
text: String? = null, | ||
defaultChecked: Boolean = false, | ||
checkboxText: String = "", | ||
confirmText: String = "", | ||
dismissText: String? = null, | ||
isDimmed: Boolean = true, | ||
textAlign: TextAlign = TextAlign.Center, | ||
onConfirmRequest: (isChecked: Boolean) -> Unit = {}, | ||
onDismissRequest: () -> Unit = {}, | ||
) { | ||
val rootModifier = modifier | ||
.fillMaxSize() | ||
.background(color = if (isDimmed) Color.Black.copy(alpha = 0.16f) else Color.Transparent) | ||
.padding(horizontal = SusuTheme.spacing.spacing_xl) | ||
var isChecked by remember { mutableStateOf(defaultChecked) } | ||
|
||
Box( | ||
modifier = rootModifier, | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.align(Alignment.Center) | ||
.background(color = Gray10, shape = RoundedCornerShape(8.dp)) | ||
.padding(SusuTheme.spacing.spacing_xl), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
title?.let { | ||
Text( | ||
text = it, | ||
style = SusuTheme.typography.title_xs, | ||
color = Gray100, | ||
maxLines = 2, | ||
) | ||
Spacer(modifier = Modifier.height(SusuTheme.spacing.spacing_xxs)) | ||
} | ||
text?.let { | ||
Text( | ||
text = it, | ||
style = SusuTheme.typography.text_xxs, | ||
color = Gray80, | ||
maxLines = 4, | ||
textAlign = textAlign, | ||
) | ||
} | ||
Spacer(modifier = Modifier.height(SusuTheme.spacing.spacing_xl)) | ||
Row( | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
CheckCircle( | ||
isChecked = isChecked, | ||
onCheckedChange = { isChecked = it }, | ||
) | ||
Spacer(modifier = Modifier.width(SusuTheme.spacing.spacing_xxxxs)) | ||
Text( | ||
text = checkboxText, | ||
style = SusuTheme.typography.title_xxs, | ||
color = if (isChecked) Gray100 else Gray40, | ||
) | ||
} | ||
Spacer(modifier = Modifier.height(SusuTheme.spacing.spacing_xl)) | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
) { | ||
dismissText?.let { | ||
SusuGhostButton( | ||
modifier = Modifier.weight(1f), | ||
color = GhostButtonColor.Black, | ||
style = SmallButtonStyle.height40, | ||
text = it, | ||
onClick = onDismissRequest, | ||
) | ||
Spacer(modifier = Modifier.height(SusuTheme.spacing.spacing_xxs)) | ||
} | ||
SusuFilledButton( | ||
modifier = Modifier.weight(1f), | ||
color = FilledButtonColor.Orange, | ||
style = SmallButtonStyle.height40, | ||
text = confirmText, | ||
onClick = { onConfirmRequest(isChecked) }, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun SusuCheckedDialogPreview() { | ||
SusuTheme { | ||
SusuCheckedDialog( | ||
title = "제목", | ||
text = "본문", | ||
defaultChecked = true, | ||
checkboxText = "체크박스 메세지", | ||
confirmText = "확인했어요", | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun SusuCheckedDialogFalsePreview() { | ||
SusuTheme { | ||
SusuCheckedDialog( | ||
title = "제목", | ||
text = "본문", | ||
checkboxText = "체크박스 메세지", | ||
confirmText = "확인", | ||
dismissText = "닫기", | ||
) | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
core/designsystem/src/main/java/com/susu/core/designsystem/component/util/CheckCircle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.susu.core.designsystem.component.util | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.drawBehind | ||
import androidx.compose.ui.graphics.drawscope.Stroke | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.susu.core.designsystem.R | ||
import com.susu.core.designsystem.theme.Gray100 | ||
import com.susu.core.designsystem.theme.Gray40 | ||
import com.susu.core.designsystem.theme.SusuTheme | ||
import com.susu.core.ui.extension.susuClickable | ||
|
||
@Composable | ||
fun CheckCircle( | ||
modifier: Modifier = Modifier, | ||
isChecked: Boolean, | ||
onCheckedChange: (Boolean) -> Unit = {}, | ||
) { | ||
Box( | ||
modifier = modifier | ||
.size(20.dp) | ||
.drawBehind { | ||
if (isChecked.not()) { | ||
drawCircle( | ||
color = Gray40, | ||
radius = 8.dp.toPx(), | ||
style = Stroke(width = 1.dp.toPx()), | ||
) | ||
} | ||
} | ||
.susuClickable( | ||
rippleEnabled = false, | ||
onClick = { onCheckedChange(isChecked.not()) }, | ||
), | ||
) { | ||
if (isChecked) { | ||
Icon( | ||
painter = painterResource(id = R.drawable.ic_check_circle_background), | ||
contentDescription = null, | ||
tint = Gray100, | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun CheckCirclePreview() { | ||
SusuTheme { | ||
Row { | ||
CheckCircle(isChecked = true) | ||
CheckCircle(isChecked = false) | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
core/designsystem/src/main/res/drawable/ic_check_circle_background.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M12,2C6.48,2 2,6.48 2,12C2,17.52 6.48,22 12,22C17.52,22 22,17.52 22,12C22,6.48 17.52,2 12,2ZM9.29,16.29L5.7,12.7C5.607,12.607 5.534,12.498 5.484,12.377C5.434,12.256 5.408,12.126 5.408,11.995C5.408,11.864 5.434,11.734 5.484,11.613C5.534,11.493 5.607,11.383 5.7,11.29C5.793,11.197 5.902,11.124 6.023,11.074C6.144,11.024 6.274,10.998 6.405,10.998C6.536,10.998 6.666,11.024 6.787,11.074C6.908,11.124 7.017,11.197 7.11,11.29L10,14.17L16.88,7.29C17.067,7.103 17.321,6.998 17.585,6.998C17.849,6.998 18.103,7.103 18.29,7.29C18.477,7.477 18.582,7.731 18.582,7.995C18.582,8.259 18.477,8.513 18.29,8.7L10.7,16.29C10.608,16.383 10.498,16.456 10.377,16.506C10.256,16.557 10.126,16.582 9.995,16.582C9.864,16.582 9.734,16.557 9.613,16.506C9.492,16.456 9.383,16.383 9.29,16.29Z" | ||
android:fillColor="#242424"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.