🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

SwipeToDismissBoxState

State of the SwipeToDismissBox composable.

Source set: Common
public class SwipeToDismissBoxState

State of the SwipeToDismissBox composable.

Properties

currentValue

Source set: Common
public val currentValue: SwipeToDismissBoxValue

The current state value of the SwipeToDismissBoxState.

targetValue

Source set: Common
public val targetValue: SwipeToDismissBoxValue

The target state. This is the closest state to the current offset (taking into account positional thresholds). If no interactions like animations or drags are in progress, this will be the current state.

settledValue

Source set: Common
public val settledValue: SwipeToDismissBoxValue

The value the SwipeToDismissBoxState is currently settled at. When progressing through multiple anchors, e.g. A -> B -> C, settledValue will stay the same until settled at an anchor, while currentValue will update to the closest anchor.

progress

Source set: Common
public val progress: Float

The fraction of the progress going from currentValue to targetValue, within 0f..1f bounds.

dismissDirection

Source set: Common
public val dismissDirection: SwipeToDismissBoxValue

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

Use this to change the background of the SwipeToDismissBox if you want different actions on each side.

Functions

requireOffset

Source set: Common
public fun requireOffset(): Float

Require the current offset.

Throws: IllegalStateException

If the offset has not been initialized yet

snapTo

Source set: Common
public suspend fun snapTo(targetValue: SwipeToDismissBoxValue)

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

Parameters

targetValue The new target value

reset

Source set: Common
public 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

Return

the reason the reset animation ended

dismiss

Source set: Common
public suspend fun dismiss(direction: SwipeToDismissBoxValue)

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

Parameters

direction The dismiss direction.

Members

Companion

Source set: Common
public companion object

Functions

Saver

Source set: Common
@Deprecated(
            message = ConfirmValueChangeDeprecated,
            level = DeprecationLevel.WARNING,
            replaceWith = ReplaceWith("Saver(positionalThreshold, density)"),
        )
        public fun Saver(
            confirmValueChange: (SwipeToDismissBoxValue) -> Boolean,
            positionalThreshold: (totalDistance: Float) -> Float,
            density: Density,
        ): Saver<SwipeToDismissBoxState, SwipeToDismissBoxValue>

Saver implementation for SwipeToDismissBoxState.

Saver

Source set: Common
public fun Saver(
            positionalThreshold: (totalDistance: Float) -> Float
        ): Saver<SwipeToDismissBoxState, SwipeToDismissBoxValue>

The default Saver implementation for SwipeToDismissBoxState.

Content updated: