|
| 1 | +package com.threegap.bitnagil.designsystem.component.block |
| 2 | + |
| 3 | +import androidx.compose.foundation.background |
| 4 | +import androidx.compose.foundation.layout.Column |
| 5 | +import androidx.compose.foundation.layout.Spacer |
| 6 | +import androidx.compose.foundation.layout.fillMaxWidth |
| 7 | +import androidx.compose.foundation.layout.height |
| 8 | +import androidx.compose.foundation.layout.padding |
| 9 | +import androidx.compose.foundation.shape.RoundedCornerShape |
| 10 | +import androidx.compose.material3.BasicAlertDialog |
| 11 | +import androidx.compose.material3.ExperimentalMaterial3Api |
| 12 | +import androidx.compose.material3.Text |
| 13 | +import androidx.compose.runtime.Composable |
| 14 | +import androidx.compose.ui.Modifier |
| 15 | +import androidx.compose.ui.text.style.TextAlign |
| 16 | +import androidx.compose.ui.tooling.preview.Preview |
| 17 | +import androidx.compose.ui.unit.dp |
| 18 | +import androidx.compose.ui.window.DialogProperties |
| 19 | +import com.threegap.bitnagil.designsystem.BitnagilTheme |
| 20 | +import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple |
| 21 | + |
| 22 | +@OptIn(ExperimentalMaterial3Api::class) |
| 23 | +@Composable |
| 24 | +fun BitnagilConfirmDialog( |
| 25 | + title: String, |
| 26 | + description: String, |
| 27 | + confirmButtonText: String, |
| 28 | + onConfirm: () -> Unit, |
| 29 | + modifier: Modifier = Modifier, |
| 30 | + dismissOnBackPress: Boolean = true, |
| 31 | + dismissOnClickOutside: Boolean = true, |
| 32 | +) { |
| 33 | + BasicAlertDialog( |
| 34 | + onDismissRequest = onConfirm, |
| 35 | + modifier = modifier, |
| 36 | + properties = DialogProperties( |
| 37 | + dismissOnBackPress = dismissOnBackPress, |
| 38 | + dismissOnClickOutside = dismissOnClickOutside, |
| 39 | + ), |
| 40 | + ) { |
| 41 | + Column( |
| 42 | + modifier = Modifier |
| 43 | + .background( |
| 44 | + color = BitnagilTheme.colors.white, |
| 45 | + shape = RoundedCornerShape(12.dp), |
| 46 | + ) |
| 47 | + .padding(vertical = 20.dp, horizontal = 24.dp), |
| 48 | + ) { |
| 49 | + Text( |
| 50 | + text = title, |
| 51 | + color = BitnagilTheme.colors.coolGray10, |
| 52 | + style = BitnagilTheme.typography.subtitle1SemiBold, |
| 53 | + modifier = Modifier.padding(bottom = 6.dp), |
| 54 | + ) |
| 55 | + |
| 56 | + Text( |
| 57 | + text = description, |
| 58 | + color = BitnagilTheme.colors.coolGray40, |
| 59 | + style = BitnagilTheme.typography.body2Medium, |
| 60 | + modifier = Modifier.padding(bottom = 18.dp), |
| 61 | + ) |
| 62 | + |
| 63 | + Text( |
| 64 | + text = confirmButtonText, |
| 65 | + color = BitnagilTheme.colors.orange500, |
| 66 | + style = BitnagilTheme.typography.body2Medium, |
| 67 | + textAlign = TextAlign.End, |
| 68 | + modifier = Modifier |
| 69 | + .fillMaxWidth() |
| 70 | + .clickableWithoutRipple { onConfirm() }, |
| 71 | + ) |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +@Preview |
| 77 | +@Composable |
| 78 | +private fun Preview() { |
| 79 | + BitnagilConfirmDialog( |
| 80 | + title = "루틴 완료를 저장하지 못했어요", |
| 81 | + description = "네트워크 연결에 문제가 있었던 것 같아요.\n다시 한 번 시도해 주세요.", |
| 82 | + confirmButtonText = "확인", |
| 83 | + onConfirm = {}, |
| 84 | + ) |
| 85 | +} |
0 commit comments