androidx.xr.compose.subspace.animation

Classes

AnimatedSpatialVisibilityScope

This is the scope for the content of AnimatedSpatialVisibility.

SpatialEnterTransition

SpatialEnterTransition defines how an AnimatedSpatialVisibility Composable appears on screen as it becomes visible.

SpatialExitTransition

SpatialExitTransition defines how an AnimatedSpatialVisibility Composable disappears on screen as it becomes not visible.

Objects

SpatialTransitionDefaults

Defaults for use with SpatialTransitions.

SpatialTransitions

Public transition spec APIs for use with AnimatedSpatialVisibility.

Top-level functions summary

Unit

AnimatedSpatialVisibility composable animates the appearance and disappearance of its subspace content, as visible value changes.

Unit

AnimatedSpatialVisibility composable animates the appearance and disappearance of its content, as visibleState's targetState changes.

Extension functions summary

Unit

This extension function creates an AnimatedSpatialVisibility composable as a child Transition of the given Transition.

Top-level functions

AnimatedSpatialVisibility

@Composable
@SubspaceComposable
fun AnimatedSpatialVisibility(
    visible: Boolean,
    modifier: SubspaceModifier = SubspaceModifier,
    enter: SpatialEnterTransition = SpatialTransitionDefaults.DefaultEnter,
    exit: SpatialExitTransition = SpatialTransitionDefaults.DefaultExit,
    label: String = "AnimatedSpatialVisibility",
    content: @Composable @SubspaceComposable AnimatedSpatialVisibilityScope.() -> Unit
): Unit

AnimatedSpatialVisibility composable animates the appearance and disappearance of its subspace content, as visible value changes. Different SpatialEnterTransitions and SpatialExitTransitions can be defined in enter and exit for the appearance and disappearance animation. There are 4 types of SpatialEnterTransition and SpatialExitTransition: Fade, Expand/Shrink, Scale and Slide. The enter transitions can be combined using +. Same for exit transitions. The order of the combination does not matter, as the transition animations will start simultaneously. See SpatialEnterTransition and SpatialExitTransition for details on the three types of transition.

Parameters
visible: Boolean

defines whether the content should be visible

modifier: SubspaceModifier = SubspaceModifier

modifier for the SubspaceLayout created to contain the content

enter: SpatialEnterTransition = SpatialTransitionDefaults.DefaultEnter

EnterTransition(s) used for the appearing animation

exit: SpatialExitTransition = SpatialTransitionDefaults.DefaultExit

ExitTransition(s) used for the disappearing animation

label: String = "AnimatedSpatialVisibility"

A label to differentiate from other animations in Android Studio animation preview.

content: @Composable @SubspaceComposable AnimatedSpatialVisibilityScope.() -> Unit

Content to appear or disappear based on the value of visible

AnimatedSpatialVisibility

@Composable
@SubspaceComposable
fun AnimatedSpatialVisibility(
    visibleState: MutableTransitionState<Boolean>,
    modifier: SubspaceModifier = SubspaceModifier,
    enter: SpatialEnterTransition = SpatialTransitionDefaults.DefaultEnter,
    exit: SpatialExitTransition = SpatialTransitionDefaults.DefaultExit,
    label: String = "AnimatedSpatialVisibility",
    content: @Composable @SubspaceComposable AnimatedSpatialVisibilityScope.() -> Unit
): Unit

AnimatedSpatialVisibility composable animates the appearance and disappearance of its content, as visibleState's targetState changes. The visibleState can also be used to observe the state of AnimatedSpatialVisibility. For example: visibleState.isIdle indicates whether all the animations have finished in AnimatedSpatialVisibility, and visibleState.currentState returns the initial state of the current animations.

Parameters
visibleState: MutableTransitionState<Boolean>

defines whether the content should be visible

modifier: SubspaceModifier = SubspaceModifier

modifier for the SubspaceLayout created to contain the content

enter: SpatialEnterTransition = SpatialTransitionDefaults.DefaultEnter

EnterTransition(s) used for the appearing animation

exit: SpatialExitTransition = SpatialTransitionDefaults.DefaultExit

ExitTransition(s) used for the disappearing animation

label: String = "AnimatedSpatialVisibility"

A label to differentiate from other animations in Android Studio animation preview.

content: @Composable @SubspaceComposable AnimatedSpatialVisibilityScope.() -> Unit

Content to appear or disappear based on the value of visibleState

Extension functions

AnimatedSpatialVisibility

@Composable
@SubspaceComposable
fun <T : Any?> Transition<T>.AnimatedSpatialVisibility(
    visible: (T) -> Boolean,
    modifier: SubspaceModifier = SubspaceModifier,
    enter: SpatialEnterTransition = SpatialTransitionDefaults.DefaultEnter,
    exit: SpatialExitTransition = SpatialTransitionDefaults.DefaultExit,
    content: @Composable @SubspaceComposable AnimatedSpatialVisibilityScope.() -> Unit
): Unit

This extension function creates an AnimatedSpatialVisibility composable as a child Transition of the given Transition. This means: 1) the enter/exit transition is now triggered by the provided Transition's targetState change. When the targetState changes, the visibility will be derived using the visible lambda and Transition.targetState. 2) The enter/exit transitions, as well as any custom enter/exit animations defined in AnimatedSpatialVisibility are now hoisted to the parent Transition. The parent Transition will wait for all of them to finish before it considers itself finished (i.e. Transition.currentState = Transition.targetState), and subsequently removes the content in the exit case.

Parameters
visible: (T) -> Boolean

defines whether the content should be visible based on transition state T

modifier: SubspaceModifier = SubspaceModifier

modifier for the SubspaceLayout created to contain the content

enter: SpatialEnterTransition = SpatialTransitionDefaults.DefaultEnter

EnterTransition(s) used for the appearing animation

exit: SpatialExitTransition = SpatialTransitionDefaults.DefaultExit

ExitTransition(s) used for the disappearing animation

content: @Composable @SubspaceComposable AnimatedSpatialVisibilityScope.() -> Unit

Content to appear or disappear based on the visibility derived from the Transition.targetState and the provided visible lambda