I have this class, and for the most part I just do
Checkable(x) { .. }
and that works great.
When I instead have
if(x) Checkable(true) { .. } else Checkable(false) { .. }
then the Switch composable differs between the two and jumps between the states instead of animating.
I think I know why - the context in which the switch is rendered differs, both checked & the lambda differs - but how can I fix that?
data class Checkable(
val checked: Boolean,
val enabled: Boolean = true,
val onCheckedChanged: (Boolean) -> Unit,
) : SettingsAction {
override val onClick = {
onCheckedChanged(!checked)
}
@Composable
override fun RowScope.Render() {
Switch(
checked = checked,
enabled = enabled,
onCheckedChanged = onCheckedChanged,
)
}
}