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

BottomDrawerState

State of the BottomDrawer composable.

Source set: Common
public class BottomDrawerState(
    initialValue: BottomDrawerValue,
    density: Density,
    confirmStateChange: (BottomDrawerValue) -> Boolean = { true },
    animationSpec: AnimationSpec<Float> = DrawerDefaults.AnimationSpec,
)

State of the BottomDrawer composable.

Parameters

initialValue The initial value of the state.
density The density that this state can use to convert values to and from dp.
confirmStateChange Optional callback invoked to confirm or veto a pending state change.
animationSpec The animation spec to be used for open/close animations, as well as settling when a user lets go.

Properties

targetValue

Source set: Common
public val targetValue: BottomDrawerValue

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

offset

Source set: Common
public val offset: Float

The current offset in pixels, or Float.NaN if it has not been initialized yet.

currentValue

Source set: Common
public val currentValue: BottomDrawerValue

The current value of the BottomDrawerState.

isOpen

Source set: Common
public val isOpen: Boolean

Whether the drawer is open, either in opened or expanded state.

isClosed

Source set: Common
public val isClosed: Boolean

Whether the drawer is closed.

isExpanded

Source set: Common
public val isExpanded: Boolean

Whether the drawer is expanded.

progress

Source set: Common
@Deprecated(
        message = "Please use the progress function to query progress explicitly between targets.",
        replaceWith = ReplaceWith("progress(from = , to = )"),
    ) // TODO: Remove in the future b/323882175
    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: BottomDrawerValue, to: BottomDrawerValue): 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

open

Source set: Common
public suspend fun open()

Open the drawer with animation and suspend until it if fully opened or animation has been cancelled. If the content height is less than BottomDrawerOpenFraction, the drawer state will move to BottomDrawerValue.Expanded instead.

Throws: CancellationException

if the animation is interrupted

close

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

Close the drawer with animation and suspend until it if fully closed or animation has been cancelled.

Throws: CancellationException

if the animation is interrupted

expand

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

Expand the drawer with animation and suspend until it if fully expanded or animation has been cancelled.

Throws: CancellationException

if the animation is interrupted

Members

Companion

Source set: Common
public companion object

Functions

Saver

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

The default Saver implementation for BottomDrawerState.