Last active
October 8, 2021 02:14
-
-
Save navczydev/951e779ec5e9c6be09399125df1e5386 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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