SwipeToRevealScope

class SwipeToRevealScope


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

Summary

Public functions

Unit
@Composable
PrimaryActionButton(
    onClick: () -> Unit,
    icon: @Composable () -> Unit,
    text: @Composable () -> Unit,
    modifier: Modifier,
    containerColor: Color,
    contentColor: Color
)

Provides a button for the primary action of a SwipeToReveal.

Unit
@Composable
SecondaryActionButton(
    onClick: () -> Unit,
    icon: @Composable () -> Unit,
    modifier: Modifier,
    containerColor: Color,
    contentColor: Color
)

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

Unit
@Composable
UndoActionButton(
    onClick: () -> Unit,
    text: @Composable () -> Unit,
    modifier: Modifier,
    icon: (@Composable () -> Unit)?,
    containerColor: Color,
    contentColor: Color
)

Provides a button for the undo action of a SwipeToReveal.

Public functions

PrimaryActionButton

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

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. It is recommended to set the button height to SwipeToRevealDefaults.LargeActionButtonHeight for large content items like Cards, using Modifier.height.

Parameters
onClick: () -> Unit

Callback to be executed when the action is performed via a button click.

icon: @Composable () -> Unit

Icon composable to be displayed for this action.

text: @Composable () -> Unit

Text composable to be displayed when the user fully swipes to execute the primary action.

modifier: Modifier = Modifier

Modifier to be applied on the composable.

containerColor: Color = Color.Unspecified

Container color for this action. This can be Color.Unspecified, and in case it is, a default color will be used.

contentColor: Color = Color.Unspecified

Content color for this action. This can be Color.Unspecified, and in case it is, a default color will be used.

SecondaryActionButton

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

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. It is recommended to set the button height to SwipeToRevealDefaults.LargeActionButtonHeight for large content items like Cards, using Modifier.height.

Parameters
onClick: () -> Unit

Callback to be executed when the action is performed via a button click.

icon: @Composable () -> Unit

Icon composable to be displayed for this action.

modifier: Modifier = Modifier

Modifier to be applied on the composable.

containerColor: Color = Color.Unspecified

Container color for this action.This can be Color.Unspecified, and in case it is, a default color will be used.

contentColor: Color = Color.Unspecified

Content color for this action. This can be Color.Unspecified, and in case it is, a default color will be used.

UndoActionButton

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

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
onClick: () -> Unit

Callback to be executed when the action is performed via a button click.

text: @Composable () -> Unit

Text composable to indicate what the undo action is, to be displayed when the user executes the primary action.

modifier: Modifier = Modifier

Modifier to be applied on the composable.

icon: (@Composable () -> Unit)? = null

Optional Icon composable to be displayed for this action.

containerColor: Color = Color.Unspecified

Container color for this action. This can be Color.Unspecified, and in case it is, a default color will be used.

contentColor: Color = Color.Unspecified

Content color for this action. This can be Color.Unspecified, and in case it is, a default color will be used.