ModalBottomSheetState


State of the ModalBottomSheetLayout composable.

Summary

Public companion functions

Saver<ModalBottomSheetState, *>
Saver(
    animationSpec: AnimationSpec<Float>,
    confirmValueChange: (ModalBottomSheetValue) -> Boolean,
    skipHalfExpanded: Boolean,
    density: Density
)

The default Saver implementation for ModalBottomSheetState.

Cmn

Public constructors

ModalBottomSheetState(
    initialValue: ModalBottomSheetValue,
    density: Density,
    confirmValueChange: (ModalBottomSheetValue) -> Boolean,
    animationSpec: AnimationSpec<Float>,
    isSkipHalfExpanded: Boolean
)
Cmn

Public functions

suspend Unit

Hide the bottom sheet with animation and suspend until it if fully hidden 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
suspend Unit

Show the bottom sheet with animation and suspend until it's shown.

Cmn

Public properties

ModalBottomSheetValue

The current value of the ModalBottomSheetState.

Cmn
Boolean

Whether the bottom sheet is visible.

Cmn
Float

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

Cmn
ModalBottomSheetValue

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(
    animationSpec: AnimationSpec<Float>,
    confirmValueChange: (ModalBottomSheetValue) -> Boolean,
    skipHalfExpanded: Boolean,
    density: Density
): Saver<ModalBottomSheetState, *>

The default Saver implementation for ModalBottomSheetState. Saves the currentValue and recreates a ModalBottomSheetState with the saved value as initial value.

Public constructors

ModalBottomSheetState

ModalBottomSheetState(
    initialValue: ModalBottomSheetValue,
    density: Density,
    confirmValueChange: (ModalBottomSheetValue) -> Boolean = { true },
    animationSpec: AnimationSpec<Float> = ModalBottomSheetDefaults.AnimationSpec,
    isSkipHalfExpanded: Boolean = false
)
Parameters
initialValue: ModalBottomSheetValue

The initial value of the state. Must not be set to ModalBottomSheetValue.HalfExpanded if isSkipHalfExpanded is set to true.

density: Density

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

confirmValueChange: (ModalBottomSheetValue) -> Boolean = { true }

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

animationSpec: AnimationSpec<Float> = ModalBottomSheetDefaults.AnimationSpec

The default animation that will be used to animate to a new state.

isSkipHalfExpanded: Boolean = false

Whether the half expanded state, if the sheet is tall enough, should be skipped. If true, the sheet will always expand to the Expanded state and move to the Hidden state when hiding the sheet, either programmatically or by user interaction. Must not be set to true if the initialValue is ModalBottomSheetValue.HalfExpanded. If supplied with ModalBottomSheetValue.HalfExpanded for the initialValue, an IllegalArgumentException will be thrown.

Public functions

hide

suspend fun hide(): Unit

Hide the bottom sheet with animation and suspend until it if fully hidden or animation has been cancelled.

progress

fun progress(from: ModalBottomSheetValue, to: ModalBottomSheetValue): @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: ModalBottomSheetValue

The starting value used to calculate the distance

to: ModalBottomSheetValue

The end value used to calculate the distance

show

suspend fun show(): Unit

Show the bottom sheet with animation and suspend until it's shown. If the sheet is taller than 50% of the parent's height, the bottom sheet will be half expanded. Otherwise it will be fully expanded.

Public properties

currentValue

val currentValueModalBottomSheetValue

The current value of the ModalBottomSheetState.

isVisible

val isVisibleBoolean

Whether the bottom sheet is visible.

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 targetValueModalBottomSheetValue

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