SwipeToDismissBoxState

class SwipeToDismissBoxState


State for SwipeToDismissBox.

Summary

Public constructors

SwipeToDismissBoxState(
    animationSpec: AnimationSpec<Float>,
    confirmStateChange: (SwipeToDismissValue) -> Boolean
)

Public functions

suspend Unit

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

Public properties

SwipeToDismissValue

The current value of the state.

Boolean

Whether the state is currently animating.

SwipeToDismissValue

The target value of the state.

Public constructors

SwipeToDismissBoxState

Added in 1.0.0
Deprecated in 1.4.0-alpha04
SwipeToDismissBoxState(
    animationSpec: AnimationSpec<Float> = SwipeToDismissBoxDefaults.AnimationSpec,
    confirmStateChange: (SwipeToDismissValue) -> Boolean = { true }
)
Parameters
animationSpec: AnimationSpec<Float> = SwipeToDismissBoxDefaults.AnimationSpec

The default animation that will be used to animate to a new state.

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

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

Public functions

snapTo

Added in 1.0.0
Deprecated in 1.4.0-alpha04
suspend fun snapTo(targetValue: SwipeToDismissValue): Unit

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

Parameters
targetValue: SwipeToDismissValue

The new target value to set currentValue to.

Public properties

currentValue

Added in 1.0.0
Deprecated in 1.4.0-alpha04
val currentValueSwipeToDismissValue

The current value of the state.

Before and during a swipe, corresponds to SwipeToDismissValue.Default, then switches to SwipeToDismissValue.Dismissed if the swipe has been completed.

isAnimationRunning

Added in 1.0.0
Deprecated in 1.4.0-alpha04
val isAnimationRunningBoolean

Whether the state is currently animating.

targetValue

Added in 1.0.0
Deprecated in 1.4.0-alpha04
val targetValueSwipeToDismissValue

The target value of the state.

If a swipe is in progress, this is the value that the state would animate to if the swipe finished. 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.