Quellcode durchsuchen

Merge branch 'dev' of github.com:nightscout/Trio-dev into onboarding-fixes

Deniz Cengiz vor 1 Jahr
Ursprung
Commit
d55d10906a

+ 3 - 1
LiveActivity/Views/LiveActivityChartView.swift

@@ -144,7 +144,9 @@ struct LiveActivityChartView: View {
             let pointMark = PointMark(
             let pointMark = PointMark(
                 x: .value("Time", chartDate),
                 x: .value("Time", chartDate),
                 y: .value("Value", displayValue)
                 y: .value("Value", displayValue)
-            ).symbolSize(16)
+            )
+            .symbolSize(16)
+            .shadow(color: Color.black.opacity(0.25), radius: 2, x: 0, y: 0)
 
 
             pointMark.foregroundStyle(pointMarkColor)
             pointMark.foregroundStyle(pointMarkColor)
         }
         }

+ 34 - 0
Trio/Sources/Application/TrioApp.swift

@@ -137,8 +137,14 @@ extension Notification.Name {
                     cleanupOldData()
                     cleanupOldData()
 
 
                     self.initState.complete = true
                     self.initState.complete = true
+
+                    // Notifications handling
+                    // Notify of completed initialization
                     Foundation.NotificationCenter.default.post(name: .initializationCompleted, object: nil)
                     Foundation.NotificationCenter.default.post(name: .initializationCompleted, object: nil)
                     UIApplication.shared.registerForRemoteNotifications()
                     UIApplication.shared.registerForRemoteNotifications()
+                    // Cancel scheduled not looping notifications when app was completely shut down and has now re-initialized completely
+                    self.clearNotLoopingNotifications()
+
                     do {
                     do {
                         try await BuildDetails.shared.handleExpireDateChange()
                         try await BuildDetails.shared.handleExpireDateChange()
                     } catch {
                     } catch {
@@ -159,6 +165,34 @@ extension Notification.Name {
         }
         }
     }
     }
 
 
+    /// Clears any legacy (Trio 0.2.x) delivered and pending notifications related to non-looping alerts.
+    /// It targets the following notifications:
+    /// - `noLoopFirstNotification`: The first notification for non-looping alerts.
+    /// - `noLoopSecondNotification`: The second notification for non-looping alerts.
+    ///
+    /// It ensures that any notifications that have already been shown to the user, as well as
+    /// any that are scheduled for the future, are removed when the system no longer needs to
+    /// alert about non-looping conditions.
+    ///
+    /// This function is typically used when the app was completely shut down and restarted,
+    /// i.e., underwent a fresh initialization and boot-up,  to avoid bogus not looping notifications
+    /// due to dangling "zombie" pending notification requests for users that update from
+    /// old Trio versions to the new generation of the app.
+    ///
+    /// Delivered notifications are cleared for completeness.
+    private func clearNotLoopingNotifications() {
+        let legacyNoLoopFirstNotification = "FreeAPS.noLoopFirstNotification"
+        let legacyNoLoopSecondNotification = "FreeAPS.noLoopSecondNotification"
+        UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [
+            legacyNoLoopFirstNotification,
+            legacyNoLoopSecondNotification
+        ])
+        UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [
+            legacyNoLoopFirstNotification,
+            legacyNoLoopSecondNotification
+        ])
+    }
+
     /// Attempts to initialize the CoreDataStack again after a previous failure.
     /// Attempts to initialize the CoreDataStack again after a previous failure.
     ///
     ///
     /// Resets error states and triggers the initialization process from the beginning. Called in response
     /// Resets error states and triggers the initialization process from the beginning. Called in response

