WIP - a lot of uncommitted work

This commit is contained in:
Trey t
2022-01-15 12:03:31 -06:00
parent 80690e4a8c
commit 64dd1855ac
31 changed files with 1024 additions and 154 deletions

View File

@@ -106,38 +106,3 @@ class LocalNotification {
UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
}
}
class NotificationDelegate: NSObject, ObservableObject, UNUserNotificationCenterDelegate {
@Published var notificationCounter = 0
override init() {
super.init()
UNUserNotificationCenter.current().delegate = self
}
func requestAuthorization() {
}
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.badge, .banner, .sound])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
if let action = LocalNotification.ActionType(rawValue: response.actionIdentifier) {
switch action {
case .horrible:
PersistenceController.shared.add(mood: .horrible, forDate: Date())
case .bad:
PersistenceController.shared.add(mood: .bad, forDate: Date())
case .average:
PersistenceController.shared.add(mood: .average, forDate: Date())
case .good:
PersistenceController.shared.add(mood: .good, forDate: Date())
case .great:
PersistenceController.shared.add(mood: .great, forDate: Date())
}
}
completionHandler()
}
}