Colton Idle
11/04/2021, 7:35 PMvar theValue by remember { mutableStateOf(false) }
val doSomething = { theValue = !theValue }
Row(modifier = Modifier.clickable { doSomething() }, verticalAlignment = CenterVertically) {
Text(text = "Show this: ")
Checkbox(checked = theValue, onCheckedChange = { doSomething() })
}
or is there something else to have the touch ripples not be independent depending if you click on the row vs the checkbox.Bryan Herbst
11/04/2021, 7:47 PMModifier.selectable()
with a Role.Checkbox
to get proper semantics on the row (or Modifier.triStateToggleable()
if you support the indeterminate state).
We are also setting onCheckedChange = null
on the actual Checkbox
so it isn’t independently clickableColton Idle
11/04/2021, 11:07 PMAlbert Chang
11/05/2021, 12:02 AMModifier.toggleable()
is better semantics-wise. Here’s a similar implementation which uses Switch
.Colton Idle
11/05/2021, 12:06 AMAlbert Chang
11/05/2021, 12:16 AM