feat(editor): 删除前二次确认
This commit is contained in:
parent
df3ec533ea
commit
31c58b3a03
5 changed files with 24 additions and 15 deletions
|
|
@ -29,7 +29,10 @@ fun WarningDialog(
|
|||
text = { Text(description) },
|
||||
confirmButton = stringResource(R.string.action_confirm),
|
||||
dismissButton = stringResource(R.string.action_cancel),
|
||||
onConfirm = onConfirm,
|
||||
onConfirm = {
|
||||
onConfirm()
|
||||
onDismiss()
|
||||
},
|
||||
onDismiss = onDismiss,
|
||||
modifier = modifier
|
||||
)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ fun TodoEditorPage(
|
|||
animatedVisibilityScope: AnimatedVisibilityScope,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
var showConfirmDialog by rememberSaveable { mutableStateOf(false) }
|
||||
var showExitConfirmDialog by rememberSaveable { mutableStateOf(false) }
|
||||
var showDeleteConfirmDialog by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
val context = LocalContext.current
|
||||
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
|
||||
|
|
@ -84,7 +85,7 @@ fun TodoEditorPage(
|
|||
if ((toDo?.subject ?: 0) != selectedSubjectIndex) isModified = true
|
||||
if ((toDo?.priority ?: 0f) != priorityState) isModified = true
|
||||
if (isModified) {
|
||||
showConfirmDialog = true
|
||||
showExitConfirmDialog = true
|
||||
} else {
|
||||
onNavigateUp()
|
||||
}
|
||||
|
|
@ -105,20 +106,20 @@ fun TodoEditorPage(
|
|||
icon = {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.Delete,
|
||||
contentDescription = stringResource(R.string.action_delete)
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
text = { Text(stringResource(R.string.action_delete)) },
|
||||
expanded = true,
|
||||
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||
onClick = onDelete
|
||||
onClick = { showDeleteConfirmDialog = true }
|
||||
)
|
||||
}
|
||||
AnimatedExtendedFloatingActionButton(
|
||||
icon = {
|
||||
Icon(
|
||||
imageVector = Icons.Outlined.Save,
|
||||
contentDescription = stringResource(R.string.action_save)
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
text = { Text(stringResource(R.string.action_save)) },
|
||||
|
|
@ -246,13 +247,21 @@ fun TodoEditorPage(
|
|||
}
|
||||
|
||||
WarningDialog(
|
||||
visible = showConfirmDialog,
|
||||
visible = showExitConfirmDialog,
|
||||
icon = Icons.AutoMirrored.Outlined.Undo,
|
||||
description = stringResource(R.string.tip_discard_changes),
|
||||
onConfirm = {
|
||||
showConfirmDialog = false
|
||||
showExitConfirmDialog = false
|
||||
onNavigateUp()
|
||||
},
|
||||
onDismiss = { showConfirmDialog = false }
|
||||
onDismiss = { showExitConfirmDialog = false }
|
||||
)
|
||||
|
||||
WarningDialog(
|
||||
visible = showDeleteConfirmDialog,
|
||||
icon = Icons.Outlined.Delete,
|
||||
description = stringResource(R.string.tip_delete_task, 1),
|
||||
onConfirm = onDelete,
|
||||
onDismiss = { showDeleteConfirmDialog = false }
|
||||
)
|
||||
}
|
||||
|
|
@ -212,10 +212,7 @@ fun MainPage(
|
|||
visible = showDeleteConfirmDialog,
|
||||
icon = Icons.Outlined.Delete,
|
||||
description = stringResource(R.string.tip_delete_task, selectedTodoIds.value.size),
|
||||
onConfirm = {
|
||||
showDeleteConfirmDialog = false
|
||||
viewModel.deleteSelectedTodo()
|
||||
},
|
||||
onConfirm = { viewModel.deleteSelectedTodo() },
|
||||
onDismiss = { showDeleteConfirmDialog = false }
|
||||
)
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
<string name="title_selected_count">已选择 %s 项</string>
|
||||
<string name="action_confirm">确定</string>
|
||||
<string name="title_warning">警告</string>
|
||||
<string name="tip_delete_task">即将删除你选择的 %s 项待办。删除后将无法恢复这些待办,确定删除?</string>
|
||||
<string name="tip_delete_task">即将删除 %s 项待办。删除后将无法恢复这些待办,确定删除?</string>
|
||||
<string name="action_back">返回</string>
|
||||
<string name="pref_about">关于</string>
|
||||
<string name="pref_about_desc">关于本应用</string>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
<string name="title_selected_count">%s selected</string>
|
||||
<string name="action_confirm">Confirm</string>
|
||||
<string name="title_warning">Warning</string>
|
||||
<string name="tip_delete_task">You are about to delete the %s selected tasks. Once deleted, these tasks cannot be recovered. Are you sure you want to delete them?</string>
|
||||
<string name="tip_delete_task">You are about to delete the %s tasks. Once deleted, these tasks cannot be recovered. Are you sure you want to delete them?</string>
|
||||
<string name="placeholder_divider" translatable="false">/</string>
|
||||
<string name="action_back">Back</string>
|
||||
<string name="pref_about">About</string>
|
||||
|
|
|
|||
Loading…
Reference in a new issue