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
name | description |
---|---|
show | A boolean indicating whether the confirmation should be displayed. |
onDismissRequest | A lambda function to be called when the dialog is dismissed - either by swiping right or when the [durationMillis] has passed. |
modifier | Modifier to be applied to the confirmation content. |
curvedText | A slot for displaying curved text content which will be shown along the bottom edge of the dialog. Defaults to a localized failure message. |
colors | A [ConfirmationColors] object for customizing the colors used in this [FailureConfirmation]. |
properties | An optional [DialogProperties] object for configuring the dialog's behavior. |
durationMillis | The duration in milliseconds for which the dialog is displayed. Defaults to [ConfirmationDefaults.ConfirmationDurationMillis]. |
content | A 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 })
}