Add task persistence and per-task reminder notifications

Tasks now survive app restarts via UserDefaults JSON. Each task with a
due time fires a notification at that exact time; date-only tasks fire
at 9am on the due date. Completing or deleting a task cancels its
pending notification. ContentView now reschedules on any task change.
This commit is contained in:
kutesir
2026-05-29 10:33:55 +03:00
parent bc55d27f45
commit 1d4d7f07c5
4 changed files with 97 additions and 29 deletions

View File

@@ -86,11 +86,11 @@ struct ContentView: View {
workoutVM.syncWidget()
}
}
.onChange(of: taskVM.tasks.count) { _ in taskVM.syncWidget() }
.onChange(of: workoutVM.doneSets) { _ in
.onChange(of: taskVM.tasks) { _ in
taskVM.syncWidget()
NotificationManager.shared.reschedule(workoutVM: workoutVM, taskVM: taskVM)
}
.onChange(of: taskVM.tasks.filter { !$0.isComplete && $0.quadrant == .urgent }.count) { _ in
.onChange(of: workoutVM.doneSets) { _ in
NotificationManager.shared.reschedule(workoutVM: workoutVM, taskVM: taskVM)
}
}