State of Compose 2023 results are in! Click here to learn more

← Back to Wear Material

Confirmation

Component
in
Wear Material
. Since 1.0.0

Overview

Code Examples

Confirmation lays out the content for an opinionated confirmation screen that displays a message to the user for durationMillis. It has a slot for an icon or image (which could be animated).

Confirmation can be used as a destination in a navigation graph e.g. using SwipeDismissableNavHost. However, for a conventional fullscreen dialog, displayed on top of other content, use Dialog.

Example of a Confirmation with animation:

Overloads

Confirmation

@Composable
public fun Confirmation(
    onTimeout: () -> Unit,
    modifier: Modifier = Modifier,
    icon: @Composable (ColumnScope.() -> Unit)? = null,
    scrollState: ScalingLazyListState = rememberScalingLazyListState(),
    durationMillis: Long = DialogDefaults.ShortDurationMillis,
    backgroundColor: Color = MaterialTheme.colors.background,
    contentColor: Color = contentColorFor(backgroundColor),
    iconColor: Color = contentColor,
    verticalArrangement: Arrangement.Vertical = DialogDefaults.ConfirmationVerticalArrangement,
    contentPadding: PaddingValues = DialogDefaults.ContentPadding,
    content: @Composable ColumnScope.() -> Unit
)

Parameters

NameDescription
onTimeoutEvent invoked when the dialog has been shown for durationMillis.
modifierModifier to be applied to the dialog.
iconAn optional slot for displaying an icon or image.
scrollStateThe scroll state for the dialog so that the scroll position can be displayed e.g. by the PositionIndicator passed to Scaffold.
durationMillisThe number of milliseconds for which the dialog is displayed, must be positive. Suggested values are DialogDefaults.ShortDurationMillis, DialogDefaults.LongDurationMillis or DialogDefaults.IndefiniteDurationMillis.
backgroundColorColor representing the background color for this dialog.
contentColorColor representing the color for content.
iconColorIcon Color that defaults to the contentColor, unless specifically overridden.
verticalArrangementThe vertical arrangement of the dialog's children. This allows us to add spacing between items and specify the arrangement of the items when we have not enough of them to fill the whole minimum size.
contentPaddingThe padding to apply around the whole of the dialog's contents.
contentA slot for the dialog title, expected to be one line of text

Confirmation

@Suppress("DEPRECATION")
@Deprecated(
        "This overload is provided for backwards compatibility with Compose for Wear OS 1.1." +
        "A newer overload is available which uses ScalingLazyListState from " +
        "wear.compose.foundation.lazy package", level = DeprecationLevel.HIDDEN
)
@Composable
public fun Confirmation(
    onTimeout: () -> Unit,
    modifier: Modifier = Modifier,
    icon: @Composable (ColumnScope.() -> Unit)? = null,
    scrollState: androidx.wear.compose.material.ScalingLazyListState =
        androidx.wear.compose.material.rememberScalingLazyListState(),
    durationMillis: Long = DialogDefaults.ShortDurationMillis,
    backgroundColor: Color = MaterialTheme.colors.background,
    contentColor: Color = contentColorFor(backgroundColor),
    iconColor: Color = contentColor,
    verticalArrangement: Arrangement.Vertical = DialogDefaults.ConfirmationVerticalArrangement,
    contentPadding: PaddingValues = DialogDefaults.ContentPadding,
    content: @Composable ColumnScope.() -> Unit
)

Parameters

NameDescription
onTimeoutEvent invoked when the dialog has been shown for durationMillis.
modifierModifier to be applied to the dialog.
iconAn optional slot for displaying an icon or image.
scrollStateThe scroll state for the dialog so that the scroll position can be displayed e.g. by the PositionIndicator passed to Scaffold.
durationMillisThe number of milliseconds for which the dialog is displayed, must be positive. Suggested values are DialogDefaults.ShortDurationMillis, DialogDefaults.LongDurationMillis or DialogDefaults.IndefiniteDurationMillis.
backgroundColorColor representing the background color for this dialog.
contentColorColor representing the color for content.
iconColorIcon Color that defaults to the contentColor, unless specifically overridden.
verticalArrangementThe vertical arrangement of the dialog's children. This allows us to add spacing between items and specify the arrangement of the items when we have not enough of them to fill the whole minimum size.
contentPaddingThe padding to apply around the whole of the dialog's contents.
contentA slot for the dialog title, expected to be one line of text