ConfirmationDialogSample
@Composable
fun ConfirmationDialogSample() {
var showConfirmation by remember { mutableStateOf(false) }
Box(Modifier.fillMaxSize()) {
FilledTonalButton(
modifier = Modifier.align(Alignment.Center),
onClick = { showConfirmation = true },
label = { Text("Show Confirmation") },
)
}
// Has an icon and a short curved text content, which will be displayed along the bottom edge of
// the screen.
val curvedTextStyle = ConfirmationDialogDefaults.curvedTextStyle
ConfirmationDialog(
visible = showConfirmation,
onDismissRequest = { showConfirmation = false },
curvedText = { confirmationDialogCurvedText("Confirmed", curvedTextStyle) },
) {
FavoriteIcon(ConfirmationDialogDefaults.IconSize)
}
}
LongTextConfirmationDialogSample
@Composable
fun LongTextConfirmationDialogSample() {
var showConfirmation by remember { mutableStateOf(false) }
Box(Modifier.fillMaxSize()) {
FilledTonalButton(
modifier = Modifier.align(Alignment.Center),
onClick = { showConfirmation = true },
label = { Text("Show Confirmation") },
)
}
// Has an icon and a text content. Text will be displayed in the center of the screen below the
// icon.
ConfirmationDialog(
visible = showConfirmation,
onDismissRequest = { showConfirmation = false },
text = { Text(text = "Your message has been sent") },
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.Send,
contentDescription = null,
modifier = Modifier.size(ConfirmationDialogDefaults.SmallIconSize),
)
}
}