package eu.friedcutlet.yokan.ui.components import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import org.jetbrains.compose.resources.stringResource import yokan.composeapp.generated.resources.Res import yokan.composeapp.generated.resources.action_cancel import yokan.composeapp.generated.resources.dialog_confirm @Composable fun ConfirmDialog( title: String, message: String, confirmLabel: String = stringResource(Res.string.dialog_confirm), dismissLabel: String = stringResource(Res.string.action_cancel), danger: Boolean = false, onConfirm: () -> Unit, onDismiss: () -> Unit, ) { AlertDialog( onDismissRequest = onDismiss, modifier = Modifier.compactDialogWidth(), // Extra-large rounded card with a pill confirm button — danger // variants use the error palette so destructive actions stand out // without resorting to all-caps text labels. shape = MaterialTheme.shapes.extraLarge, title = { Text( title, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold, ) }, text = { Text(message, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant) }, confirmButton = { Button( onClick = { onConfirm() onDismiss() }, shape = RoundedCornerShape(50), colors = if (danger) { ButtonDefaults.buttonColors( containerColor = MaterialTheme.colorScheme.errorContainer, contentColor = MaterialTheme.colorScheme.onErrorContainer, ) } else ButtonDefaults.buttonColors(), contentPadding = PaddingValues(horizontal = 20.dp, vertical = 8.dp), ) { Text(confirmLabel, style = MaterialTheme.typography.labelLarge) } }, dismissButton = { TextButton(onClick = onDismiss) { Text(dismissLabel) } }, ) }