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