-
-
Save KatieBarnett/69f8e04e299aa63d9b29dd363d0bb25a to your computer and use it in GitHub Desktop.
Confirm dialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val coroutineScope = rememberCoroutineScope() | |
var showConfirmChanges by rememberSaveable { mutableStateOf(false) } | |
... | |
if (showConfirmChanges) { | |
AlertDialog( | |
onDismissRequest = { showConfirmChanges = false }, | |
title = { Text(stringResource(R.string.confirm_changes_title)) }, | |
text = { Text(stringResource(R.string.confirm_changes_text)) }, | |
confirmButton = { | |
TextButton(onClick = { | |
// Close the ModalBottomSheet | |
coroutineScope.launch { | |
addSheetState.hide() | |
}.invokeOnCompletion { | |
if (!addSheetState.isVisible) { | |
showAddSheet = false | |
} | |
} | |
// Close the confirm changes AlertDialog | |
showConfirmChanges = false | |
}) { | |
Text(stringResource(R.string.confirm_changes_confirm)) | |
} | |
}, | |
dismissButton = { | |
TextButton(onClick = { | |
showConfirmChanges = false | |
}) { | |
Text(stringResource(R.string.confirm_changes_dismiss)) | |
} | |
}, | |
properties = DialogProperties( | |
dismissOnBackPress = false, | |
dismissOnClickOutside = false | |
) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment