Browse Source

Unified in-app and notification action snooze functionality to use the same set of snooze options: 20 mins, 1 hour, 3 hours, and 6 hours, and update localized titles for all snooze actions in notification handling.

Charlie Chrisman 4 tháng trước cách đây
mục cha
commit
caf041d8f7

+ 7 - 5
Trio Watch App Extension/Helper/WatchNotificationHandler.swift

@@ -41,11 +41,13 @@ final class WatchNotificationHandler: NSObject, UNUserNotificationCenterDelegate
     private func title(for action: NotificationResponseAction) -> String {
         switch action {
         case .snooze20:
-            return String(localized: "Snooze 20 min", comment: "Snooze glucose alerts for 20 minutes")
-        case .snooze40:
-            return String(localized: "Snooze 40 min", comment: "Snooze glucose alerts for 40 minutes")
-        case .snooze60:
-            return String(localized: "Snooze 1 hr", comment: "Snooze glucose alerts for 60 minutes")
+            return String(localized: "20 min", comment: "Snooze glucose alerts for 20 minutes")
+        case .snooze1hr:
+            return String(localized: "1 hour", comment: "Snooze glucose alerts for 1 hour")
+        case .snooze3hr:
+            return String(localized: "3 hours", comment: "Snooze glucose alerts for 3 hours")
+        case .snooze6hr:
+            return String(localized: "6 hours", comment: "Snooze glucose alerts for 6 hours")
         }
     }
 

+ 8 - 5
Trio/Sources/Models/NotificationIdentifiers.swift

@@ -6,8 +6,9 @@ enum NotificationCategoryIdentifier: String {
 
 enum NotificationResponseAction: String, CaseIterable {
     case snooze20 = "Trio.snooze20"
-    case snooze40 = "Trio.snooze40"
-    case snooze60 = "Trio.snooze60"
+    case snooze1hr = "Trio.snooze1hr"
+    case snooze3hr = "Trio.snooze3hr"
+    case snooze6hr = "Trio.snooze6hr"
 
     var duration: TimeInterval {
         TimeInterval(minutes * 60)
@@ -17,10 +18,12 @@ enum NotificationResponseAction: String, CaseIterable {
         switch self {
         case .snooze20:
             return 20
-        case .snooze40:
-            return 40
-        case .snooze60:
+        case .snooze1hr:
             return 60
+        case .snooze3hr:
+            return 180
+        case .snooze6hr:
+            return 360
         }
     }
 }

+ 6 - 23
Trio/Sources/Modules/Snooze/View/SnoozeRootView.swift

@@ -14,29 +14,12 @@ extension Snooze {
         @State private var snoozeDescription = "nothing to see here"
 
         private var pickerTimes: [TimeInterval] {
-            var arr: [TimeInterval] = []
-
-            let mins10 = 0.166_67
-            let mins20 = mins10 * 2
-            let mins30 = mins10 * 3
-            // let mins40 = mins10 * 4
-
-            for hr in 0 ..< 2 {
-                for min in [0.0, mins20, mins20 * 2] {
-                    arr.append(TimeInterval(hours: Double(hr) + min))
-                }
-            }
-            for hr in 2 ..< 4 {
-                for min in [0.0, mins30] {
-                    arr.append(TimeInterval(hours: Double(hr) + min))
-                }
-            }
-
-            for hr in 4 ... 8 {
-                arr.append(TimeInterval(hours: Double(hr)))
-            }
-
-            return arr
+            [
+                TimeInterval(minutes: 20),   // 20 minutes
+                TimeInterval(hours: 1),      // 1 hour
+                TimeInterval(hours: 3),      // 3 hours
+                TimeInterval(hours: 6)       // 6 hours
+            ]
         }
 
         private var formatter: DateComponentsFormatter {

+ 7 - 5
Trio/Sources/Services/UserNotifications/UserNotificationsManager.swift

@@ -138,11 +138,13 @@ final class BaseUserNotificationsManager: NSObject, UserNotificationsManager, In
     private func title(for action: NotificationResponseAction) -> String {
         switch action {
         case .snooze20:
-            return String(localized: "Snooze 20 min", comment: "Snooze glucose alerts for 20 minutes")
-        case .snooze40:
-            return String(localized: "Snooze 40 min", comment: "Snooze glucose alerts for 40 minutes")
-        case .snooze60:
-            return String(localized: "Snooze 1 hr", comment: "Snooze glucose alerts for 60 minutes")
+            return String(localized: "20 min", comment: "Snooze glucose alerts for 20 minutes")
+        case .snooze1hr:
+            return String(localized: "1 hour", comment: "Snooze glucose alerts for 1 hour")
+        case .snooze3hr:
+            return String(localized: "3 hours", comment: "Snooze glucose alerts for 3 hours")
+        case .snooze6hr:
+            return String(localized: "6 hours", comment: "Snooze glucose alerts for 6 hours")
         }
     }