Skip to content

Commit b3e278d

Browse files
committed
feat: Click to toggle mark as done
1 parent ae87b1d commit b3e278d

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

tasks/tasks/TaskCard.swift

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@ import SwiftUI
22

33
struct TaskCard: View {
44
let taskItem: TaskItem
5+
var onToggleCompletion: (() -> Void)? = nil
56

67
var body: some View {
78
VStack(alignment: .leading, spacing: 6) {
89
HStack {
9-
if taskItem.status == "completed" {
10-
Image(systemName: "checkmark.circle.fill")
11-
.foregroundColor(.green)
12-
.padding(.trailing, 2)
13-
} else {
14-
Image(systemName: "circle")
15-
.foregroundColor(.gray)
16-
.padding(.trailing, 2)
10+
Group {
11+
if taskItem.status == "completed" {
12+
Image(systemName: "checkmark.circle.fill")
13+
.foregroundColor(.green)
14+
} else {
15+
Image(systemName: "circle")
16+
.foregroundColor(.gray)
17+
}
18+
}
19+
.padding(.trailing, 2)
20+
.contentShape(Rectangle())
21+
.onTapGesture {
22+
onToggleCompletion?()
1723
}
1824

1925
Text(taskItem.title ?? "(no title)")
2026
.font(.headline)
21-
2227
}
2328

2429
if let notes = taskItem.notes, !notes.isEmpty {

tasks/tasks/TaskListTab.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private struct TaskRowView: View {
9797
let deleteTask: () -> Void
9898

9999
var body: some View {
100-
TaskCard(taskItem: task)
100+
TaskCard(taskItem: task, onToggleCompletion: toggleCompletion)
101101
.contentShape(Rectangle())
102102
.onTapGesture(perform: onTap)
103103
.swipeActions(edge: .leading, allowsFullSwipe: true) {

0 commit comments

Comments
 (0)