Hello. On the old Transition API, `transition` s h...
# compose
b
Hello. On the old Transition API,
transition
s had
onStateChangeFinished
callback. Does anyone know if there's a similar callback on the new API?
I inspected
Transition
code and seems like that is not supported. I wonder if that could be done here 🤔 or maybe having a callback for that is not a good idea?
z
Most of the animation apis have an animation ended event handler that gets a reason
b
The new animation (
animate*asState(...)
) apis have
finishedListener
parameters, yes. However, the transition apis (
updateTransition
,
transition.animate*(..)
) do not. So, when handling transitions, I'm not sure if there's a way to know "all the animations for this transition have ended"
d
The new transition has a
currentState
that can be observed.
currentState == targetState
signals that the transition for all animations has finished. 🙂
b
Thanks @Doris Liu! At the beginning it was a bit complicated to wrap my head around transition changes as State updates, but makes sense! I got it working, thank you 🙏
d
Glad it worked for you! 🙂 Expressing the finished event as a state change makes sequencing transition states a bit nicer, like in this example: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]/androidx/compose/animation/demos/DoubleTapToLikeDemo.kt;l=74
b
wooow... yes, that indeed looks pretty. And here I was writing a queue of states to handle sequencing transition states 🙃
once I'm done with my changes, I would really appreciate your feedback, if possible 😅
d
once I'm done with my changes, I would really appreciate your feedback, if possible
Sure thing! I'm happy to take a look! 🙂