diff --git a/iosApp/iosApp/Helpers/L10n.swift b/iosApp/iosApp/Helpers/L10n.swift index 8b81e52..b8e3b58 100644 --- a/iosApp/iosApp/Helpers/L10n.swift +++ b/iosApp/iosApp/Helpers/L10n.swift @@ -216,6 +216,8 @@ enum L10n { static var deleteTask: String { String(localized: "tasks_delete_task") } static var archiveConfirm: String { String(localized: "tasks_archive_confirm") } static var archive: String { String(localized: "tasks_archive") } + static var cancelTask: String { String(localized: "tasks_cancel_task") } + static var cancelConfirm: String { String(localized: "tasks_cancel_confirm") } static var noTasks: String { String(localized: "tasks_no_tasks") } // Complete Task View diff --git a/iosApp/iosApp/Localizable.xcstrings b/iosApp/iosApp/Localizable.xcstrings index e5875b5..44a7324 100644 --- a/iosApp/iosApp/Localizable.xcstrings +++ b/iosApp/iosApp/Localizable.xcstrings @@ -25673,6 +25673,28 @@ } } }, + "tasks_cancel_confirm" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Are you sure you want to cancel this task?" + } + } + } + }, + "tasks_cancel_task" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Cancel Task" + } + } + } + }, "tasks_category" : { "extractionState" : "manual", "localizations" : { diff --git a/iosApp/iosApp/Residence/ResidenceDetailView.swift b/iosApp/iosApp/Residence/ResidenceDetailView.swift index 19cbfb1..13f9cd5 100644 --- a/iosApp/iosApp/Residence/ResidenceDetailView.swift +++ b/iosApp/iosApp/Residence/ResidenceDetailView.swift @@ -25,6 +25,8 @@ struct ResidenceDetailView: View { @State private var selectedTaskForComplete: TaskResponse? @State private var selectedTaskForArchive: TaskResponse? @State private var showArchiveConfirmation = false + @State private var selectedTaskForCancel: TaskResponse? + @State private var showCancelConfirmation = false @State private var hasAppeared = false @State private var showReportAlert = false @@ -144,6 +146,21 @@ struct ResidenceDetailView: View { Text("Are you sure you want to archive \"\(task.title)\"? You can unarchive it later from archived tasks.") } } + .alert(L10n.Tasks.cancelTask, isPresented: $showCancelConfirmation) { + Button(L10n.Common.no, role: .cancel) { + selectedTaskForCancel = nil + } + Button(L10n.Common.yes, role: .destructive) { + if let task = selectedTaskForCancel { + taskViewModel.cancelTask(id: task.id) { _ in + loadResidenceTasks() + } + selectedTaskForCancel = nil + } + } + } message: { + Text(L10n.Tasks.cancelConfirm) + } .sheet(isPresented: $showingUpgradePrompt) { UpgradePromptView(triggerKey: upgradeTriggerKey.isEmpty ? "add_11th_task" : upgradeTriggerKey, isPresented: $showingUpgradePrompt) } @@ -489,9 +506,8 @@ private struct TasksSectionContainer: View { showEditTask = true }, onCancelTask: { task in - taskViewModel.cancelTask(id: task.id) { _ in - reloadTasks() - } + selectedTaskForCancel = task + showCancelConfirmation = true }, onUncancelTask: { taskId in taskViewModel.uncancelTask(id: taskId) { _ in diff --git a/iosApp/iosApp/Task/AllTasksView.swift b/iosApp/iosApp/Task/AllTasksView.swift index cc88233..b2e542d 100644 --- a/iosApp/iosApp/Task/AllTasksView.swift +++ b/iosApp/iosApp/Task/AllTasksView.swift @@ -76,11 +76,11 @@ struct AllTasksView: View { Text(L10n.Tasks.archiveConfirm.replacingOccurrences(of: "this task", with: "\"\(task.title)\"")) } } - .alert(L10n.Tasks.deleteTask, isPresented: $showCancelConfirmation) { - Button(L10n.Common.cancel, role: .cancel) { + .alert(L10n.Tasks.cancelTask, isPresented: $showCancelConfirmation) { + Button(L10n.Common.no, role: .cancel) { selectedTaskForCancel = nil } - Button(L10n.Tasks.archive, role: .destructive) { + Button(L10n.Common.yes, role: .destructive) { if let task = selectedTaskForCancel { taskViewModel.cancelTask(id: task.id) { _ in loadAllTasks() @@ -89,9 +89,7 @@ struct AllTasksView: View { } } } message: { - if let task = selectedTaskForCancel { - Text(L10n.Tasks.archiveConfirm.replacingOccurrences(of: "this task", with: "\"\(task.title)\"")) - } + Text(L10n.Tasks.cancelConfirm) } .onChange(of: showAddTask) { isShowing in if !isShowing {