I am still trying to solve this problem in compose, where I can animate multiple properties of a Composable, transitioning between, let’s say 3 states,
unpressed, pressed, expanded.
One challenge is that I need to go from
unpressed -> pressed, and let that transition finish before starting the transition from
pressed -> expanded. Otherwise the animation won’t be smooth if the user finishes the click action before the press animation finishes. So I need an intermediary that catches the state change and holds it until the finished listener is invoked.
The tweening functions need to take into account both the starting state and end state in order to calculate their values, so I need some object to encapsulate that information with the tween value.
I’ve tried wrapping this up in a ButtonTransition composable and returning a ButtonState instance that wraps the state and tween values:
ButtonState(val type: MutableStateType, val tween: StateFloat), and modifying the
ButtonState.type based on the
PressInteraction, but there’s a lot of issues with it.
From what I can tell, the recomposition from the animation is causing multiple instances of my ButtonTransition to be created, so the information is being lost upon recomposition (as well as other issues).