Skip to content

Instantly share code, notes, and snippets.

@navczydev
Last active October 8, 2021 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save navczydev/951e779ec5e9c6be09399125df1e5386 to your computer and use it in GitHub Desktop.
Save navczydev/951e779ec5e9c6be09399125df1e5386 to your computer and use it in GitHub Desktop.
private fun TopicItem(itemTitle: String, selected: Boolean, onToggle: () -> Unit) {
// ...
val stateNotSubscribed = stringResource(R.string.state_not_subscribed)
val stateSubscribed = stringResource(R.string.state_subscribed)
Row(
modifier = Modifier
.semantics {
// custom description based on the state
stateDescription = if (selected) {
stateSubscribed
} else {
stateNotSubscribed
}
}
.toggleable(
value = selected,
onValueChange = { _ -> onToggle() },
role = Role.Checkbox
)
.padding(horizontal = 16.dp, vertical = 8.dp)
) {
// ...
Checkbox(
checked = selected,
onCheckedChange = null,
modifier = Modifier.align(Alignment.CenterVertically)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment