Transition
public class Transition<S>
internal constructor(
private val transitionState: TransitionState<S>,
@get:RestrictTo(RestrictTo.Scope.LIBRARY) public val parentTransition: Transition<*>?,
public val label: String? = null,
)
Transition
manages all the child animations on a state level. Child animations can be created
in a declarative way using Transition.animateFloat
, Transition.animateValue
,
animateColor
etc. When the targetState
changes,
Transition
will automatically start or adjust course for all its child animations to animate to
the new target values defined for each animation.
After arriving at targetState
, Transition
will be triggered to run if any child animation
changes its target value (due to their dynamic target calculation logic, such as theme-dependent
values).
Secondary Constructors
@PublishedApi
internal constructor(
transitionState: TransitionState<S>,
label: String? = null,
) : this(transitionState, null, label)
internal constructor(
initialState: S,
label: String?,
) : this(MutableTransitionState(initialState), null, label)
@PublishedApi
internal constructor(
transitionState: MutableTransitionState<S>,
label: String? = null,
) : this(transitionState as TransitionState<S>, null, label)
Functions
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
public fun setPlaytimeAfterInitialAndTargetStateEstablished(
initialState: S,
targetState: S,
playTimeNanos: Long,
)
This allows tools to set the transition (between initial and target state) to a specific
playTimeNanos
.
Note: This function is intended for tooling use only.
Caveat: Once initialState
or targetState
changes, it needs to take a whole
composition pass for all the animations and child transitions to recompose with the new
initialState
and targetState
. Subsequently all the animations will be updated to the
given play time.
Caveat: This function puts Transition
in a manual playtime setting mode. From then on
the Transition
will not resume normal animation runs.