Modern Apps git

← Modern-Apps.git

unblockjam: add next-level FAB and hide undo/restart on win

Commit
a0255cb8792e05c0f3c391d43233857eae07d0b9
Author
Vayun Mathur <[email protected]>
When
2026-08-07 00:25 UTC (4 months ago)
Parents
283e72b

Diff

games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/MainActivity.kt
diff --git a/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/MainActivity.kt b/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/MainActivity.ktindex 2bd4f54c9a..d87fb6ee63 100644--- a/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/MainActivity.kt+++ b/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/MainActivity.kt@@ -34,6 +34,8 @@ import com.vayunmathur.library.ui.CardDefaults import com.vayunmathur.library.ui.CircularProgressIndicator import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.Icon+import com.vayunmathur.library.ui.FloatingActionButton+import com.vayunmathur.library.ui.IconArrowForward import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Scaffold@@ -49,6 +51,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.alpha import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource@@ -405,7 +408,17 @@ fun GameScreen(state: GameUiState, actions: GameActions, onBack: () -> Unit) {     val currentLevelData = state.levelData     val isLevelWon = state.isLevelWon -    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 (isLevelWon && state.levelIndex < state.maxLevelIndex) {+                FloatingActionButton(onClick = { actions.onLevelChange(state.levelIndex + 1) }) {+                    IconArrowForward()+                }+            }+        },+    ) { innerPadding ->         Surface(             modifier = Modifier.fillMaxSize(),             color = MaterialTheme.colorScheme.background@@ -424,14 +437,18 @@ fun GameScreen(state: GameUiState, actions: GameActions, onBack: () -> Unit) {                 )             }             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.                 Button(                     onClick = { actions.onUndo() },+                    modifier = Modifier.alpha(if (isLevelWon) 0f else 1f),                     enabled = state.canUndo && !isLevelWon                 ) {                     Text(stringResource(UiR.string.undo))                 }                 Button(                     onClick = { actions.onRestart() },+                    modifier = Modifier.alpha(if (isLevelWon) 0f else 1f),                     enabled = state.canUndo && !isLevelWon                 ) {                     Text(stringResource(R.string.restart))