Modern Apps git

← Modern-Apps.git

games-sudoku: give the board actions icons over labels

Commit
5279f6eaf4531510dacd87dce20e25030d5a6d59
Author
Vayun Mathur <[email protected]>
When
2026-11-07 20:04 UTC (29 days ago)
Parents
9f8cca6
The Notes / Erase / Undo / Hint bar was four text-only outlined
buttons, where conventional Sudoku apps (and this repo's other game
chrome) lead with an icon. Each action now shows its library icon
(IconEdit for notes, IconEraser, IconUndo, IconLightbulb for hint)
above a small label, which also keeps the four actions legible side
by side on a phone where icon-plus-label in a row would crowd.

Notes mode keeps its filled-tonal "on" state. No behaviour changes:
same actions, same enabled rules. Icons come from library/ui's
Icons.kt per repo rules; no shared code was touched.

Diff

games/sudoku/src/main/java/com/vayunmathur/games/sudoku/ui/GameBoardScreen.kt
diff --git a/games/sudoku/src/main/java/com/vayunmathur/games/sudoku/ui/GameBoardScreen.kt b/games/sudoku/src/main/java/com/vayunmathur/games/sudoku/ui/GameBoardScreen.ktindex 09750ed1c3..bd778883f6 100644--- a/games/sudoku/src/main/java/com/vayunmathur/games/sudoku/ui/GameBoardScreen.kt+++ b/games/sudoku/src/main/java/com/vayunmathur/games/sudoku/ui/GameBoardScreen.kt@@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth@@ -33,6 +34,10 @@ import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.CircularProgressIndicator import com.vayunmathur.library.ui.ConfirmDialog import com.vayunmathur.library.ui.FilledTonalButton+import com.vayunmathur.library.ui.IconEdit+import com.vayunmathur.library.ui.IconEraser+import com.vayunmathur.library.ui.IconLightbulb+import com.vayunmathur.library.ui.IconUndo import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.OutlinedButton import com.vayunmathur.library.ui.R as UiR@@ -233,6 +238,18 @@ private fun StatusRow(game: SudokuGameState) {     } } +/** Tighter than a text button's default padding: the content is an icon over a short label. */+private val ActionPadding = PaddingValues(horizontal = Spacing.xs, vertical = Spacing.sm)++/** One board action's content: its icon above its label, centred. */+@Composable+private fun ActionLabel(icon: @Composable () -> Unit, label: String) {+    Column(horizontalAlignment = Alignment.CenterHorizontally) {+        icon()+        Text(label, style = MaterialTheme.typography.labelSmall)+    }+}+ @Composable private fun ActionBar(     state: SudokuUiState,@@ -249,33 +266,45 @@ private fun ActionBar(             Modifier.fillMaxWidth(),             horizontalArrangement = Arrangement.spacedBy(Spacing.sm),         ) {+            // Icon over label, as in other Sudoku apps: the four actions stay legible+            // side by side on a phone, where icon-plus-label in a row would crowd.             // Tonal fill is the "on" state for notes mode; the label alone is too easy to miss.             if (game.notesMode) {                 FilledTonalButton(                     onClick = { actions.toggleNotesMode() },                     modifier = Modifier.weight(1f),-                ) { Text(stringResource(R.string.notes)) }+                    contentPadding = ActionPadding,+                ) { ActionLabel({ IconEdit(Modifier.size(20.dp)) }, stringResource(R.string.notes)) }             } else {                 OutlinedButton(                     onClick = { actions.toggleNotesMode() },                     modifier = Modifier.weight(1f),-                ) { Text(stringResource(R.string.notes)) }+                    contentPadding = ActionPadding,+                ) { ActionLabel({ IconEdit(Modifier.size(20.dp)) }, stringResource(R.string.notes)) }             }             OutlinedButton(                 onClick = { actions.clearCell() },                 modifier = Modifier.weight(1f),                 enabled = !ended,-            ) { Text(stringResource(R.string.erase)) }+                contentPadding = ActionPadding,+            ) { ActionLabel({ IconEraser(Modifier.size(20.dp)) }, stringResource(R.string.erase)) }             OutlinedButton(                 onClick = { actions.undo() },                 modifier = Modifier.weight(1f),                 enabled = state.canUndo,-            ) { Text(stringResource(com.vayunmathur.library.ui.R.string.undo)) }+                contentPadding = ActionPadding,+            ) {+                ActionLabel(+                    { IconUndo(Modifier.size(20.dp)) },+                    stringResource(com.vayunmathur.library.ui.R.string.undo),+                )+            }             OutlinedButton(                 onClick = { actions.hint() },                 modifier = Modifier.weight(1f),                 enabled = !ended,-            ) { Text(stringResource(R.string.hint)) }+                contentPadding = ActionPadding,+            ) { ActionLabel({ IconLightbulb(Modifier.size(20.dp)) }, stringResource(R.string.hint)) }         }         TextButton(             onClick = {
metadata_data/photos/games-sudoku/phone/1.png
diff --git a/metadata_data/photos/games-sudoku/phone/1.png b/metadata_data/photos/games-sudoku/phone/1.pngindex f69f05abb3..4f7592ca59 100644Binary files a/metadata_data/photos/games-sudoku/phone/1.png and b/metadata_data/photos/games-sudoku/phone/1.png differ
metadata_data/photos/games-sudoku/phone/2.png
diff --git a/metadata_data/photos/games-sudoku/phone/2.png b/metadata_data/photos/games-sudoku/phone/2.pngindex a90c2027ae..8210626e9b 100644Binary files a/metadata_data/photos/games-sudoku/phone/2.png and b/metadata_data/photos/games-sudoku/phone/2.png differ
metadata_data/photos/games-sudoku/phone/3.png
diff --git a/metadata_data/photos/games-sudoku/phone/3.png b/metadata_data/photos/games-sudoku/phone/3.pngindex 270db4c573..81bb7e1bad 100644Binary files a/metadata_data/photos/games-sudoku/phone/3.png and b/metadata_data/photos/games-sudoku/phone/3.png differ
metadata_data/photos/games-sudoku/phone/4.png
diff --git a/metadata_data/photos/games-sudoku/phone/4.png b/metadata_data/photos/games-sudoku/phone/4.pngindex 914ca99079..76f954565f 100644Binary files a/metadata_data/photos/games-sudoku/phone/4.png and b/metadata_data/photos/games-sudoku/phone/4.png differ
metadata_data/photos/games-sudoku/phone/5.png
diff --git a/metadata_data/photos/games-sudoku/phone/5.png b/metadata_data/photos/games-sudoku/phone/5.pngindex 42276720da..a7e33614d1 100644Binary files a/metadata_data/photos/games-sudoku/phone/5.png and b/metadata_data/photos/games-sudoku/phone/5.png differ