pipes: add next-level FAB and hide undo/restart on win
- Commit
acf52948b2340c015fcefbf472e828cc4dda070b- Author
- Vayun Mathur <[email protected]>
- When
- 2026-08-07 00:25 UTC (4 months ago)
- Parents
a0255cb
Diff
games/pipes/src/main/java/com/vayunmathur/games/pipes/MainActivity.kt
diff --git a/games/pipes/src/main/java/com/vayunmathur/games/pipes/MainActivity.kt b/games/pipes/src/main/java/com/vayunmathur/games/pipes/MainActivity.ktindex 4125ace55b..8881b3b642 100644--- a/games/pipes/src/main/java/com/vayunmathur/games/pipes/MainActivity.kt+++ b/games/pipes/src/main/java/com/vayunmathur/games/pipes/MainActivity.kt@@ -35,6 +35,8 @@ import com.vayunmathur.library.ui.Icon import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.FloatingActionButton+import com.vayunmathur.library.ui.IconArrowForward import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Switch import com.vayunmathur.library.ui.Text@@ -45,6 +47,7 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.alpha import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight@@ -485,7 +488,17 @@ fun GameBoardScreen( onBack: () -> Unit, onLevelChange: (Int) -> Unit, ) {- Scaffold(topBar = { TopAppBar({}, navigationIcon = { IconNavigation(onBack) }) }) { innerPadding ->+ Scaffold(+ topBar = { TopAppBar({}, navigationIcon = { IconNavigation(onBack) }) },+ floatingActionButton = {+ // Quick "next level" shortcut once solved, for players who want to move on fast.+ if (state.isLevelWon && state.levelIndex < state.maxLevelIndex) {+ FloatingActionButton(onClick = { onLevelChange(state.levelIndex + 1) }) {+ IconArrowForward()+ }+ }+ },+ ) { innerPadding -> Surface( modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background@@ -504,15 +517,20 @@ fun GameBoardScreen( ) } val actionButtons = @Composable {+ // Kept in the layout (invisible + disabled) once solved so the board doesn't+ // shift; neither button does anything on a won level. val enabled = state.canUndo && !state.isLevelWon+ val hiddenWhenWon = Modifier.alpha(if (state.isLevelWon) 0f else 1f) Button( onClick = { actions.onUndo() },+ modifier = hiddenWhenWon, enabled = enabled ) { Text(stringResource(UiR.string.undo)) } Button( onClick = { actions.onRestart() },+ modifier = hiddenWhenWon, enabled = enabled ) { Text(stringResource(R.string.restart))