BottomDrawerState


State of the BottomDrawer composable.

Summary

Public companion functions

Saver<BottomDrawerStateBottomDrawerValue>
Saver(
    density: Density,
    confirmStateChange: (BottomDrawerValue) -> Boolean,
    animationSpec: AnimationSpec<Float>
)

The default Saver implementation for BottomDrawerState.

Cmn

Public constructors

BottomDrawerState(
    initialValue: BottomDrawerValue,
    density: Density,
    confirmStateChange: (BottomDrawerValue) -> Boolean,
    animationSpec: AnimationSpec<Float>
)
Cmn

Public functions

suspend Unit

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

Cmn
suspend Unit

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

Cmn
suspend Unit

Open the drawer with animation and suspend until it if fully opened or animation has been cancelled.

Cmn
@FloatRange(from = 0.0, to = 1.0) Float

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

Cmn

Public properties

BottomDrawerValue

The current value of the BottomDrawerState.

Cmn
Boolean

Whether the drawer is closed.

Cmn
Boolean

Whether the drawer is expanded.

Cmn
Boolean

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

Cmn
Float

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

Cmn
Float

This property is deprecated. Please use the progress function to query progress explicitly between targets.

Cmn
BottomDrawerValue

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

Cmn

Public companion functions

Saver

fun Saver(
    density: Density,
    confirmStateChange: (BottomDrawerValue) -> Boolean,
    animationSpec: AnimationSpec<Float>
): Saver<BottomDrawerStateBottomDrawerValue>

The default Saver implementation for BottomDrawerState.

Public constructors

BottomDrawerState

BottomDrawerState(
    initialValue: BottomDrawerValue,
    density: Density,
    confirmStateChange: (BottomDrawerValue) -> Boolean = { true },
    animationSpec: AnimationSpec<Float> = AnimationSpec
)
Parameters
initialValue: BottomDrawerValue

The initial value of the state.

density: Density

The density that this state can use to convert values to and from dp.

confirmStateChange: (BottomDrawerValue) -> Boolean = { true }

Optional callback invoked to confirm or veto a pending state change.

animationSpec: AnimationSpec<Float> = AnimationSpec

The animation spec to be used for animations.

Public functions

close

suspend fun close(): Unit

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

Throws
kotlinx.coroutines.CancellationException

if the animation is interrupted

expand

suspend fun expand(): Unit

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

Throws
kotlinx.coroutines.CancellationException

if the animation is interrupted

open

suspend fun open(): Unit

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
kotlinx.coroutines.CancellationException

if the animation is interrupted

progress

fun progress(from: BottomDrawerValue, to: BottomDrawerValue): @FloatRange(from = 0.0, to = 1.0) 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: BottomDrawerValue

The starting value used to calculate the distance

to: BottomDrawerValue

The end value used to calculate the distance

Public properties

currentValue

val currentValueBottomDrawerValue

The current value of the BottomDrawerState.

isClosed

val isClosedBoolean

Whether the drawer is closed.

isExpanded

val isExpandedBoolean

Whether the drawer is expanded.

isOpen

val isOpenBoolean

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

offset

val offsetFloat

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

progress

@ExperimentalMaterialApi
val progressFloat

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

targetValue

val targetValueBottomDrawerValue

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