Add confirmation dialogs for destructive task actions

iOS:
- Add archive task confirmation to TaskActionButtons.swift
- Add archive task confirmation to AllTasksView.swift
- Add cancel and archive task confirmations to ResidenceDetailView.swift
- Fix generatePropertyReport call to use new method signature

Android:
- Add cancel task confirmation to ResidenceDetailScreen.kt
- Add archive task confirmation to ResidenceDetailScreen.kt

All destructive task actions (cancel, archive/delete) now require user confirmation with clear warning messages before proceeding.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-11-13 23:44:41 -06:00
parent a2de0f3454
commit 6ffd5ff626
4 changed files with 468 additions and 225 deletions

View File

@@ -56,6 +56,10 @@ fun ResidenceDetailScreen(
var reportMessage by remember { mutableStateOf("") }
var showReportConfirmation by remember { mutableStateOf(false) }
var showDeleteConfirmation by remember { mutableStateOf(false) }
var showCancelTaskConfirmation by remember { mutableStateOf(false) }
var showArchiveTaskConfirmation by remember { mutableStateOf(false) }
var taskToCancel by remember { mutableStateOf<TaskDetail?>(null) }
var taskToArchive by remember { mutableStateOf<TaskDetail?>(null) }
val deleteState by residenceViewModel.deleteResidenceState.collectAsState()
LaunchedEffect(residenceId) {
@@ -244,6 +248,76 @@ fun ResidenceDetailScreen(
)
}
if (showCancelTaskConfirmation && taskToCancel != null) {
AlertDialog(
onDismissRequest = {
showCancelTaskConfirmation = false
taskToCancel = null
},
title = { Text("Cancel Task") },
text = { Text("Are you sure you want to cancel \"${taskToCancel!!.title}\"? This action cannot be undone.") },
confirmButton = {
Button(
onClick = {
showCancelTaskConfirmation = false
residenceViewModel.cancelTask(taskToCancel!!.id)
taskToCancel = null
},
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.error
)
) {
Text("Cancel Task")
}
},
dismissButton = {
TextButton(onClick = {
showCancelTaskConfirmation = false
taskToCancel = null
}) {
Text("Dismiss")
}
}
)
}
if (showArchiveTaskConfirmation && taskToArchive != null) {
AlertDialog(
onDismissRequest = {
showArchiveTaskConfirmation = false
taskToArchive = null
},
title = { Text("Archive Task") },
text = { Text("Are you sure you want to archive \"${taskToArchive!!.title}\"? You can unarchive it later from archived tasks.") },
confirmButton = {
Button(
onClick = {
showArchiveTaskConfirmation = false
taskViewModel.archiveTask(taskToArchive!!.id) { success ->
if (success) {
residenceViewModel.loadResidenceTasks(residenceId)
}
}
taskToArchive = null
},
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.error
)
) {
Text("Archive")
}
},
dismissButton = {
TextButton(onClick = {
showArchiveTaskConfirmation = false
taskToArchive = null
}) {
Text("Dismiss")
}
}
)
}
val snackbarHostState = remember { SnackbarHostState() }
LaunchedEffect(showReportSnackbar) {
@@ -612,7 +686,8 @@ fun ResidenceDetailScreen(
onNavigateToEditTask(task)
},
onCancelTask = { task ->
residenceViewModel.cancelTask(task.id)
taskToCancel = task
showCancelTaskConfirmation = true
},
onUncancelTask = { task ->
residenceViewModel.uncancelTask(task.id)
@@ -625,11 +700,8 @@ fun ResidenceDetailScreen(
}
},
onArchiveTask = { task ->
taskViewModel.archiveTask(task.id) { success ->
if (success) {
residenceViewModel.loadResidenceTasks(residenceId)
}
}
taskToArchive = task
showArchiveTaskConfirmation = true
},
onUnarchiveTask = { task ->
taskViewModel.unarchiveTask(task.id) { success ->