Modern Apps git

← Modern-Apps.git

chess: reserve puzzle action-row height to prevent layout shift

Commit
6336a8bd59721fd58101a52aa98a62ca6b5402b6
Author
Vayun Mathur <[email protected]>
When
2026-07-08 18:41 UTC (5 months ago)
Parents
e9940d6

Diff

games/chess/src/main/java/com/vayunmathur/games/chess/MainActivity.kt
diff --git a/games/chess/src/main/java/com/vayunmathur/games/chess/MainActivity.kt b/games/chess/src/main/java/com/vayunmathur/games/chess/MainActivity.ktindex d43daebc52..ccf7e89621 100644--- a/games/chess/src/main/java/com/vayunmathur/games/chess/MainActivity.kt+++ b/games/chess/src/main/java/com/vayunmathur/games/chess/MainActivity.kt@@ -606,18 +606,23 @@ fun PuzzleScreen(viewModel: PuzzleViewModel) {             )             Spacer(Modifier.height(16.dp)) -            Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {+            // Reserve the action-row height whether or not the Failed buttons are+            // shown, so the board and everything above it never shift.+            Box(Modifier.height(40.dp), contentAlignment = Alignment.Center) {                 if (uiState.status == PuzzleStatus.Failed) {-                    Button(onClick = { viewModel.retry() }) {-                        Text(stringResource(R.string.puzzle_retry))-                    }-                    OutlinedButton(onClick = { viewModel.showSolution() }) {-                        Text(stringResource(R.string.puzzle_show_solution))+                    Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {+                        Button(onClick = { viewModel.retry() }) {+                            Text(stringResource(R.string.puzzle_retry))+                        }+                        OutlinedButton(onClick = { viewModel.showSolution() }) {+                            Text(stringResource(R.string.puzzle_show_solution))+                        }                     }                 }-                Button(onClick = { viewModel.loadRandom() }) {-                    Text(stringResource(R.string.puzzle_next))-                }+            }+            Spacer(Modifier.height(8.dp))+            Button(onClick = { viewModel.loadRandom() }) {+                Text(stringResource(R.string.puzzle_next))             }         }     }