abrir cuadro de diálogo cuando haga clic con el botón jetpack componer
@Composable
fun Alert(name: String,
showDialog: Boolean,
onDismiss: () -> Unit) {
if (showDialog) {
AlertDialog(
title = {
Text("Title")
},
text = {
Text(text = name)
},
onDismissRequest = onDismiss,
confirmButton = {
TextButton(onClick = onDismiss ) {
Text("OK")
}
},
dismissButton = {}
)
}
}
and call it with:
val showDialog = remember { mutableStateOf(false) }
Card() {
if (showDialog.value) {
Alert(name = "Name",
showDialog = showDialog.value,
onDismiss = {showDialog.value = false})
}
Column(Modifier.clickable(
onClick = {showDialog.value = true})
) {}
}