← Back to Wear Material
Confirmation
Component
in
Wear Material
. Since 1.0.0Overview
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
Name | Description |
---|---|
onTimeout | Event invoked when the dialog has been shown for durationMillis. |
modifier | Modifier to be applied to the dialog. |
icon | An optional slot for displaying an icon or image. |
scrollState | The scroll state for the dialog so that the scroll position can be displayed e.g. by the PositionIndicator passed to Scaffold. |
durationMillis | The number of milliseconds for which the dialog is displayed, must be positive. Suggested values are DialogDefaults.ShortDurationMillis, DialogDefaults.LongDurationMillis or DialogDefaults.IndefiniteDurationMillis. |
backgroundColor | Color representing the background color for this dialog. |
contentColor | Color representing the color for content. |
iconColor | Icon Color that defaults to the contentColor, unless specifically overridden. |
verticalArrangement | The 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. |
contentPadding | The padding to apply around the whole of the dialog's contents. |
content | A 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
Name | Description |
---|---|
onTimeout | Event invoked when the dialog has been shown for durationMillis. |
modifier | Modifier to be applied to the dialog. |
icon | An optional slot for displaying an icon or image. |
scrollState | The scroll state for the dialog so that the scroll position can be displayed e.g. by the PositionIndicator passed to Scaffold. |
durationMillis | The number of milliseconds for which the dialog is displayed, must be positive. Suggested values are DialogDefaults.ShortDurationMillis, DialogDefaults.LongDurationMillis or DialogDefaults.IndefiniteDurationMillis. |
backgroundColor | Color representing the background color for this dialog. |
contentColor | Color representing the color for content. |
iconColor | Icon Color that defaults to the contentColor, unless specifically overridden. |
verticalArrangement | The 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. |
contentPadding | The padding to apply around the whole of the dialog's contents. |
content | A slot for the dialog title, expected to be one line of text |