🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

BottomSheetState

State of the persistent bottom sheet in BottomSheetScaffold.

Source set: Common
public class BottomSheetState(
    initialValue: BottomSheetValue,
    density: Density,
    animationSpec: AnimationSpec<Float> = BottomSheetScaffoldDefaults.AnimationSpec,
    confirmValueChange: (BottomSheetValue) -> Boolean = { true },
)

State of the persistent bottom sheet in BottomSheetScaffold.

Parameters

initialValue The initial value of the state.
density The density that this state can use to convert values to and from dp.
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.

Properties

currentValue

Source set: Common
public val currentValue: BottomSheetValue

The current value of the BottomSheetState.

targetValue

Source set: Common
public val targetValue: BottomSheetValue

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

isExpanded

Source set: Common
public val isExpanded: Boolean

Whether the bottom sheet is expanded.

isCollapsed

Source set: Common
public val isCollapsed: Boolean

Whether the bottom sheet is collapsed.

progress

Source set: Common
@Deprecated(
        message = "Please use the progress function to query progress explicitly between targets.",
        replaceWith = ReplaceWith("progress(from = , to = )"),
    )
    public val progress: Float

The fraction of the progress, within 0f..1f bounds, or 1f if the AnchoredDraggableState is in a settled state.

Functions

progress

Source set: Common
public fun progress(from: BottomSheetValue, to: BottomSheetValue): 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

expand

Source set: Common
public suspend fun expand()

Expand the bottom sheet with an animation and suspend until the animation finishes or is cancelled. Note: If the peek height is equal to the sheet height, this method will animate to the Collapsed state.

This method will throw CancellationException if the animation is interrupted.

collapse

Source set: Common
public suspend fun collapse(): Unit

Collapse the bottom sheet with animation and suspend until it if fully collapsed or animation has been cancelled. This method will throw CancellationException if the animation is interrupted.

requireOffset

Source set: Common
public fun requireOffset(): Float

Require the current offset.

Throws: IllegalStateException

If the offset has not been initialized yet

Members

Companion

Source set: Common
public companion object

Functions

Saver

Source set: Common
public fun Saver(
            animationSpec: AnimationSpec<Float>,
            confirmStateChange: (BottomSheetValue) -> Boolean,
            density: Density,
        ): Saver<BottomSheetState, *>

The default Saver implementation for BottomSheetState.