theapache64
09/20/2021, 4:43 PMMutableTransitionState
(MTS) with updateTransition
is only useful if we want to update the state within the composable. If we simply want to access the MTS#currentState
, MTS#targetState
and MTS#isIdle
, we can use Transition#currentState
, Transition#targetState
and Transition#isRunning
respectively. Please correct me if am wrong.theapache64
09/20/2021, 5:53 PMtransition
object inside animationSpec
like this?Doris Liu
09/20/2021, 6:39 PMMutableTransitionState
can be created and accessed from anywhere such as your ViewModel, whereas updateTransition
can only be invoked from composition. Here's an example of creating & manipulating MutableTransitionState
from outside of composition: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]se/animation/demos/AnimatedVisiblilityLazyColumnDemo.kt;l=115
It's best to read initialState
& targetState
in transitionSpec
from the receiver AnimatedContentScope (which is an impl of Transition.Segment), instead of from the Transition directly. When seeking Transitions (e.g. for animation tooling), we'll be creating new Transition.Segment
for the specific initial/target required by seeking, and call Transition.Segment.transitionSpec()
to obtain the animations used in that segment. There's no guarantee that the Segment.initialState is always the same as Transition.currentState.theapache64
09/20/2021, 6:40 PMDoris Liu
09/20/2021, 6:43 PMMTS#targetState/currentState
are the same as Transition#targetState/currentState
.