New confirmation dialog when deleting a page
This commit is contained in:
@@ -75,6 +75,7 @@ fun DocumentScreen(
|
|||||||
) {
|
) {
|
||||||
// TODO Check how often images are loaded
|
// TODO Check how often images are loaded
|
||||||
val showNewDocDialog = rememberSaveable { mutableStateOf(false) }
|
val showNewDocDialog = rememberSaveable { mutableStateOf(false) }
|
||||||
|
val showDeletePageDialog = rememberSaveable { mutableStateOf(false) }
|
||||||
val showPdfDialog = rememberSaveable { mutableStateOf(false) }
|
val showPdfDialog = rememberSaveable { mutableStateOf(false) }
|
||||||
val currentPageIndex = rememberSaveable { mutableIntStateOf(initialPage) }
|
val currentPageIndex = rememberSaveable { mutableIntStateOf(initialPage) }
|
||||||
if (currentPageIndex.intValue >= document.pageCount()) {
|
if (currentPageIndex.intValue >= document.pageCount()) {
|
||||||
@@ -111,10 +112,17 @@ fun DocumentScreen(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
) { modifier ->
|
) { modifier ->
|
||||||
DocumentPreview(document, currentPageIndex, onDeleteImage, modifier)
|
DocumentPreview(document, currentPageIndex, { showDeletePageDialog.value = true }, modifier)
|
||||||
if (showNewDocDialog.value) {
|
if (showNewDocDialog.value) {
|
||||||
NewDocumentDialog(onConfirm = onStartNew, showNewDocDialog, stringResource(R.string.close_document))
|
NewDocumentDialog(onConfirm = onStartNew, showNewDocDialog, stringResource(R.string.close_document))
|
||||||
}
|
}
|
||||||
|
if (showDeletePageDialog.value) {
|
||||||
|
ConfirmationDialog(
|
||||||
|
title = stringResource(R.string.delete_page),
|
||||||
|
message = stringResource(R.string.delete_page_warning),
|
||||||
|
showDialog = showDeletePageDialog
|
||||||
|
) { onDeleteImage(document.pageId(currentPageIndex.intValue)) }
|
||||||
|
}
|
||||||
if (showPdfDialog.value) {
|
if (showPdfDialog.value) {
|
||||||
PdfGenerationBottomSheetWrapper(
|
PdfGenerationBottomSheetWrapper(
|
||||||
onDismiss = { showPdfDialog.value = false },
|
onDismiss = { showPdfDialog.value = false },
|
||||||
@@ -212,11 +220,21 @@ private fun BottomBar(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NewDocumentDialog(onConfirm: () -> Unit, showDialog: MutableState<Boolean>, title: String) {
|
fun NewDocumentDialog(onConfirm: () -> Unit, showDialog: MutableState<Boolean>, title: String) {
|
||||||
|
ConfirmationDialog(title, stringResource(R.string.new_document_warning), showDialog, onConfirm)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun ConfirmationDialog(
|
||||||
|
title: String,
|
||||||
|
message: String,
|
||||||
|
showDialog: MutableState<Boolean>,
|
||||||
|
onConfirm: () -> Unit,
|
||||||
|
) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
title = { Text(title) },
|
title = { Text(title) },
|
||||||
text = { Text(stringResource(R.string.new_document_warning)) },
|
text = { Text(message) },
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton (onClick = {
|
TextButton(onClick = {
|
||||||
showDialog.value = false
|
showDialog.value = false
|
||||||
onConfirm()
|
onConfirm()
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<string name="close_document">Fermer le document</string>
|
<string name="close_document">Fermer le document</string>
|
||||||
<string name="current_document">Document en cours</string>
|
<string name="current_document">Document en cours</string>
|
||||||
<string name="delete_page">Supprimer la page</string>
|
<string name="delete_page">Supprimer la page</string>
|
||||||
|
<string name="delete_page_warning">Voulez-vous supprimer cette page ?</string>
|
||||||
<string name="document">Document</string>
|
<string name="document">Document</string>
|
||||||
<string name="error">Erreur : %1$s</string>
|
<string name="error">Erreur : %1$s</string>
|
||||||
<string name="error_no_document">Aucun document détecté</string>
|
<string name="error_no_document">Aucun document détecté</string>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<string name="close_document">Close document</string>
|
<string name="close_document">Close document</string>
|
||||||
<string name="current_document">Current document</string>
|
<string name="current_document">Current document</string>
|
||||||
<string name="delete_page">Delete page</string>
|
<string name="delete_page">Delete page</string>
|
||||||
|
<string name="delete_page_warning">Do you want to delete this page?</string>
|
||||||
<string name="document">Document</string>
|
<string name="document">Document</string>
|
||||||
<string name="error">Error: %1$s</string>
|
<string name="error">Error: %1$s</string>
|
||||||
<string name="error_no_document">No document detected</string>
|
<string name="error_no_document">No document detected</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user