https://kotlinlang.org logo
#compose
Title
# compose
c

Christian Maier

01/02/2021, 2:17 PM
When I shrink a Card using a tween animation, how can change the size another card as soon as the tween animation is finished? Traditionally, I’d think of an end-Listener and start an animation on another View
j

Jeisson Sáchica

01/04/2021, 7:29 PM
How are you firing the animation? the
animate
composable takes an
endListener: (Float) -> Unit
Or if you're using an
AnimatedFloat
, the
animateTo
method takes an
onEnd: (AnimationEndReason, T) -> Unit
c

Christian Maier

01/04/2021, 8:02 PM
I’m using a
transitionDefinition
Than I’m starting a
transition()
with that definition
Can I achieve that with these tools?
j

Jeisson Sáchica

01/04/2021, 8:08 PM
Great! Then there is an optional parameter that composable takes which is a
onStateChangeFinished: (T) -> Unit
👍 1
So if you have let's say t wo states: Visible and Collapsed, that callback will be called when the animation changes from one to the other
c

Christian Maier

01/04/2021, 8:10 PM
I should’ve seen that. 😕
Perfect, just what I needed!
1
Thank you very much!
j

Jeisson Sáchica

01/04/2021, 8:10 PM
No problem
c

Christian Maier

01/04/2021, 8:11 PM
I need to pay more attention but the signatures, but some are really long. Anyways, bad excuse!
j

Jeisson Sáchica

01/04/2021, 8:13 PM
No worries, one can easily miss them among that many parameters. Even the definition of the
transition
states
// TODO: The list of params is getting a bit long. Consider grouping them.
So that will most probably change for the better in the future