Skip to content

Instantly share code, notes, and snippets.

@rooparsh
Last active October 16, 2020 08:49
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 rooparsh/b984765b465aed456720eaa832c1b142 to your computer and use it in GitHub Desktop.
Save rooparsh/b984765b465aed456720eaa832c1b142 to your computer and use it in GitHub Desktop.
Composable Function for Creating Text Radio Button
@Composable
fun RadioButton(text: String, selectedValue: String, onClickListener: (String) -> Unit) {
Row(Modifier
.fillMaxWidth()
.selectable(
selected = (text == selectedValue),
onClick = {
onClickListener(text)
}
)
.padding(horizontal = 16.dp)
) {
RadioButton(
selected = (text == selectedValue),
onClick = {
onClickListener(text)
}
)
Text(
text = text,
style = MaterialTheme.typography.body1.merge(),
modifier = Modifier.padding(start = 16.dp)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment