clock: group stopwatch controls into a floating toolbar
- Commit
dc3377a5a2053e38a74a921804ed24064f1efcca- Author
- vayun-mathur <[email protected]>
- When
- 2026-08-21 18:44 UTC (3 months ago)
- Parents
3e68da1
Diff
clock/src/main/java/com/vayunmathur/clock/ui/StopwatchScreen.kt
diff --git a/clock/src/main/java/com/vayunmathur/clock/ui/StopwatchScreen.kt b/clock/src/main/java/com/vayunmathur/clock/ui/StopwatchScreen.ktindex 198f7a276e..5faf946b03 100644--- a/clock/src/main/java/com/vayunmathur/clock/ui/StopwatchScreen.kt+++ b/clock/src/main/java/com/vayunmathur/clock/ui/StopwatchScreen.kt@@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed-import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue@@ -33,6 +32,7 @@ import com.vayunmathur.clock.platform.StopwatchUiState import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.FloatingActionButton import com.vayunmathur.library.ui.HorizontalDivider+import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconPause import com.vayunmathur.library.ui.IconPlay import com.vayunmathur.library.ui.IconRestartAlt@@ -41,6 +41,7 @@ import com.vayunmathur.library.ui.LazyListScaffold import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.VerticalFloatingToolbar import kotlin.time.Duration.Companion.seconds /**@@ -62,15 +63,22 @@ fun StopwatchScreen(backStack: com.vayunmathur.library.util.NavBackStack<com.vay } LazyListScaffold(floatingActionButton = {- Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {+ // Lap and reset are peers of start/stop, not separate decisions, so they share the+ // stopwatch's one control surface rather than stacking as three loose FABs. A toolbar+ // rather than a FAB menu because lap is timed to whatever the user is measuring and+ // cannot afford an expand tap first.+ VerticalFloatingToolbar(+ floatingActionButton = {+ FloatingActionButton({ actions.toggleStopwatch() }) {+ if(isRunning) IconPause() else IconPlay()+ }+ },+ ) { if(isRunning) {- FloatingActionButton({ actions.addLap() }) { IconTimer() }+ IconButton({ actions.addLap() }) { IconTimer() } } if(countingTime > 0.seconds) {- FloatingActionButton(onClick = { actions.resetStopwatch() }) { IconRestartAlt() }- }- FloatingActionButton({ actions.toggleStopwatch() }) {- if(isRunning) IconPause() else IconPlay()+ IconButton({ actions.resetStopwatch() }) { IconRestartAlt() } } } }, horizontalPadding = 16.dp) {@@ -115,7 +123,7 @@ fun StopwatchScreen(backStack: com.vayunmathur.library.util.NavBackStack<com.vay item { Surface( modifier = Modifier.fillMaxWidth(),- shape = RoundedCornerShape(12.dp),+ shape = MaterialTheme.shapes.large, color = MaterialTheme.colorScheme.surfaceContainer ) { Column {
clock/src/main/java/com/vayunmathur/clock/ui/components/AlarmRingingScreen.kt
diff --git a/clock/src/main/java/com/vayunmathur/clock/ui/components/AlarmRingingScreen.kt b/clock/src/main/java/com/vayunmathur/clock/ui/components/AlarmRingingScreen.ktindex 5be0d7d3da..d2e98c7003 100644--- a/clock/src/main/java/com/vayunmathur/clock/ui/components/AlarmRingingScreen.kt+++ b/clock/src/main/java/com/vayunmathur/clock/ui/components/AlarmRingingScreen.kt@@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape-import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier@@ -61,13 +60,13 @@ fun AlarmRingingScreen( Button( onClick = onDismiss, modifier = Modifier.fillMaxWidth().height(96.dp),- shape = RoundedCornerShape(28.dp),+ shape = MaterialTheme.shapes.extraLarge, colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.primary, contentColor = MaterialTheme.colorScheme.onPrimary), elevation = ButtonDefaults.buttonElevation(defaultElevation = 8.dp) ) { Text(text = stringResource(R.string.button_stop), style = MaterialTheme.typography.headlineSmall, fontWeight = FontWeight.ExtraBold) }- FilledTonalButton(onClick = onSnooze, modifier = Modifier.fillMaxWidth().height(64.dp), shape = RoundedCornerShape(28.dp)) {+ FilledTonalButton(onClick = onSnooze, modifier = Modifier.fillMaxWidth().height(64.dp), shape = MaterialTheme.shapes.extraLarge) { IconPause(); Spacer(modifier = Modifier.width(8.dp)); Text(text = stringResource(R.string.button_snooze), style = MaterialTheme.typography.titleMedium) } }