Jetpack Compose accessibility with Semantics

Viewed 213

I'm trying to implement accessibility as describe here. This is the Modifier I tried:

var isChecked: Boolean by rememberSaveable { mutableStateOf(value = false) } 
Row(
    modifier = Modifier
        .semantics {
            contentDescription = "My custom content description" 
            stateDescription = if (isChecked) {
                "Checkbox has been selected" 
            } else {
                "Checkbox has been unselected"
            }
        }
        .toggleable(
            value = isChecked,
            onValueChange = { isChecked = it },
        )
) {
    // [...] other Composables
    Checkbox(
        checked = isChecked,
        onCheckedChange = null, // handle by toggleable
        modifier = Modifier
            .padding(16.dp), // as onCheckedChange is null, we need to handle padding.
    )
}

But the result of Talkback is the following when I double tap

enter image description here

Am I missing something?

0 Answers
Related