DismissState


State of the SwipeToDismiss composable.

Summary

Public companion functions

Saver<DismissStateDismissValue>
Saver(confirmStateChange: (DismissValue) -> Boolean)

The default Saver implementation for DismissState.

Cmn

Public constructors

DismissState(
    initialValue: DismissValue,
    confirmStateChange: (DismissValue) -> Boolean
)
Cmn

Public functions

suspend Unit

Dismiss the component in the given direction, with an animation and suspend.

Cmn
Boolean

Whether the component has been dismissed in the given direction.

Cmn
suspend Unit

Reset the component to the default position with animation and suspend until it if fully reset or animation has been cancelled.

Cmn

Public properties

DismissDirection?

The direction (if any) in which the composable has been or is being dismissed.

Cmn

Inherited functions

From androidx.compose.material.SwipeableState
suspend Unit

Set the state to the target value by starting an animation.

Cmn
Float

Force swipeable to consume drag delta provided from outside of the regular swipeable gesture flow.

Cmn
suspend Unit
performFling(velocity: Float)

Perform fling with settling to one of the anchors which is determined by the given velocity.

Cmn
suspend Unit

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

Cmn

Inherited properties

From androidx.compose.material.SwipeableState
DismissValue

The current value of the state.

Cmn
Float

The direction in which the swipeable is moving, relative to the current currentValue.

Cmn
Boolean

Whether the state is currently animating.

Cmn
State<Float>

The current position (in pixels) of the swipeable.

Cmn
State<Float>

The amount by which the swipeable has been swiped past its bounds.

Cmn
SwipeProgress<DismissValue>

Information about the ongoing swipe or animation, if any.

Cmn
DismissValue

The target value of the state.

Cmn

Public companion functions

Saver

fun Saver(confirmStateChange: (DismissValue) -> Boolean): Saver<DismissStateDismissValue>

The default Saver implementation for DismissState.

Public constructors

DismissState

DismissState(
    initialValue: DismissValue,
    confirmStateChange: (DismissValue) -> Boolean = { true }
)
Parameters
initialValue: DismissValue

The initial value of the state.

confirmStateChange: (DismissValue) -> Boolean = { true }

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

Public functions

dismiss

suspend fun dismiss(direction: DismissDirection): Unit

Dismiss the component in the given direction, with an animation and suspend. This method will throw CancellationException if the animation is interrupted

Parameters
direction: DismissDirection

The dismiss direction.

isDismissed

fun isDismissed(direction: DismissDirection): Boolean

Whether the component has been dismissed in the given direction.

Parameters
direction: DismissDirection

The dismiss direction.

reset

suspend fun reset(): Unit

Reset the component to the default position with animation and suspend until it if fully reset or animation has been cancelled. This method will throw CancellationException if the animation is interrupted

Returns
Unit

the reason the reset animation ended

Public properties

dismissDirection

val dismissDirectionDismissDirection?

The direction (if any) in which the composable has been or is being dismissed.

If the composable is settled at the default state, then this will be null. Use this to change the background of the SwipeToDismiss if you want different actions on each side.