+ 25 - 1
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -22974,6 +22974,7 @@
       }
       }
     },
     },
     "Add a CGM and pump to enable automated insuin delivery" : {
     "Add a CGM and pump to enable automated insuin delivery" : {
+      "extractionState" : "stale",
       "localizations" : {
       "localizations" : {
         "bg" : {
         "bg" : {
           "stringUnit" : {
           "stringUnit" : {
@@ -23073,6 +23074,9 @@
         }
         }
       }
       }
     },
     },
+    "Add a CGM and pump to enable automated insulin delivery" : {
+
+    },
     "Add a Garmin Device to Trio." : {
     "Add a Garmin Device to Trio." : {
       "localizations" : {
       "localizations" : {
         "bg" : {
         "bg" : {
@@ -43760,7 +43764,7 @@
     "Before you begin…" : {
     "Before you begin…" : {
 
 
     },
     },
-    "Before you can begin with configuring your therapy settigns, Trio needs to know which units you use for your glucose and insulin measurements (based on your pump model)." : {
+    "Before you can begin with configuring your therapy settings, Trio needs to know which units you use for your glucose and insulin measurements (based on your pump model)." : {
 
 
     },
     },
     "Beta (TestFlight) Expires" : {
     "Beta (TestFlight) Expires" : {
@@ -125390,6 +125394,7 @@
       }
       }
     },
     },
     "Lower target glucose when Autosens Ratio is <1." : {
     "Lower target glucose when Autosens Ratio is <1." : {
+      "extractionState" : "stale",
       "localizations" : {
       "localizations" : {
         "bg" : {
         "bg" : {
           "stringUnit" : {
           "stringUnit" : {
@@ -125489,6 +125494,9 @@
         }
         }
       }
       }
     },
     },
+    "Lower target glucose when Autosens Ratio is >1." : {
+
+    },
     "m" : {
     "m" : {
       "comment" : "Abbreviation for Minutes\nabbreviation for minutes",
       "comment" : "Abbreviation for Minutes\nabbreviation for minutes",
       "localizations" : {
       "localizations" : {
@@ -138177,7 +138185,11 @@
         }
         }
       }
       }
     },
     },
+    "No Glucose Notifications will be triggered." : {
+
+    },
     "No Glucose Notificatitons will be triggered." : {
     "No Glucose Notificatitons will be triggered." : {
+      "extractionState" : "stale",
       "localizations" : {
       "localizations" : {
         "bg" : {
         "bg" : {
           "stringUnit" : {
           "stringUnit" : {
@@ -142878,7 +142890,11 @@
         }
         }
       }
       }
     },
     },
+    "Note: The forecast used for this warning does not include carbs or insulin that have been logged but not yet effective." : {
+
+    },
     "Note: The forecast used for this warning does not include carbs or insulin that have not yet been logged." : {
     "Note: The forecast used for this warning does not include carbs or insulin that have not yet been logged." : {
+      "extractionState" : "stale",
       "localizations" : {
       "localizations" : {
         "bg" : {
         "bg" : {
           "stringUnit" : {
           "stringUnit" : {
@@ -156964,6 +156980,7 @@
       }
       }
     },
     },
     "Raise target glucose if when Autosens Ratio is >1." : {
     "Raise target glucose if when Autosens Ratio is >1." : {
+      "extractionState" : "stale",
       "localizations" : {
       "localizations" : {
         "bg" : {
         "bg" : {
           "stringUnit" : {
           "stringUnit" : {
@@ -157063,6 +157080,9 @@
         }
         }
       }
       }
     },
     },
+    "Raise target glucose when Autosens Ratio is <1." : {
+
+    },
     "Random variation added to each reading to simulate real-world sensor noise." : {
     "Random variation added to each reading to simulate real-world sensor noise." : {
       "localizations" : {
       "localizations" : {
         "bg" : {
         "bg" : {
@@ -217363,6 +217383,7 @@
       }
       }
     },
     },
     "When the carb on board (COB) forecast line is active, enabling this feature allows Trio to use Super Micro Boluses (SMB) to deliver the insulin required." : {
     "When the carb on board (COB) forecast line is active, enabling this feature allows Trio to use Super Micro Boluses (SMB) to deliver the insulin required." : {
+      "extractionState" : "stale",
       "localizations" : {
       "localizations" : {
         "bg" : {
         "bg" : {
           "stringUnit" : {
           "stringUnit" : {
@@ -217462,6 +217483,9 @@
         }
         }
       }
       }
     },
     },
+    "When there are carbs on board (COB > 0), enabling this feature allows Trio to use Super Micro Boluses (SMB) to deliver the insulin required." : {
+
+    },
     "When this feature is enabled, manually setting a temporary target above %@ %@ will decrease the Autosens Ratio used for ISF and basal adjustments, resulting in less insulin delivered overall. This scales with the temporary target set; the higher the temp target, the lower the Autosens Ratio used." : {
     "When this feature is enabled, manually setting a temporary target above %@ %@ will decrease the Autosens Ratio used for ISF and basal adjustments, resulting in less insulin delivered overall. This scales with the temporary target set; the higher the temp target, the lower the Autosens Ratio used." : {
       "localizations" : {
       "localizations" : {
         "bg" : {
         "bg" : {

+ 1 - 1
Trio/Sources/Modules/BolusCalculatorConfig/View/BolusCalculatorConfigRootView.swift

@@ -179,7 +179,7 @@ extension BolusCalculatorConfig {
                             "Also triggered when the lowest forecasted glucose (minPredBG) is < \(state.units == .mgdL ? 54.description : 54.formattedAsMmolL) \(state.units.rawValue)."
                             "Also triggered when the lowest forecasted glucose (minPredBG) is < \(state.units == .mgdL ? 54.description : 54.formattedAsMmolL) \(state.units.rawValue)."
                         )
                         )
                         Text(
                         Text(
-                            "Note: The forecast used for this warning does not include carbs or insulin that have not yet been logged."
+                            "Note: The forecast used for this warning does not include carbs or insulin that have been logged but not yet effective."
                         )
                         )
                     }
                     }
                 )
                 )

+ 4 - 2
Trio/Sources/Modules/DataTable/View/DataTableRootView.swift

@@ -367,10 +367,12 @@ extension DataTable {
                                 action: {
                                 action: {
                                     alertGlucoseToDelete = glucose
                                     alertGlucoseToDelete = glucose
 
 
+                                    let glucoseToDisplay = state.units == .mgdL ? glucose.glucose
+                                        .description : Int(glucose.glucose).formattedAsMmolL
                                     alertTitle = String(localized: "Delete Glucose?", comment: "Alert title for deleting glucose")
                                     alertTitle = String(localized: "Delete Glucose?", comment: "Alert title for deleting glucose")
                                     alertMessage = Formatter.dateFormatter
                                     alertMessage = Formatter.dateFormatter
-                                        .string(from: glucose.date ?? Date()) + ", " +
-                                        (Formatter.decimalFormatterWithTwoFractionDigits.string(for: glucose.glucose) ?? "0")
+                                        .string(from: glucose.date ?? Date()) + ", " + glucoseToDisplay + " " + state.units
+                                        .rawValue
 
 
                                     isRemoveHistoryItemAlertPresented = true
                                     isRemoveHistoryItemAlertPresented = true
                                 }
                                 }

+ 1 - 1
Trio/Sources/Modules/GlucoseNotificationSettings/View/GlucoseNotificationSettingsRootView.swift

@@ -198,7 +198,7 @@ extension GlucoseNotificationSettings {
                                                 )
                                                 )
                                                 VStack(alignment: .leading, spacing: 5) {
                                                 VStack(alignment: .leading, spacing: 5) {
                                                     Text("Disabled:").bold()
                                                     Text("Disabled:").bold()
-                                                    Text("No Glucose Notificatitons will be triggered.")
+                                                    Text("No Glucose Notifications will be triggered.")
                                                 }
                                                 }
                                                 VStack(alignment: .leading, spacing: 5) {
                                                 VStack(alignment: .leading, spacing: 5) {
                                                     Text("Always:").bold()
                                                     Text("Always:").bold()

+ 3 - 3
Trio/Sources/Modules/Home/View/HomeRootView.swift

@@ -1056,13 +1056,13 @@ extension Home {
 
 
                 Button(
                 Button(
                     action: {
                     action: {
-                        state.showModal(for: .bolus) },
+                        state.showModal(for: .treatmentView) },
                     label: {
                     label: {
                         Image(systemName: "plus.circle.fill")
                         Image(systemName: "plus.circle.fill")
                             .font(.system(size: 40))
                             .font(.system(size: 40))
                             .foregroundStyle(Color.tabBar)
                             .foregroundStyle(Color.tabBar)
-                            .padding(.bottom, 1)
-                            .padding(.horizontal, 22.5)
+                            .padding(.vertical, 2)
+                            .padding(.horizontal, 24)
                     }
                     }
                 )
                 )
             }.ignoresSafeArea(.keyboard, edges: .bottom).blur(radius: state.waitForSuggestion ? 8 : 0)
             }.ignoresSafeArea(.keyboard, edges: .bottom).blur(radius: state.waitForSuggestion ? 8 : 0)

+ 1 - 1
Trio/Sources/Modules/LiveActivitySettings/View/LiveActivityWidgetConfiguration.swift

@@ -377,7 +377,7 @@ enum LiveActivityItem: String, CaseIterable, Identifiable {
     var id: String { rawValue }
     var id: String { rawValue }
 
 
     static var defaultItems: [LiveActivityItem] {
     static var defaultItems: [LiveActivityItem] {
-        [.currentGlucoseLarge, .iob, .cob, .updatedLabel]
+        [.currentGlucose, .iob, .cob, .updatedLabel]
     }
     }
 
 
     var displayName: String {
     var displayName: String {

+ 1 - 1
Trio/Sources/Modules/Onboarding/View/OnboardingView+Util.swift

@@ -105,7 +105,7 @@ enum OnboardingStep: Int, CaseIterable, Identifiable, Equatable {
             )
             )
         case .unitSelection:
         case .unitSelection:
             return String(
             return String(
-                localized: "Before you can begin with configuring your therapy settigns, Trio needs to know which units you use for your glucose and insulin measurements (based on your pump model)."
+                localized: "Before you can begin with configuring your therapy settings, Trio needs to know which units you use for your glucose and insulin measurements (based on your pump model)."
             )
             )
         case .glucoseTarget:
         case .glucoseTarget:
             return String(
             return String(

+ 1 - 1
Trio/Sources/Modules/SMBSettings/View/SMBSettingsRootView.swift

@@ -65,7 +65,7 @@ extension SMBSettings {
                         VStack(alignment: .leading, spacing: 10) {
                         VStack(alignment: .leading, spacing: 10) {
                             Text("Default: OFF").bold()
                             Text("Default: OFF").bold()
                             Text(
                             Text(
-                                "When the carb on board (COB) forecast line is active, enabling this feature allows Trio to use Super Micro Boluses (SMB) to deliver the insulin required."
+                                "When there are carbs on board (COB > 0), enabling this feature allows Trio to use Super Micro Boluses (SMB) to deliver the insulin required."
                             )
                             )
                             Text(
                             Text(
                                 "Note: If this is enabled and the criteria are met, SMBs could be utilized regardless of other SMB settings being enabled or not."
                                 "Note: If this is enabled and the criteria are met, SMBs could be utilized regardless of other SMB settings being enabled or not."

+ 1 - 1
Trio/Sources/Modules/Settings/View/SettingsRootView.swift

@@ -115,7 +115,7 @@ extension Settings {
                     ).listRowBackground(Color.chart)
                     ).listRowBackground(Color.chart)
 
 
                     let miniHintText = closedLoopDisabled ?
                     let miniHintText = closedLoopDisabled ?
-                        String(localized: "Add a CGM and pump to enable automated insuin delivery") :
+                        String(localized: "Add a CGM and pump to enable automated insulin delivery") :
                         String(localized: "Enable automated insulin delivery.")
                         String(localized: "Enable automated insulin delivery.")
                     let miniHintTextColorForDisabled: Color = colorScheme == .dark ? .orange : .accentColor
                     let miniHintTextColorForDisabled: Color = colorScheme == .dark ? .orange : .accentColor
                     let miniHintTextColor: Color = closedLoopDisabled ? miniHintTextColorForDisabled : .secondary
                     let miniHintTextColor: Color = closedLoopDisabled ? miniHintTextColorForDisabled : .secondary

+ 2 - 2
Trio/Sources/Modules/TargetBehavoir/View/TargetBehavoirRootView.swift

@@ -110,7 +110,7 @@ extension TargetBehavoir {
                     units: state.units,
                     units: state.units,
                     type: .boolean,
                     type: .boolean,
                     label: String(localized: "Sensitivity Raises Target", comment: "Sensitivity Raises Target"),
                     label: String(localized: "Sensitivity Raises Target", comment: "Sensitivity Raises Target"),
-                    miniHint: String(localized: "Raise target glucose if when Autosens Ratio is >1."),
+                    miniHint: String(localized: "Raise target glucose when Autosens Ratio is <1."),
                     verboseHint: VStack(alignment: .leading, spacing: 10) {
                     verboseHint: VStack(alignment: .leading, spacing: 10) {
                         Text("Default: OFF").bold()
                         Text("Default: OFF").bold()
                         Text(
                         Text(
@@ -133,7 +133,7 @@ extension TargetBehavoir {
                     units: state.units,
                     units: state.units,
                     type: .boolean,
                     type: .boolean,
                     label: String(localized: "Resistance Lowers Target", comment: "Resistance Lowers Target"),
                     label: String(localized: "Resistance Lowers Target", comment: "Resistance Lowers Target"),
-                    miniHint: String(localized: "Lower target glucose when Autosens Ratio is <1."),
+                    miniHint: String(localized: "Lower target glucose when Autosens Ratio is >1."),
                     verboseHint: VStack(alignment: .leading, spacing: 10) {
                     verboseHint: VStack(alignment: .leading, spacing: 10) {
                         Text("Default: OFF").bold()
                         Text("Default: OFF").bold()
                         Text(
                         Text(

+ 2 - 2
Trio/Sources/Router/Screen.swift

@@ -15,7 +15,7 @@ enum Screen: Identifiable, Hashable {
     case isfEditor
     case isfEditor
     case crEditor
     case crEditor
     case targetsEditor
     case targetsEditor
-    case bolus
+    case treatmentView
     case manualTempBasal
     case manualTempBasal
     case dataTable
     case dataTable
     case cgm
     case cgm
@@ -82,7 +82,7 @@ extension Screen {
             CarbRatioEditor.RootView(resolver: resolver)
             CarbRatioEditor.RootView(resolver: resolver)
         case .targetsEditor:
         case .targetsEditor:
             TargetsEditor.RootView(resolver: resolver)
             TargetsEditor.RootView(resolver: resolver)
-        case .bolus:
+        case .treatmentView:
             Treatments.RootView(resolver: resolver)
             Treatments.RootView(resolver: resolver)
         case .manualTempBasal:
         case .manualTempBasal:
             ManualTempBasal.RootView(resolver: resolver)
             ManualTempBasal.RootView(resolver: resolver)

+ 1 - 1
Trio/Sources/Services/UserNotifications/UserNotificationsManager.swift

@@ -40,7 +40,7 @@ protocol pumpNotificationObserver {
 }
 }
 
 
 final class BaseUserNotificationsManager: NSObject, UserNotificationsManager, Injectable {
 final class BaseUserNotificationsManager: NSObject, UserNotificationsManager, Injectable {
-    private enum Identifier: String {
+    enum Identifier: String {
         case glucoseNotification = "Trio.glucoseNotification"
         case glucoseNotification = "Trio.glucoseNotification"
         case carbsRequiredNotification = "Trio.carbsRequiredNotification"
         case carbsRequiredNotification = "Trio.carbsRequiredNotification"
         case noLoopFirstNotification = "Trio.noLoopFirstNotification"
         case noLoopFirstNotification = "Trio.noLoopFirstNotification"