BackdropScaffoldState

Class
Common
class BackdropScaffoldState
@Deprecated(
    "This constructor is deprecated. Density must be provided by the component. " +
        "Please use the constructor that provides a [Density].",
    ReplaceWith(
        """
            BackdropScaffoldState(
                initialValue = initialValue,
                density = LocalDensity.current,
                animationSpec = animationSpec,
                confirmValueChange = confirmValueChange
            )
            """
    ),
)
constructor(
    initialValue: BackdropValue,
    animationSpec: AnimationSpec<Float> = BackdropScaffoldDefaults.AnimationSpec,
    val confirmValueChange: (BackdropValue) -> Boolean = { true },
    val snackbarHostState: SnackbarHostState = SnackbarHostState(),
)

State of the BackdropScaffold composable.

Parameters

initialValue The initial value of the state.
animationSpec The default animation that will be used to animate to a new state.
confirmValueChange Optional callback invoked to confirm or veto a pending state change.
snackbarHostState The SnackbarHostState used to show snackbars inside the scaffold.

Properties

Common
val currentValue: BackdropValue

The current value of the BottomSheetState.

Common
val targetValue: BackdropValue

The target value the state will settle at once the current interaction ends, or the currentValue if there is no interaction in progress.

Common
val isRevealed: Boolean

Whether the back layer is revealed.

Common
val isConcealed: Boolean

Whether the back layer is concealed.

Functions

fun requireOffset() = anchoredDraggableState.requireOffset()

Require the current offset.

suspend fun reveal() = anchoredDraggableState.animateTo(targetValue = Revealed)

Reveal the back layer with animation and suspend until it if fully revealed or animation has been cancelled. This method will throw CancellationException if the animation is interrupted

suspend fun conceal() = anchoredDraggableState.animateTo(targetValue = Concealed)

Conceal the back layer with animation and suspend until it if fully concealed or animation has been cancelled. This method will throw CancellationException if the animation is interrupted

@FloatRange(from = 0.0, to = 1.0)
    fun progress(from: BackdropValue, to: BackdropValue): Float

The fraction of the offset between from and to, as a fraction between 0f..1f, or 1f if from is equal to to.

Parameters

from The starting value used to calculate the distance
to The end value used to calculate the distance

Companion Object

Methods

Common
fun Saver(
            animationSpec: AnimationSpec<Float>,
            confirmStateChange: (BackdropValue) -> Boolean,
            snackbarHostState: SnackbarHostState,
            density: Density,
        ): Saver<BackdropScaffoldState, *>

The default Saver implementation for BackdropScaffoldState.