Avsluta-dialogen: tidsredigeringen hopfälld bakom 'Ändra tid'
All checks were successful
release / build-release (push) Successful in 4m46s

Standardvyn visar bara en rad: start → slut (varaktighet). Knappen
fäller ut start/varaktighet/slut-kontrollerna vid behov.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kf4MAbZ3c3B4Xy5XfuGsCP
This commit is contained in:
2026-07-25 11:14:42 +02:00
parent 983886e8f1
commit 27331b20a7

View File

@@ -473,6 +473,7 @@ private fun CompleteSessionDialog(
mutableStateOf(((lastActivity - originalStart) / 1000).toInt().coerceAtLeast(60)) mutableStateOf(((lastActivity - originalStart) / 1000).toInt().coerceAtLeast(60))
} }
var showCalorieInfo by remember { mutableStateOf(false) } var showCalorieInfo by remember { mutableStateOf(false) }
var showTimeEditor by remember { mutableStateOf(false) }
var showDatePicker by remember { mutableStateOf(false) } var showDatePicker by remember { mutableStateOf(false) }
var showTimePicker by remember { mutableStateOf(false) } var showTimePicker by remember { mutableStateOf(false) }
var showDurationPicker by remember { mutableStateOf(false) } var showDurationPicker by remember { mutableStateOf(false) }
@@ -626,73 +627,89 @@ private fun CompleteSessionDialog(
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
) )
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) { val zone = java.time.ZoneId.systemDefault()
val start = java.time.Instant.ofEpochMilli(startEpochMs).atZone(zone)
val end = java.time.Instant.ofEpochMilli(startEpochMs + durationSeconds * 1000L)
.atZone(zone)
Row(verticalAlignment = Alignment.CenterVertically) {
Text( Text(
"START (rätta om passet startades sent eller glömdes)", buildString {
style = MaterialTheme.typography.labelSmall, append(start.format(java.time.format.DateTimeFormatter.ofPattern("EEE d MMM HH:mm")))
color = MaterialTheme.colorScheme.onSurfaceVariant, append(" → %02d:%02d".format(end.hour, end.minute))
if (end.toLocalDate() != start.toLocalDate()) append(" +1d")
append(" (%d:%02d)".format(durationSeconds / 3600, (durationSeconds % 3600) / 60))
},
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.weight(1f),
) )
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { TextButton(onClick = { showTimeEditor = !showTimeEditor }) {
val zone = java.time.ZoneId.systemDefault() Text(if (showTimeEditor) "Dölj" else "Ändra tid")
val start = java.time.Instant.ofEpochMilli(startEpochMs).atZone(zone)
FilledTonalButton(
onClick = { showDatePicker = true },
modifier = Modifier.weight(1f),
) {
Text(
start.toLocalDate().format(
java.time.format.DateTimeFormatter.ofPattern("EEE d MMM")
)
)
}
FilledTonalButton(
onClick = { showTimePicker = true },
modifier = Modifier.weight(1f),
) {
Text("%02d:%02d".format(start.hour, start.minute))
}
} }
} }
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { if (showTimeEditor) {
val zone = java.time.ZoneId.systemDefault() Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
val startDay = java.time.Instant.ofEpochMilli(startEpochMs)
.atZone(zone).toLocalDate()
val end = java.time.Instant.ofEpochMilli(startEpochMs + durationSeconds * 1000L)
.atZone(zone)
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
Text( Text(
"VARAKTIGHET", "START (rätta om passet startades sent eller glömdes)",
style = MaterialTheme.typography.labelSmall, style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
) )
FilledTonalButton( Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
onClick = { showDurationPicker = true }, FilledTonalButton(
modifier = Modifier.fillMaxWidth(), onClick = { showDatePicker = true },
) { modifier = Modifier.weight(1f),
Text("%d:%02d".format(durationSeconds / 3600, (durationSeconds % 3600) / 60)) ) {
Text(
start.toLocalDate().format(
java.time.format.DateTimeFormatter.ofPattern("EEE d MMM")
)
)
}
FilledTonalButton(
onClick = { showTimePicker = true },
modifier = Modifier.weight(1f),
) {
Text("%02d:%02d".format(start.hour, start.minute))
}
} }
} }
Column(
modifier = Modifier.weight(1f), Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
verticalArrangement = Arrangement.spacedBy(4.dp), Column(
) { modifier = Modifier.weight(1f),
Text( verticalArrangement = Arrangement.spacedBy(4.dp),
"SLUT",
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
FilledTonalButton(
onClick = { showEndPicker = true },
modifier = Modifier.fillMaxWidth(),
) { ) {
Text( Text(
"%02d:%02d".format(end.hour, end.minute) + "VARAKTIGHET",
if (end.toLocalDate() != startDay) " +1d" else "" style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
) )
FilledTonalButton(
onClick = { showDurationPicker = true },
modifier = Modifier.fillMaxWidth(),
) {
Text("%d:%02d".format(durationSeconds / 3600, (durationSeconds % 3600) / 60))
}
}
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
Text(
"SLUT",
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
FilledTonalButton(
onClick = { showEndPicker = true },
modifier = Modifier.fillMaxWidth(),
) {
Text(
"%02d:%02d".format(end.hour, end.minute) +
if (end.toLocalDate() != start.toLocalDate()) " +1d" else ""
)
}
} }
} }
} }