SwipeToRevealDefaults

object SwipeToRevealDefaults


Summary

Public functions

Map<RevealValueFloat>
@Composable
anchors(anchorWidth: Dp, useAnchoredActions: Boolean)

Creates the recommended anchors to support right-to-left swiping to reveal additional action buttons.

Map<RevealValueFloat>
@Composable
bidirectionalAnchors(anchorWidth: Dp, useAnchoredActions: Boolean)

Creates anchors that allow the user to swipe either left-to-right or right-to-left to reveal or execute the actions.

Public properties

Dp

Width that's required to display both actions in a SwipeToReveal composable.

Dp

Standard height for a large revealed action, such as when the swiped item is a Card.

Dp

Width that's required to display a single action in a SwipeToReveal composable.

Dp

Standard height for a small revealed action, such as when the swiped item is a Button.

Public functions

anchors

@Composable
fun anchors(
    anchorWidth: Dp = SingleActionAnchorWidth,
    useAnchoredActions: Boolean = true
): Map<RevealValueFloat>

Creates the recommended anchors to support right-to-left swiping to reveal additional action buttons.

Parameters
anchorWidth: Dp = SingleActionAnchorWidth

Absolute width, in dp, of the screen revealed items should be displayed in. Ignored if useAnchoredActions is set to false, as the items won't be anchored to the screen. For a single action SwipeToReveal component, this should be SwipeToRevealDefaults.SingleActionAnchorWidth, and for a double action SwipeToReveal, SwipeToRevealDefaults.DoubleActionAnchorWidth to be able to display both action buttons.

useAnchoredActions: Boolean = true

Whether the actions should stay revealed, or bounce back to hidden when the user stops swiping. This is relevant for SwipeToReveal components with a single action. If the developer wants a swipe to clear behaviour, this should be set to false.

bidirectionalAnchors

@Composable
fun bidirectionalAnchors(
    anchorWidth: Dp = SingleActionAnchorWidth,
    useAnchoredActions: Boolean = true
): Map<RevealValueFloat>

Creates anchors that allow the user to swipe either left-to-right or right-to-left to reveal or execute the actions. This should not be used if the component is part of an activity, as the gesture might conflict with the swipe-to-dismiss gesture. This is only supported for rare cases where the current screen does not support swipe to dismiss.

Parameters
anchorWidth: Dp = SingleActionAnchorWidth

Absolute width, in dp, of the screen revealed items should be displayed in. Ignored if useAnchoredActions is set to false, as the items won't be anchored to the screen. For a single action SwipeToReveal component, this should be SwipeToRevealDefaults.SingleActionAnchorWidth, and for a double action SwipeToReveal, SwipeToRevealDefaults.DoubleActionAnchorWidth to be able to display both action buttons.

useAnchoredActions: Boolean = true

Whether the actions should stay revealed, or bounce back to hidden when the user stops swiping. This is relevant for SwipeToReveal components with a single action. If the developer wants a swipe to clear behaviour, this should be set to false.

Public properties

DoubleActionAnchorWidth

Added in 1.0.0-alpha34
val DoubleActionAnchorWidthDp

Width that's required to display both actions in a SwipeToReveal composable.

LargeActionButtonHeight

Added in 1.0.0-alpha34
val LargeActionButtonHeightDp

Standard height for a large revealed action, such as when the swiped item is a Card.

SingleActionAnchorWidth

Added in 1.0.0-alpha34
val SingleActionAnchorWidthDp

Width that's required to display a single action in a SwipeToReveal composable.

SmallActionButtonHeight

Added in 1.0.0-alpha34
val SmallActionButtonHeightDp

Standard height for a small revealed action, such as when the swiped item is a Button.