Build apps faster with our new App builder! Check it out →

FailureConfirmation

Android

Component in Wear Material 3 Compose

Shows a [Confirmation] dialog with a failure icon and an optional short curved text. This confirmation indicates an unsuccessful operation or action.

The confirmation will show a message to the user for [durationMillis]. After a specified timeout, the [onDismissRequest] callback will be invoked, where it's up to the caller to handle the dismissal. To hide the confirmation, [show] parameter should be set to false.

Last updated:

Installation

dependencies {
   implementation("androidx.wear.compose:compose-material3:1.0.0-alpha27")
}

Overloads

@Composable
fun FailureConfirmation(
    show: Boolean,
    onDismissRequest: () -> Unit,
    modifier: Modifier = Modifier,
    curvedText: (CurvedScope.() -> Unit)? = ConfirmationDefaults.failureText(),
    colors: ConfirmationColors = ConfirmationDefaults.failureColors(),
    properties: DialogProperties = DialogProperties(),
    durationMillis: Long = ConfirmationDefaults.ConfirmationDurationMillis,
    content: @Composable BoxScope.() -> Unit = ConfirmationDefaults.FailureIcon,
)

Parameters

namedescription
showA boolean indicating whether the confirmation should be displayed.
onDismissRequestA lambda function to be called when the dialog is dismissed - either by swiping right or when the [durationMillis] has passed.
modifierModifier to be applied to the confirmation content.
curvedTextA slot for displaying curved text content which will be shown along the bottom edge of the dialog. Defaults to a localized failure message.
colorsA [ConfirmationColors] object for customizing the colors used in this [FailureConfirmation].
propertiesAn optional [DialogProperties] object for configuring the dialog's behavior.
durationMillisThe duration in milliseconds for which the dialog is displayed. Defaults to [ConfirmationDefaults.ConfirmationDurationMillis].
contentA slot for displaying an icon inside the confirmation dialog, which can be animated. Defaults to [ConfirmationDefaults.FailureIcon].

Code Example

FailureConfirmationSample

@Composable
fun FailureConfirmationSample() {
    var showConfirmation by remember { mutableStateOf(false) }

    Box(Modifier.fillMaxSize()) {
        FilledTonalButton(
            modifier = Modifier.align(Alignment.Center),
            onClick = { showConfirmation = true },
            label = { Text("Show Confirmation") }
        )
    }

    FailureConfirmation(show = showConfirmation, onDismissRequest = { showConfirmation = false })
}
by @alexstyl