Skip to content

Commit

Permalink
[FEATURE] #79 링크 추가와 관련된 Toast UI 추가(저장완료, 실패, 저장공간 부족)
Browse files Browse the repository at this point in the history
  • Loading branch information
l5x5l committed Nov 2, 2024
1 parent fa0369b commit 58096b3
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,25 +28,38 @@ 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 ?: {}
)
.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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
)
}
}
}
Original file line number Diff line number Diff line change
@@ -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()
}

0 comments on commit 58096b3

Please sign in to comment.