feat(Today Dashboard): add Long Press gesture to reset progress on Today tasks
MODIFY
ACHNBrowserUI/ACHNBrowserUI/packages/Backend/Sources/Backend/environments/UserCollection.swift
ACHNBrowserUI/ACHNBrowserUI/packages/Backend/Sources/Backend/environments/UserCollection.swift
@@ -92,13 +92,18 @@ 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()
for(taskName, _) in dailyTasks.tasks {

MODIFY
ACHNBrowserUI/ACHNBrowserUI/views/todayDashboard/TodayTasksSection.swift
ACHNBrowserUI/ACHNBrowserUI/views/todayDashboard/TodayTasksSection.swift
@@ -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 {

feat(Today Dashboard): add Long Press gesture to reset progress on Today tasks (#192)