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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user