diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-07-15 08:35:06 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-07-16 02:49:19 +0000 |
| commit | 488ab9c91e5b635688102682d92d117ef46235fc (patch) | |
| tree | 847ac0a9158bd346a646253fcb2594f8eb1c6d12 /android/app/src/main/java/org/terst/doot/widget | |
| parent | bec930383e250b3641f9b241d8b664bacc90d533 (diff) | |
fix(widget): redesign recurrence dialog layout
The 4 frequency chips and 7 weekday chips were each laid out in a
single non-wrapping Row -- on a real phone width these overflow/get
cut off rather than wrapping. The interval field was a full-width
OutlinedTextField with the unit baked into its label ("Every N
dailys"/"weeklys" -- ungrammatical for anything but weekly), and the
whole dialog had no visual grouping.
Redesigned: FlowRow (wraps instead of overflowing) for both chip rows;
single-letter weekday chips (S M T W T F S) to stay compact; a narrow
fixed-width (72dp) interval field paired with a correctly-pluralized
unit label rendered separately from the field; muted section labels
(REPEATS / EVERY / ON THESE DAYS) for structure. No callback/API
changes -- purely a layout rewrite of the same onSave/onClear/onDismiss
contract.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VTUSAEKfsPc6WGDq45yPHD
Diffstat (limited to 'android/app/src/main/java/org/terst/doot/widget')
| -rw-r--r-- | android/app/src/main/java/org/terst/doot/widget/ui/RecurrenceEditDialog.kt | 95 |
1 files changed, 70 insertions, 25 deletions
diff --git a/android/app/src/main/java/org/terst/doot/widget/ui/RecurrenceEditDialog.kt b/android/app/src/main/java/org/terst/doot/widget/ui/RecurrenceEditDialog.kt index 62fb549..c5c8aff 100644 --- a/android/app/src/main/java/org/terst/doot/widget/ui/RecurrenceEditDialog.kt +++ b/android/app/src/main/java/org/terst/doot/widget/ui/RecurrenceEditDialog.kt @@ -2,12 +2,15 @@ package org.terst.doot.widget.ui import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ExperimentalLayoutApi +import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.width import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.AlertDialog import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.FilterChip +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Text import androidx.compose.material3.TextButton @@ -16,6 +19,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.dp @@ -26,7 +30,34 @@ internal fun weekdayAbbrev(day: Int): String = when (day) { else -> "?" } -@OptIn(ExperimentalMaterial3Api::class) +/** Single-letter label for the compact weekday chip row (S M T W T F S). */ +private fun weekdayLetter(day: Int): String = when (day) { + 0 -> "S"; 1 -> "M"; 2 -> "T"; 3 -> "W"; 4 -> "T"; 5 -> "F"; 6 -> "S" + else -> "?" +} + +/** Correctly pluralized unit for a frequency + interval, e.g. "day"/"days". */ +private fun unitLabel(freq: String, interval: Int): String { + val plural = interval != 1 + return when (freq) { + "daily" -> if (plural) "days" else "day" + "weekly" -> if (plural) "weeks" else "week" + "monthly" -> if (plural) "months" else "month" + "yearly" -> if (plural) "years" else "year" + else -> "" + } +} + +@Composable +private fun SectionLabel(text: String) { + Text( + text = text.uppercase(), + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant + ) +} + +@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) @Composable fun RecurrenceEditDialog( initial: TaskRecurrence?, @@ -42,33 +73,47 @@ fun RecurrenceEditDialog( onDismissRequest = onDismiss, title = { Text("Recurrence") }, text = { - Column { - Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) { - listOf("daily", "weekly", "monthly", "yearly").forEach { option -> - FilterChip( - selected = freq == option, - onClick = { freq = option }, - label = { Text(option.replaceFirstChar { it.uppercase() }) } + Column(verticalArrangement = Arrangement.spacedBy(20.dp)) { + Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { + SectionLabel("Repeats") + FlowRow(horizontalArrangement = Arrangement.spacedBy(6.dp)) { + listOf("daily", "weekly", "monthly", "yearly").forEach { option -> + FilterChip( + selected = freq == option, + onClick = { freq = option }, + label = { Text(option.replaceFirstChar { it.uppercase() }) } + ) + } + } + } + + Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { + SectionLabel("Every") + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { + OutlinedTextField( + value = interval, + onValueChange = { if (it.all(Char::isDigit)) interval = it }, + modifier = Modifier.width(72.dp), + singleLine = true, + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number) ) + Text(unitLabel(freq, interval.toIntOrNull() ?: 1)) } } - OutlinedTextField( - value = interval, - onValueChange = { if (it.all(Char::isDigit)) interval = it }, - label = { Text("Every N ${freq}${if (interval != "1") "s" else ""}") }, - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), - singleLine = true - ) + if (freq == "weekly") { - Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { - (0..6).forEach { day -> - FilterChip( - selected = weekdays.contains(day), - onClick = { - weekdays = if (weekdays.contains(day)) weekdays - day else weekdays + day - }, - label = { Text(weekdayAbbrev(day)) } - ) + Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { + SectionLabel("On these days") + FlowRow(horizontalArrangement = Arrangement.spacedBy(4.dp)) { + (0..6).forEach { day -> + FilterChip( + selected = weekdays.contains(day), + onClick = { + weekdays = if (weekdays.contains(day)) weekdays - day else weekdays + day + }, + label = { Text(weekdayLetter(day)) } + ) + } } } } |
