Skip to content

Instantly share code, notes, and snippets.

@navczydev
Created October 30, 2022 00:57
Show Gist options
  • Save navczydev/fd98ca14359c3ffe248f2dbad69c256b to your computer and use it in GitHub Desktop.
Save navczydev/fd98ca14359c3ffe248f2dbad69c256b to your computer and use it in GitHub Desktop.
@Composable
fun MaterialSwitch170(updateCheckStateError: () -> Unit, resetCheckErrorState: () -> Unit) {
AndroidView(factory = { context ->
MaterialSwitch(context).apply {
text = context.resources.getString(R.string.switch_from_1_7)
setThumbIconResource(R.drawable.baseline_check_circle_24)
setOnCheckedChangeListener { _, isChecked ->
when (isChecked) {
true -> updateCheckStateError()
false -> {
resetCheckErrorState()
}
}
}
}
}, update = {
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment