wordmaker: make bonus-word rows full-size with a definition cue (#ux-audit)
- Commit
fafb4fc70b5297067db9e05dbd2419237a8dc20f- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-13 01:31 UTC (23 days ago)
- Parents
d9d4dde
Symptom: in the Bonus Words dialog each word was a bare line of text about 28 dp tall - below the 48 dp minimum touch target, easy to miss or to hit the neighbouring word - and nothing suggested that tapping a word shows its definition. Root cause: BonusWordsDialog rendered each word as a Text with 4 dp vertical padding and a clickable modifier. Fix: each word is a shared library ListItem (56 dp minimum height, transparent container so it sits on the dialog surface) whose whole row is clickable, with a trailing info icon as the visual cue. The icon is marked decorative (cleared semantics) because the row itself is the button and already carries the word as its label; no new strings were needed. User-visible effect: bonus words are comfortable list rows with an "i" at the end, and tapping anywhere on a row opens the definition as before. Verification: new BonusListRowsTest - a row has a click action, is at least 48 dp tall, and opens the definition dialog. The existing bonus dialog tests still find and open words by text.
Diff
games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/dialogs/WordDialogs.kt
diff --git a/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/dialogs/WordDialogs.kt b/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/dialogs/WordDialogs.ktindex 5d458a87fc..f93c8f32a3 100644--- a/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/dialogs/WordDialogs.kt+++ b/games/wordmaker/src/main/java/com/vayunmathur/games/wordmaker/ui/dialogs/WordDialogs.kt@@ -2,8 +2,8 @@ package com.vayunmathur.games.wordmaker.ui.dialogs import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.rememberScrollState@@ -15,12 +15,18 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.pluralStringResource+import androidx.compose.ui.semantics.clearAndSetSemantics import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.vayunmathur.games.wordmaker.R import com.vayunmathur.library.ui.AlertDialog import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.IconInfo+import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.ListItemDefaults+import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.R as UiR @Composable@@ -62,15 +68,27 @@ fun BonusWordsDialog( title = { Text(text = pluralStringResource(R.plurals.bonus_words_title, bonusWords.size, bonusWords.size)) }, text = { LazyColumn(modifier = Modifier.fillMaxWidth()) {+ // Full-height list rows (the old ~28 dp text lines were hard to hit) with a+ // visible info affordance, so it is clear a tap shows the word's definition. items(bonusWords.toList().sorted()) { word ->- Text(- text = word,+ ListItem( modifier = Modifier- .padding(vertical = 4.dp) .fillMaxWidth() .clickable { definitionDialog = Pair(word, getDefinition(word))- })+ },+ trailingContent = {+ // Decorative: the row itself is the button.+ IconInfo(+ modifier = Modifier.clearAndSetSemantics {},+ tint = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ },+ colors = ListItemDefaults.colors(containerColor = Color.Transparent),+ contentPadding = PaddingValues(vertical = 4.dp),+ ) {+ Text(text = word)+ } } } },
games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/BonusListRowsTest.kt
diff --git a/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/BonusListRowsTest.kt b/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/BonusListRowsTest.ktnew file mode 100644index 0000000000..cb74d81eb7--- /dev/null+++ b/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/BonusListRowsTest.kt@@ -0,0 +1,37 @@+package com.vayunmathur.games.wordmaker.ui++import androidx.compose.ui.test.assertHasClickAction+import androidx.compose.ui.test.assertIsDisplayed+import androidx.compose.ui.test.junit4.createComposeRule+import androidx.compose.ui.test.onNodeWithText+import androidx.compose.ui.test.performClick+import androidx.compose.ui.unit.dp+import com.vayunmathur.games.wordmaker.ui.dialogs.BonusWordsDialog+import com.vayunmathur.library.ui.DynamicTheme+import org.junit.Rule+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner+import org.robolectric.annotation.Config+import kotlin.test.Test+import kotlin.test.assertTrue++@RunWith(RobolectricTestRunner::class)+@Config(qualifiers = "w411dp-h891dp")+class BonusListRowsTest {+ @get:Rule val rule = createComposeRule()++ @Test fun bonusWordRowsAreFullSizeTouchTargetsThatOpenTheDefinition() {+ rule.setContent {+ DynamicTheme {+ BonusWordsDialog(bonusWords = setOf("OWL", "COW"), getDefinition = { listOf("def of $it") }, onDismiss = {})+ }+ }+ val row = rule.onNodeWithText("OWL")+ row.assertHasClickAction()+ val height = row.fetchSemanticsNode().boundsInRoot.height+ val min = with(rule.density) { 48.dp.toPx() }+ assertTrue(height >= min, "bonus row is $height px tall, want at least $min")+ row.performClick()+ rule.onNodeWithText("def of OWL").assertIsDisplayed()+ }+}