How can I animate a checkbox when the `checked` value changes (not from the `onCheckedChange` callba...
l
How can I animate a checkbox when the
checked
value changes (not from the
onCheckedChange
callback) - a touch form outside the Checkbox bounds (like a “check all”)
l
are you passing the
checked
as a parameter of your composable?
l
Yes
l
so you already have the behavior and you want the animation
l
Correct 🙂
l
Have you looked how is the animation triggered inside of checkbox?
l
with a
rememberRipple
? 😄
l
I haven't looked into it myself but your answer is in there
if the animation is using coroutines you could use a side effect to animate on state change/recomposition
l
I can apply the ripple where the user clicks with a
clickable
, but I don’t see how I can trigger it from the outside of the
CheckBox
function
l
if you can't manipulate the default checkbox to behave that way you could copy it and customize it yourself
I'd say the question is about UX. If you want to animate them all without user interacting directly with them
l
If I’m asking here, perhaps it’s because we already agreed to try that solution 🙂
l
I would try a custom checkbox then
l
So it’s not doable with what the SDK is giving us, is that what you’re saying?
l
the default behavior is change state without animation and animation upon interaction
you can copy the sdk checkbox and change that behavior
t
"How can I animate a checkbox..." which animation are you looking for? Do you want the same as if they had touched and gotten a ripple? I note that the ripple actually only happens if you do a prolonged click on it. If i tap super fast on them (at least the M3 ones), they just snap to the other state with no ripple. There may be a fast fade there, hard for my eyes to catch it.
l
Yes, the ripple animation is what I was looking for