DismissState
-
Cmn
@ExperimentalMaterialApi
class DismissState : SwipeableState
State of the SwipeToDismiss composable.
Summary
Public companion functions |
||
|---|---|---|
Saver<DismissState, DismissValue> |
Saver(confirmStateChange: (DismissValue) -> Boolean)The default |
Cmn
|
Public constructors |
|
|---|---|
DismissState( |
Cmn
|
Public functions |
||
|---|---|---|
suspend Unit |
dismiss(direction: DismissDirection)Dismiss the component in the given |
Cmn
|
Boolean |
isDismissed(direction: DismissDirection)Whether the component has been dismissed in the given |
Cmn
|
suspend Unit |
reset()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 |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited properties |
|||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public companion functions
Saver
fun Saver(confirmStateChange: (DismissValue) -> Boolean): Saver<DismissState, DismissValue>
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 dismissDirection: DismissDirection?
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.