SwipeToRevealScope

Class

Android
public class SwipeToRevealScope
internal constructor(
    internal val revealState: RevealState,
    internal val hasSecondaryAction: Boolean,
    internal val hasPrimaryUndo: Boolean,
    internal val hasSecondaryUndo: Boolean,
    internal val coroutineScope: CoroutineScope,
)

Scope for the actions of a SwipeToReveal composable. Used to define the primary, secondary, undo primary and undo secondary actions.

Functions

@Composable
    public fun PrimaryActionButton(
        onClick: () -> Unit,
        icon: @Composable () -> Unit,
        text: @Composable () -> Unit,
        modifier: Modifier = Modifier,
        containerColor: Color = Color.Unspecified,
        contentColor: Color = Color.Unspecified,
    )

Provides a button for the primary action of a SwipeToReveal.

When first revealed the primary action displays an icon and then, if fully swiped, it additionally shows text. By default the button height is ButtonDefaults.Height - it is recommended to set the button height to SwipeToRevealDefaults.LargeActionButtonHeight for large content items like Cards, using Modifier.height.

Parameters

onClickCallback to be executed when the action is performed via a button click.
iconIcon composable to be displayed for this action.
textText composable to be displayed when the user fully swipes to execute the primary action.
modifierModifier to be applied on the composable.
containerColorContainer color for this action. This can be Color.Unspecified, and in case it is, a default color will be used.
contentColorContent color for this action. This can be Color.Unspecified, and in case it is, a default color will be used.
@Composable
    public fun SecondaryActionButton(
        onClick: () -> Unit,
        icon: @Composable () -> Unit,
        modifier: Modifier = Modifier,
        containerColor: Color = Color.Unspecified,
        contentColor: Color = Color.Unspecified,
    )

Provides a button for the optional secondary action of a SwipeToReveal.

Secondary action only displays an icon, because, unlike the primary action, it is never extended to full width so does not have room to display text. By default, the button height is ButtonDefaults.Height - it is recommended to set the button height to SwipeToRevealDefaults.LargeActionButtonHeight for large content items like Cards, using Modifier.height.

Parameters

onClickCallback to be executed when the action is performed via a button click.
iconIcon composable to be displayed for this action.
modifierModifier to be applied on the composable.
containerColorContainer color for this action.This can be Color.Unspecified, and in case it is, a default color will be used.
contentColorContent color for this action. This can be Color.Unspecified, and in case it is, a default color will be used.
@Composable
    public fun UndoActionButton(
        onClick: () -> Unit,
        text: @Composable () -> Unit,
        modifier: Modifier = Modifier,
        icon: @Composable (() -> Unit)? = null,
        containerColor: Color = Color.Unspecified,
        contentColor: Color = Color.Unspecified,
    )

Provides a button for the undo action of a SwipeToReveal. When the user performs either the primary or secondary action, and the corresponding undo action is provided, the initial action will be hidden once SwipeToReveal has animated to the fully revealed state, and the undo action button will be displayed.

It is recommended to always use the default undo button height, ButtonDefaults.Height.

Parameters

onClickCallback to be executed when the action is performed via a button click.
textText composable to indicate what the undo action is, to be displayed when the user executes the primary action.
modifierModifier to be applied on the composable.
iconOptional Icon composable to be displayed for this action.
containerColorContainer color for this action. This can be Color.Unspecified, and in case it is, a default color will be used.
contentColorContent color for this action. This can be Color.Unspecified, and in case it is, a default color will be used.