SmartUpdateDialog.kt
composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/ui/screens/detail/SmartUpdateDialog.kt
1package eu.friedcutlet.yokan.ui.screens.detail23import yokan.composeapp.generated.resources.detail_smart_auto4import yokan.composeapp.generated.resources.detail_smart_always5import yokan.composeapp.generated.resources.detail_smart_days6import yokan.composeapp.generated.resources.detail_smart_update7import yokan.composeapp.generated.resources.detail_smart_explanation8import yokan.composeapp.generated.resources.detail_smart_estimate9import yokan.composeapp.generated.resources.detail_smart_insufficient10import androidx.compose.foundation.layout.Arrangement11import androidx.compose.foundation.layout.Column12import androidx.compose.foundation.layout.FlowRow13import androidx.compose.material3.AlertDialog14import androidx.compose.material3.FilterChip15import androidx.compose.material3.MaterialTheme16import androidx.compose.material3.Text17import androidx.compose.material3.TextButton18import androidx.compose.runtime.Composable19import androidx.compose.ui.Modifier20import androidx.compose.ui.unit.dp21import org.jetbrains.compose.resources.stringResource22import yokan.composeapp.generated.resources.Res23import yokan.composeapp.generated.resources.ui_close24import eu.friedcutlet.yokan.ui.components.compactDialogWidth2526@Composable27internal fun SmartUpdateDialog(28 manualDays: Int?,29 automaticDays: Int?,30 onChange: (Int?) -> Unit,31 onDismiss: () -> Unit,32) {33 androidx.compose.material3.AlertDialog(34 onDismissRequest = onDismiss,35 modifier = Modifier.compactDialogWidth(),36 confirmButton = { TextButton(onClick = onDismiss) { Text(stringResource(Res.string.ui_close)) } },37 title = { Text(stringResource(Res.string.detail_smart_update)) },38 text = {39 Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {40 Text(stringResource(Res.string.detail_smart_explanation), style = MaterialTheme.typography.bodySmall)41 Text(42 automaticDays?.let { stringResource(Res.string.detail_smart_estimate, it) }43 ?: stringResource(Res.string.detail_smart_insufficient),44 style = MaterialTheme.typography.bodyMedium,45 )46 FilterChip(47 selected = manualDays == null, onClick = { onChange(null) },48 label = { Text(stringResource(Res.string.detail_smart_auto)) },49 )50 FlowRow(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {51 listOf(0, 1, 3, 7, 14, 30).forEach { days ->52 FilterChip(53 selected = manualDays == days, onClick = { onChange(days) },54 label = { Text(if (days == 0) stringResource(Res.string.detail_smart_always) else stringResource(Res.string.detail_smart_days, days)) },55 )56 }57 }58 }59 },60 )61}62