ModalBottomSheetState
-
Cmn
class ModalBottomSheetState
State of the ModalBottomSheetLayout composable.
Summary
Public companion functions |
||
|---|---|---|
Saver<ModalBottomSheetState, *> |
Saver(The default |
Cmn
|
Public constructors |
|
|---|---|
ModalBottomSheetState( |
Cmn
|
Public functions |
||
|---|---|---|
suspend Unit |
hide()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 |
progress(from: ModalBottomSheetValue, to: ModalBottomSheetValue)The fraction of the offset between |
Cmn
|
suspend Unit |
show()Show the bottom sheet with animation and suspend until it's shown. |
Cmn
|
Public properties |
||
|---|---|---|
ModalBottomSheetValue |
The current value of the |
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 |
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 |
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 |
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 |
Public properties
currentValue
val currentValue: ModalBottomSheetValue
The current value of the ModalBottomSheetState.
progress
@ExperimentalMaterialApi
val progress: Float
The fraction of the progress, within 0f..1f bounds, or 1f if the AnchoredDraggableState is in a settled state.
targetValue
val targetValue: ModalBottomSheetValue
The target value the state will settle at once the current interaction ends, or the currentValue if there is no interaction in progress.