Skip to content

Commit f955ed2

Browse files
jamesarichclaude
andcommitted
refactor: make the event-fonts toggle row fully toggleable (a11y)
CodeRabbit nitpick: the whole row (label + switch) now toggles the pref via Modifier.toggleable(role = Role.Switch); the Switch is visual-only (onCheckedChange = null) so it doesn't double-fire. Bigger touch target, one semantics node. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 4dff4d7 commit f955ed2

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/EventInfoSheet.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
2525
import androidx.compose.foundation.layout.padding
2626
import androidx.compose.foundation.layout.size
2727
import androidx.compose.foundation.rememberScrollState
28+
import androidx.compose.foundation.selection.toggleable
2829
import androidx.compose.foundation.shape.CircleShape
2930
import androidx.compose.foundation.verticalScroll
3031
import androidx.compose.material3.ExperimentalMaterial3Api
@@ -43,6 +44,7 @@ import androidx.compose.ui.graphics.Color
4344
import androidx.compose.ui.graphics.luminance
4445
import androidx.compose.ui.graphics.vector.ImageVector
4546
import androidx.compose.ui.platform.LocalUriHandler
47+
import androidx.compose.ui.semantics.Role
4648
import androidx.compose.ui.semantics.heading
4749
import androidx.compose.ui.semantics.semantics
4850
import androidx.compose.ui.unit.dp
@@ -101,7 +103,13 @@ fun EventInfoSheet(edition: EventFirmwareEdition, onDismiss: () -> Unit) {
101103
if (fontsToggle.available) {
102104
HorizontalDivider()
103105
Row(
104-
modifier = Modifier.fillMaxWidth(),
106+
modifier =
107+
Modifier.fillMaxWidth()
108+
.toggleable(
109+
value = fontsToggle.enabled,
110+
onValueChange = fontsToggle.onChange,
111+
role = Role.Switch,
112+
),
105113
horizontalArrangement = Arrangement.spacedBy(12.dp),
106114
verticalAlignment = Alignment.CenterVertically,
107115
) {
@@ -110,7 +118,8 @@ fun EventInfoSheet(edition: EventFirmwareEdition, onDismiss: () -> Unit) {
110118
style = MaterialTheme.typography.bodyMedium,
111119
modifier = Modifier.weight(1f),
112120
)
113-
Switch(checked = fontsToggle.enabled, onCheckedChange = fontsToggle.onChange)
121+
// Row owns the toggle; null keeps the Switch visual-only (no double-fire).
122+
Switch(checked = fontsToggle.enabled, onCheckedChange = null)
114123
}
115124
}
116125
}

0 commit comments

Comments
 (0)