DrawerState
-
Cmn
class DrawerState
State of the ModalNavigationDrawer and DismissibleNavigationDrawer composable.
Summary
Public companion functions |
||
|---|---|---|
Saver<DrawerState, DrawerValue> |
Saver(confirmStateChange: (DrawerValue) -> Boolean)The default |
Cmn
|
Public constructors |
|
|---|---|
DrawerState( |
Cmn
|
Public functions |
||
|---|---|---|
suspend Unit |
This function is deprecated. This method has been replaced by the open and close methods. |
Cmn
|
suspend Unit |
close()Close the drawer with animation and suspend until it if fully closed 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
|
suspend Unit |
snapTo(targetValue: DrawerValue)Set the state without any animation and suspend until it's set |
Cmn
|
Public properties |
||
|---|---|---|
Float |
The current position (in pixels) of the drawer sheet, or Float.NaN before the offset is initialized. |
Cmn
|
DrawerValue |
The current value of the state. |
Cmn
|
Boolean |
Whether the state is currently animating. |
Cmn
|
Boolean |
Whether the drawer is closed. |
Cmn
|
Boolean |
Whether the drawer is open. |
Cmn
|
State<Float> |
This property is deprecated. Please access the offset through currentOffset, which returns the value directly instead of wrapping it in a state object. |
Cmn
|
DrawerValue |
The target value of the drawer state. |
Cmn
|
Public companion functions
Saver
fun Saver(confirmStateChange: (DrawerValue) -> Boolean): Saver<DrawerState, DrawerValue>
The default Saver implementation for DrawerState.
Public constructors
DrawerState
DrawerState(
initialValue: DrawerValue,
confirmStateChange: (DrawerValue) -> Boolean = { true }
)
| Parameters | |
|---|---|
initialValue: DrawerValue |
The initial value of the state. |
confirmStateChange: (DrawerValue) -> Boolean = { true } |
Optional callback invoked to confirm or veto a pending state change. |
Public functions
animateTo
suspend funanimateTo(targetValue: DrawerValue, anim: AnimationSpec<Float>): Unit
Set the state of the drawer with specific animation
| Parameters | |
|---|---|
targetValue: DrawerValue |
The new value to animate to. |
anim: AnimationSpec<Float> |
The animation that will be used to animate to the new value. |
close
suspend fun close(): Unit
Close the drawer with animation and suspend until it if fully closed or animation has been cancelled. This method will throw CancellationException if the animation is interrupted
| Returns | |
|---|---|
Unit |
the reason the close animation ended |
open
suspend fun open(): Unit
Open the drawer with animation and suspend until it if fully opened or animation has been cancelled. This method will throw CancellationException if the animation is interrupted
| Returns | |
|---|---|
Unit |
the reason the open animation ended |
snapTo
suspend fun snapTo(targetValue: DrawerValue): Unit
Set the state without any animation and suspend until it's set
| Parameters | |
|---|---|
targetValue: DrawerValue |
The new target value |
Public properties
currentOffset
val currentOffset: Float
The current position (in pixels) of the drawer sheet, or Float.NaN before the offset is initialized.
| See also | |
|---|---|
offset |
for more information. |
currentValue
val currentValue: DrawerValue
The current value of the state.
If no swipe or animation is in progress, this corresponds to the start the drawer currently in. If a swipe or an animation is in progress, this corresponds the state drawer was in before the swipe or animation started.
offset
val offset: State<Float>
The current position (in pixels) of the drawer sheet, or Float.NaN before the offset is initialized.
| See also | |
|---|---|
offset |
for more information. |
targetValue
val targetValue: DrawerValue
The target value of the drawer state.
If a swipe is in progress, this is the value that the Drawer would animate to if the swipe finishes. If an animation is running, this is the target value of that animation. Finally, if no swipe or animation is in progress, this is the same as the currentValue.