From 58096b33ef4ea57d3897a2f6feb2c00c9a34e192 Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Sat, 2 Nov 2024 19:02:39 +0900 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20#79=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=EC=99=80=20=EA=B4=80=EB=A0=A8=EB=90=9C=20Toa?= =?UTF-8?q?st=20UI=20=EC=B6=94=EA=B0=80(=EC=A0=80=EC=9E=A5=EC=99=84?= =?UTF-8?q?=EB=A3=8C,=20=EC=8B=A4=ED=8C=A8,=20=EC=A0=80=EC=9E=A5=EA=B3=B5?= =?UTF-8?q?=EA=B0=84=20=EB=B6=80=EC=A1=B1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/block/pokittoast/PokitToast.kt | 30 ++++++++++++++----- .../ui/components/block/pokittoast/Preview.kt | 19 ++++++++++++ .../pokittoast/attributes/PokitToastType.kt | 18 +++++++++++ 3 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/attributes/PokitToastType.kt diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/PokitToast.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/PokitToast.kt index 550a4009..2f820bf2 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/PokitToast.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/PokitToast.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import pokitmons.pokit.core.ui.R +import pokitmons.pokit.core.ui.components.block.pokittoast.attributes.PokitToastType import pokitmons.pokit.core.ui.theme.PokitTheme @Composable @@ -27,11 +28,12 @@ fun PokitToast( text: String, onClick: (() -> Unit)? = null, onClickClose: () -> Unit = {}, + type: PokitToastType = PokitToastType.Normal ) { Row( modifier = modifier .clip(RoundedCornerShape(9999.dp)) - .background(PokitTheme.colors.backgroundTertiary) + .background(type.color) .clickable( enabled = onClick != null, onClick = onClick ?: {} @@ -39,13 +41,25 @@ fun PokitToast( .padding(start = 20.dp, end = 14.dp, top = 12.dp, bottom = 12.dp), verticalAlignment = Alignment.CenterVertically ) { - Text( - text = text, - style = PokitTheme.typography.body3Medium.copy(color = PokitTheme.colors.inverseWh), - maxLines = 2, - overflow = TextOverflow.Ellipsis, - modifier = Modifier.weight(1f) - ) + Row( + modifier = Modifier.weight(1f), + verticalAlignment = Alignment.CenterVertically + ) { + Text( + text = text, + style = PokitTheme.typography.body3Medium.copy(color = PokitTheme.colors.inverseWh), + maxLines = 2, + overflow = TextOverflow.Ellipsis, + ) + type.iconResourceId?.let { resourceId -> + Spacer(modifier = Modifier.width(8.dp)) + Icon( + painter = painterResource(id = resourceId), + contentDescription = null, + tint = PokitTheme.colors.inverseWh + ) + } + } Spacer(modifier = Modifier.width(12.dp)) diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/Preview.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/Preview.kt index 663d3435..42b6b088 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/Preview.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/Preview.kt @@ -8,6 +8,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import pokitmons.pokit.core.ui.components.block.pokittoast.attributes.PokitToastType import pokitmons.pokit.core.ui.theme.PokitTheme @Preview(showBackground = true) @@ -23,6 +24,24 @@ private fun Preview() { text = "최대 30개의 포킷을 생성할 수 있습니다.\n포킷을 삭제한 뒤에 추가해주세요.", onClick = {} ) + PokitToast( + modifier = Modifier.padding(20.dp), + text = "링크 저장 완료", + onClick = {}, + type = PokitToastType.Success + ) + PokitToast( + modifier = Modifier.padding(20.dp), + text = "링크 저장 실패", + onClick = {}, + type = PokitToastType.Error + ) + PokitToast( + modifier = Modifier.padding(20.dp), + text = "저장 공간 부족", + onClick = {}, + type = PokitToastType.Warning + ) } } } diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/attributes/PokitToastType.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/attributes/PokitToastType.kt new file mode 100644 index 00000000..7fff5a2b --- /dev/null +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/block/pokittoast/attributes/PokitToastType.kt @@ -0,0 +1,18 @@ +package pokitmons.pokit.core.ui.components.block.pokittoast.attributes + +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import pokitmons.pokit.core.ui.R +import pokitmons.pokit.core.ui.theme.PokitTheme + +enum class PokitToastType( + private val getColor: @Composable () -> Color, + val iconResourceId : Int? = null, +) { + Normal(getColor = { PokitTheme.colors.backgroundTertiary }), + Success(getColor = { PokitTheme.colors.success }, iconResourceId = R.drawable.icon_24_check), + Error(getColor = { PokitTheme.colors.error }), + Warning(getColor = { PokitTheme.colors.warning }); + + val color: Color @Composable get() = getColor() +}