Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AIReviewSwiftUI/TaskViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ final class TaskViewModel: ObservableObject {
tasks.append(Task(title: title))
}

/// Toggles the completion status of the specified task in the tasks array.
///
/// If the task is found by its unique identifier, its `isCompleted` property is switched between true and false.
///
/// - Parameter task: The task whose completion status should be toggled.
func toggleComplete(_ task: Task) {
guard let index = tasks.firstIndex(where: { $0.id == task.id }) else { return }
tasks[index].isCompleted.toggle()
Expand Down