DrawerState

@Stable
class DrawerState(initialValue: DrawerValue, confirmStateChange: (DrawerValue) -> Boolean = { true })

State of the ModalNavigationDrawer and DismissibleNavigationDrawer composable.

Parameters

initialValue

The initial value of the state.

confirmStateChange

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

Constructors

Link copied to clipboard
constructor(initialValue: DrawerValue, confirmStateChange: (DrawerValue) -> Boolean = { true })

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The current position (in pixels) of the drawer sheet, or Float.NaN before the offset is initialized.

Link copied to clipboard

The current value of the state.

Link copied to clipboard

Whether the state is currently animating.

Link copied to clipboard

Whether the drawer is closed.

Link copied to clipboard

Whether the drawer is open.

Link copied to clipboard
val offset: State<Float>

The current position (in pixels) of the drawer sheet, or Float.NaN before the offset is initialized.

Link copied to clipboard

The target value of the drawer state.

Functions

Link copied to clipboard
suspend fun animateTo(targetValue: DrawerValue, anim: AnimationSpec<Float>)

Set the state of the drawer with specific animation

Link copied to clipboard
suspend fun close()

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

Link copied to clipboard
suspend fun open()

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

Link copied to clipboard
suspend fun snapTo(targetValue: DrawerValue)

Set the state without any animation and suspend until it's set