|
| 1 | +package com.neki.android.core.designsystem.dialog |
| 2 | + |
| 3 | +import androidx.compose.foundation.background |
| 4 | +import androidx.compose.foundation.layout.Arrangement |
| 5 | +import androidx.compose.foundation.layout.Column |
| 6 | +import androidx.compose.foundation.layout.fillMaxWidth |
| 7 | +import androidx.compose.foundation.layout.padding |
| 8 | +import androidx.compose.foundation.layout.widthIn |
| 9 | +import androidx.compose.foundation.shape.RoundedCornerShape |
| 10 | +import androidx.compose.material3.Icon |
| 11 | +import androidx.compose.material3.Text |
| 12 | +import androidx.compose.runtime.Composable |
| 13 | +import androidx.compose.ui.Alignment |
| 14 | +import androidx.compose.ui.Modifier |
| 15 | +import androidx.compose.ui.draw.clip |
| 16 | +import androidx.compose.ui.graphics.Color |
| 17 | +import androidx.compose.ui.graphics.vector.ImageVector |
| 18 | +import androidx.compose.ui.res.vectorResource |
| 19 | +import androidx.compose.ui.text.style.TextAlign |
| 20 | +import androidx.compose.ui.text.style.TextDecoration |
| 21 | +import androidx.compose.ui.unit.dp |
| 22 | +import androidx.compose.ui.window.Dialog |
| 23 | +import androidx.compose.ui.window.DialogProperties |
| 24 | +import com.neki.android.core.designsystem.ComponentPreview |
| 25 | +import com.neki.android.core.designsystem.R |
| 26 | +import com.neki.android.core.designsystem.button.CTAButtonPrimary |
| 27 | +import com.neki.android.core.designsystem.modifier.clickableSingle |
| 28 | +import com.neki.android.core.designsystem.ui.theme.NekiTheme |
| 29 | + |
| 30 | +@Composable |
| 31 | +fun SingleButtonWithTextButtonAlertDialog( |
| 32 | + title: String, |
| 33 | + content: String, |
| 34 | + buttonText: String, |
| 35 | + textButtonText: String, |
| 36 | + onDismissRequest: () -> Unit, |
| 37 | + onButtonClick: () -> Unit, |
| 38 | + onTextButtonClick: () -> Unit, |
| 39 | + enabled: Boolean = true, |
| 40 | + properties: DialogProperties = DialogProperties( |
| 41 | + usePlatformDefaultWidth = false, |
| 42 | + dismissOnBackPress = false, |
| 43 | + dismissOnClickOutside = false, |
| 44 | + ), |
| 45 | +) { |
| 46 | + Dialog( |
| 47 | + onDismissRequest = onDismissRequest, |
| 48 | + properties = properties, |
| 49 | + ) { |
| 50 | + Column( |
| 51 | + modifier = Modifier |
| 52 | + .fillMaxWidth() |
| 53 | + .padding(horizontal = 20.dp) |
| 54 | + .widthIn(max = 400.dp) |
| 55 | + .clip(RoundedCornerShape(20.dp)) |
| 56 | + .background(NekiTheme.colorScheme.white) |
| 57 | + .padding(top = 20.dp), |
| 58 | + horizontalAlignment = Alignment.CenterHorizontally, |
| 59 | + verticalArrangement = Arrangement.spacedBy(12.dp), |
| 60 | + ) { |
| 61 | + Icon( |
| 62 | + imageVector = ImageVector.vectorResource(R.drawable.icon_dialog_alert), |
| 63 | + tint = Color.Unspecified, |
| 64 | + contentDescription = null, |
| 65 | + ) |
| 66 | + Column( |
| 67 | + modifier = Modifier.padding(horizontal = 24.dp), |
| 68 | + verticalArrangement = Arrangement.spacedBy(2.dp), |
| 69 | + horizontalAlignment = Alignment.CenterHorizontally, |
| 70 | + ) { |
| 71 | + Text( |
| 72 | + text = title, |
| 73 | + style = NekiTheme.typography.title18Bold, |
| 74 | + color = NekiTheme.colorScheme.gray900, |
| 75 | + textAlign = TextAlign.Center, |
| 76 | + ) |
| 77 | + Text( |
| 78 | + text = content, |
| 79 | + style = NekiTheme.typography.body14Regular, |
| 80 | + color = NekiTheme.colorScheme.gray500, |
| 81 | + textAlign = TextAlign.Center, |
| 82 | + ) |
| 83 | + } |
| 84 | + Column( |
| 85 | + modifier = Modifier.padding(vertical = 12.dp), |
| 86 | + horizontalAlignment = Alignment.CenterHorizontally, |
| 87 | + verticalArrangement = Arrangement.spacedBy(8.dp), |
| 88 | + ) { |
| 89 | + CTAButtonPrimary( |
| 90 | + text = buttonText, |
| 91 | + onClick = onButtonClick, |
| 92 | + modifier = Modifier |
| 93 | + .fillMaxWidth() |
| 94 | + .padding(horizontal = 12.dp), |
| 95 | + enabled = enabled, |
| 96 | + ) |
| 97 | + Text( |
| 98 | + modifier = Modifier |
| 99 | + .padding( |
| 100 | + vertical = 4.dp, |
| 101 | + horizontal = 56.dp, |
| 102 | + ) |
| 103 | + .clickableSingle(onClick = onTextButtonClick), |
| 104 | + text = textButtonText, |
| 105 | + style = NekiTheme.typography.body14Regular, |
| 106 | + color = NekiTheme.colorScheme.primary600, |
| 107 | + textDecoration = TextDecoration.Underline, |
| 108 | + ) |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | +} |
| 113 | + |
| 114 | +@ComponentPreview |
| 115 | +@Composable |
| 116 | +private fun SingleButtonWithTextButtonAlertDialogPreview() { |
| 117 | + NekiTheme { |
| 118 | + SingleButtonWithTextButtonAlertDialog( |
| 119 | + title = "메인 텍스트가 들어가는 곳", |
| 120 | + content = "보조 설명 텍스트가 들어가는 공간입니다", |
| 121 | + buttonText = "텍스트", |
| 122 | + textButtonText = "텍스트 공간", |
| 123 | + onDismissRequest = {}, |
| 124 | + onButtonClick = {}, |
| 125 | + onTextButtonClick = {}, |
| 126 | + ) |
| 127 | + } |
| 128 | +} |
0 commit comments