JengaDialog

fun JengaDialog(onDismissRequest: () -> Unit, confirmButton: @Composable () -> Unit, modifier: Modifier = Modifier, title: String? = null, text: String? = null, dismissButton: @Composable () -> Unit? = null, shape: Shape = JengaDialogDefaults.shape, contentPadding: PaddingValues = JengaDialogDefaults.contentPadding, titleStyle: TextStyle = JengaDialogDefaults.titleStyle, textStyle: TextStyle = JengaDialogDefaults.textStyle, actionSpacing: Dp = JengaDialogDefaults.actionSpacing, colors: JengaDialogColors = JengaDialogDefaults.colors(), border: BorderStroke? = JengaDialogDefaults.border)(source)

A modal dialog with an optional title and body, plus confirm/dismiss actions. For a destructive confirmation, pass a danger JengaButton as confirmButton.

Parameters

onDismissRequest

called when the user dismisses (scrim tap or back).

confirmButton

the primary action (e.g. a JengaButton).

modifier

the Modifier for the dialog surface.

title

optional title.

text

optional body text.

dismissButton

optional secondary action.

shape

the dialog shape.

contentPadding

padding inside the dialog.

titleStyle

the title text style.

textStyle

the text text style.

actionSpacing

gap between the actions.

colors

the color set; defaults to JengaDialogDefaults.colors.

border

outline around the dialog; defaults to JengaDialogDefaults.border (a hairline in dark themes only). Pass null for none.

Samples

var open by remember {
    mutableStateOf(
        value = true,
    )
}
if (open) {
    JengaDialog(
        onDismissRequest = { open = false },
        title = "Reset device?",
        text = "This clears the cached gate session.",
        confirmButton = {
            JengaButton(
                text = "Reset",
                onClick = { open = false },
                variant = JengaButtonVariant.Danger,
            )
        },
        dismissButton = {
            JengaButton(
                text = "Cancel",
                onClick = { open = false },
                variant = JengaButtonVariant.Ghost,
            )
        },
    )
}