Skip to content

Commit

Permalink
[TNT-190] feat: TnTCheckTogglePopupDialog ๊ตฌํ˜„
Browse files Browse the repository at this point in the history
- ํŠธ๋ ˆ์ด๋„ˆ ์—ฐ๊ฒฐ ํŒ์—… ๋‹ค์ด์–ผ๋กœ๊ทธ๋กœ ์‚ฌ์šฉ ์˜ˆ์ •
  • Loading branch information
SeonJeongk committed Jan 29, 2025
1 parent 80ebff5 commit d1cdff6
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package co.kr.tnt.designsystem.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
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.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import co.kr.tnt.core.designsystem.R
import co.kr.tnt.designsystem.theme.TnTTheme

@Composable
fun TnTCheckToggle(
isChecked: Boolean = false,
onCheckClick: () -> Unit,
modifier: Modifier = Modifier,
) {
val icon = if (isChecked) {
R.drawable.ic_check_true
} else {
R.drawable.ic_check_false
}

Image(
painter = painterResource(icon),
contentDescription = null,
modifier = modifier
.size(24.dp)
.clip(CircleShape)
.clickable(onClick = onCheckClick),
)
}

@Preview
@Composable
private fun TnTCheckTogglePreview() {
TnTTheme {
var isChecked by remember { mutableStateOf(false) }

TnTCheckToggle(
isChecked = isChecked,
onCheckClick = { isChecked = !isChecked },
)
}
}
13 changes: 13 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_check_false.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<group>
<clip-path
android:pathData="M2,2h24v24h-24z"/>
<path
android:pathData="M12.028,17.867L20.666,9.228C20.815,9.079 20.989,9.003 21.188,9C21.388,8.997 21.565,9.073 21.72,9.228C21.875,9.383 21.953,9.561 21.953,9.763C21.953,9.964 21.875,10.142 21.72,10.297L12.66,19.372C12.48,19.553 12.269,19.643 12.028,19.643C11.787,19.643 11.576,19.553 11.395,19.372L7.22,15.197C7.071,15.049 6.998,14.872 7,14.667C7.002,14.463 7.08,14.283 7.236,14.128C7.391,13.973 7.569,13.895 7.77,13.895C7.971,13.895 8.15,13.973 8.305,14.128L12.028,17.867Z"
android:fillColor="#D4D4D4"/>
</group>
</vector>
13 changes: 13 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_check_true.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<group>
<clip-path
android:pathData="M2,2h24v24h-24z"/>
<path
android:pathData="M12.028,17.867L20.666,9.228C20.815,9.079 20.989,9.003 21.188,9C21.388,8.997 21.565,9.073 21.72,9.228C21.875,9.383 21.953,9.561 21.953,9.763C21.953,9.964 21.875,10.142 21.72,10.297L12.66,19.372C12.48,19.553 12.269,19.643 12.028,19.643C11.787,19.643 11.576,19.553 11.395,19.372L7.22,15.197C7.071,15.049 6.998,14.872 7,14.667C7.002,14.463 7.08,14.283 7.236,14.128C7.391,13.973 7.569,13.895 7.77,13.895C7.971,13.895 8.15,13.973 8.305,14.128L12.028,17.867Z"
android:fillColor="#FF472F"/>
</group>
</vector>
136 changes: 136 additions & 0 deletions core/ui/src/main/java/co/kr/tnt/ui/component/TnTCheckToggleDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package co.kr.tnt.ui.component

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults.cardColors
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.text.style.TextAlign
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 co.kr.tnt.designsystem.component.TnTCheckToggle
import co.kr.tnt.designsystem.component.button.TnTTextButton
import co.kr.tnt.designsystem.component.button.model.ButtonSize
import co.kr.tnt.designsystem.component.button.model.ButtonType
import co.kr.tnt.designsystem.theme.TnTTheme

@Composable
fun TnTCheckToggleDialog(
title: String,
content: String,
isChecked: Boolean,
checkToggleText: String,
leftButtonText: String,
rightButtonText: String,
modifier: Modifier = Modifier,
onLeftButtonClick: () -> Unit,
onRightButtonClick: () -> Unit,
onCheckClick: () -> Unit,
onDismiss: () -> Unit,
) {
Dialog(
onDismissRequest = { onDismiss() },
properties = DialogProperties(usePlatformDefaultWidth = false),
) {
Card(
shape = RoundedCornerShape(16.dp),
colors = cardColors().copy(TnTTheme.colors.commonColors.Common0),
modifier = modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(horizontal = 20.dp),
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.padding(20.dp),
) {
Text(
text = title,
style = TnTTheme.typography.h3.copy(
textAlign = TextAlign.Center,
),
color = TnTTheme.colors.neutralColors.Neutral900,
modifier = Modifier.padding(top = 20.dp),
)
Text(
text = content,
style = TnTTheme.typography.body2Medium.copy(
textAlign = TextAlign.Center,
),
color = TnTTheme.colors.neutralColors.Neutral500,
modifier = Modifier.padding(top = 10.dp),
)
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 5.dp, vertical = 20.dp),
) {
TnTCheckToggle(
isChecked = isChecked,
onCheckClick = onCheckClick,
)
Text(
text = checkToggleText,
style = TnTTheme.typography.body2Medium,
color = TnTTheme.colors.neutralColors.Neutral500,
modifier = Modifier.padding(start = 4.dp),
)
}
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
TnTTextButton(
size = ButtonSize.Medium,
type = ButtonType.Gray,
text = leftButtonText,
onClick = onLeftButtonClick,
modifier = Modifier.weight(1f),
)
TnTTextButton(
size = ButtonSize.Medium,
type = ButtonType.Primary,
text = rightButtonText,
onClick = onRightButtonClick,
modifier = Modifier.weight(1f),
)
}
}
}
}
}

@Preview
@Composable
private fun TnTCheckToggleDialogPreview() {
TnTTheme {
var isChecked by remember { mutableStateOf(false) }

TnTCheckToggleDialog(
title = "ํŠธ๋ ˆ์ด๋„ˆ๋ฅผ ์—ฐ๊ฒฐํ•ด ์ฃผ์„ธ์š”",
content = "์—ฐ๊ฒฐํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ ์ผ๋ถ€ ๊ธฐ๋Šฅ์ด ์ œํ•œ๋ผ์š”\n์ดˆ๋Œ€ ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•ด ์—ฐ๊ฒฐํ•ด์ฃผ์‹œ๊ฒ ์–ด์š”?",
checkToggleText = "3์ผ ๋™์•ˆ ๋ณด์ง€ ์•Š๊ธฐ",
isChecked = isChecked,
onLeftButtonClick = {},
onRightButtonClick = {},
onCheckClick = { isChecked = !isChecked },
leftButtonText = "๋‹ค์Œ์—",
rightButtonText = "์—ฐ๊ฒฐํ•˜๊ธฐ",
onDismiss = {},
)
}
}

0 comments on commit d1cdff6

Please sign in to comment.