Task deletion feature (#7)

This PR contains the work done to add support for todo tasks deletion on the *Task list* view.

Reviewed-on: rock-n-code/todos-app#7
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #7.
This commit is contained in:
2026-02-11 16:35:51 +00:00
committed by javier
parent ac0e0f6556
commit b8e6e515dc
4 changed files with 138 additions and 24 deletions
+16 -2
View File
@@ -9,6 +9,10 @@ struct TaskListView: View {
// MARK: Properties
/// The SwiftData model context for performing data operations.
@Environment(\.modelContext)
private var modelContext
/// The view model managing the state and business logic for this view.
///
/// This view model holds the group configuration and completion filter state.
@@ -40,8 +44,18 @@ struct TaskListView: View {
Content(
group: viewModel.group,
showCompleted: viewModel.showCompleted
) { tasks, source, destination in
viewModel.reorderTasks(tasks, from: source, to: destination)
) { tasks, offsets in
viewModel.deleteTasks(
tasks,
at: offsets,
from: modelContext
)
} onReorder: { tasks, source, destination in
viewModel.reorderTasks(
tasks,
from: source,
to: destination
)
}
.navigationTitle(viewModel.navigationTitle)
.toolbar {