Skip to content

Commit

Permalink
feat(Today Dashboard): add Long Press gesture to reset progress on To…
Browse files Browse the repository at this point in the history
…day tasks (Dimillian#192)
  • Loading branch information
renaudjenny authored May 25, 2020
1 parent f8be08a commit dbc0167
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,17 @@ public class UserCollection: ObservableObject {
return added
}

public func
updateProgress(taskName: DailyTasks.taskName) {
public func updateProgress(taskName: DailyTasks.taskName) {
dailyTasks.tasks[taskName]?.curProgress += 1
dailyTasks.lastUpdate = Date()
save()
}

public func resetProgress(taskName: DailyTasks.taskName) {
dailyTasks.tasks[taskName]?.curProgress = 0
dailyTasks.lastUpdate = Date()
save()
}

public func resetTasks() {
dailyTasks.lastUpdate = Date()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ struct TodayTasksSection: View {
}
self.collection.updateProgress(taskName: taskName)
}
.onLongPressGesture {
guard task.hasProgress else { return }
self.collection.resetProgress(taskName: taskName)
}
}

var body: some View {
Expand Down

0 comments on commit dbc0167

Please sign in to comment.