BottomDrawerState
-
Cmn
class BottomDrawerState
State of the BottomDrawer composable.
Summary
Public companion functions |
||
|---|---|---|
Saver<BottomDrawerState, BottomDrawerValue> |
Saver(The default |
Cmn
|
Public constructors |
|
|---|---|
BottomDrawerState( |
Cmn
|
Public functions |
||
|---|---|---|
suspend Unit |
close()Close the drawer with animation and suspend until it if fully closed or animation has been cancelled. |
Cmn
|
suspend Unit |
expand()Expand the drawer with animation and suspend until it if fully expanded or animation has been cancelled. |
Cmn
|
suspend Unit |
open()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 |
progress(from: BottomDrawerValue, to: BottomDrawerValue)The fraction of the offset between |
Cmn
|
Public properties |
||
|---|---|---|
BottomDrawerValue |
The current value of the |
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 in pixels, or |
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 |
Cmn
|
Public companion functions
Saver
fun Saver(
density: Density,
confirmStateChange: (BottomDrawerValue) -> Boolean,
animationSpec: AnimationSpec<Float>
): Saver<BottomDrawerState, BottomDrawerValue>
The default Saver implementation for BottomDrawerState.
Public constructors
BottomDrawerState
BottomDrawerState(
initialValue: BottomDrawerValue,
density: Density,
confirmStateChange: (BottomDrawerValue) -> Boolean = { true },
animationSpec: AnimationSpec<Float> = DrawerDefaults.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> = DrawerDefaults.AnimationSpec |
The animation spec to be used for open/close animations, as well as settling when a user lets go. |
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
offset
val offset: Float
The current offset in pixels, or Float.NaN if it has not been initialized yet.
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: BottomDrawerValue
The target value the state will settle at once the current interaction ends, or the currentValue if there is no interaction in progress.