فهرست منبع

Merge branch 'settings-update' of https://github.com/tmhastings/Trio-dev into settings-update

tmhastings 1 سال پیش
والد
کامیت
3380054127

+ 1 - 0
FreeAPS/Resources/Info.plist

@@ -101,6 +101,7 @@
 		<string>bluetooth-peripheral</string>
 		<string>bluetooth-peripheral</string>
 		<string>fetch</string>
 		<string>fetch</string>
 		<string>processing</string>
 		<string>processing</string>
+                <string>remote-notification</string>
 	</array>
 	</array>
 	<key>UIFileSharingEnabled</key>
 	<key>UIFileSharingEnabled</key>
 	<true/>
 	<true/>

+ 1 - 1
FreeAPS/Sources/Models/DecimalPickerSettings.swift

@@ -103,7 +103,7 @@ struct DecimalPickerSettings {
         max: 1,
         max: 1,
         type: PickerSetting.PickerSettingType.insulinUnit
         type: PickerSetting.PickerSettingType.insulinUnit
     )
     )
-    var insulinPeakTime = PickerSetting(value: 75, step: 5, min: 35, max: 120, type: PickerSetting.PickerSettingType.minute)
+    var insulinPeakTime = PickerSetting(value: 75, step: 1, min: 35, max: 120, type: PickerSetting.PickerSettingType.minute)
     var carbsReqThreshold = PickerSetting(value: 1.0, step: 0.1, min: 0, max: 10, type: PickerSetting.PickerSettingType.gram)
     var carbsReqThreshold = PickerSetting(value: 1.0, step: 0.1, min: 0, max: 10, type: PickerSetting.PickerSettingType.gram)
     var noisyCGMTargetMultiplier = PickerSetting(
     var noisyCGMTargetMultiplier = PickerSetting(
         value: 1.3,
         value: 1.3,

+ 24 - 23
FreeAPS/Sources/Modules/CGM/View/CGMRootView.swift

@@ -220,6 +220,7 @@ extension CGM {
                 .onAppear(perform: configureView)
                 .onAppear(perform: configureView)
                 .navigationTitle("CGM")
                 .navigationTitle("CGM")
                 .navigationBarTitleDisplayMode(.automatic)
                 .navigationBarTitleDisplayMode(.automatic)
+                .navigationBarItems(leading: displayClose ? Button("Close", action: state.hideModal) : nil)
                 .sheet(isPresented: $shouldDisplayHint) {
                 .sheet(isPresented: $shouldDisplayHint) {
                     SettingInputHintView(
                     SettingInputHintView(
                         hintDetent: $hintDetent,
                         hintDetent: $hintDetent,
@@ -229,29 +230,6 @@ extension CGM {
                         sheetTitle: "Help"
                         sheetTitle: "Help"
                     )
                     )
                 }
                 }
-                .sheet(isPresented: $setupCGM) {
-                    if let cgmFetchManager = state.cgmManager,
-                       let cgmManager = cgmFetchManager.cgmManager,
-                       state.cgmCurrent.type == cgmFetchManager.cgmGlucoseSourceType,
-                       state.cgmCurrent.id == cgmFetchManager.cgmGlucosePluginId
-                    {
-                        CGMSettingsView(
-                            cgmManager: cgmManager,
-                            bluetoothManager: state.provider.apsManager.bluetoothManager!,
-                            unit: state.settingsManager.settings.units,
-                            completionDelegate: state
-                        )
-                    } else {
-                        CGMSetupView(
-                            CGMType: state.cgmCurrent,
-                            bluetoothManager: state.provider.apsManager.bluetoothManager!,
-                            unit: state.settingsManager.settings.units,
-                            completionDelegate: state,
-                            setupDelegate: state,
-                            pluginCGMManager: self.state.pluginCGMManager
-                        )
-                    }
-                }
                 .onChange(of: setupCGM) { _, setupCGM in
                 .onChange(of: setupCGM) { _, setupCGM in
                     state.setupCGM = setupCGM
                     state.setupCGM = setupCGM
                 }
                 }
@@ -260,6 +238,29 @@ extension CGM {
                 }
                 }
                 .screenNavigation(self)
                 .screenNavigation(self)
             }
             }
+            .sheet(isPresented: $setupCGM) {
+                if let cgmFetchManager = state.cgmManager,
+                   let cgmManager = cgmFetchManager.cgmManager,
+                   state.cgmCurrent.type == cgmFetchManager.cgmGlucoseSourceType,
+                   state.cgmCurrent.id == cgmFetchManager.cgmGlucosePluginId
+                {
+                    CGMSettingsView(
+                        cgmManager: cgmManager,
+                        bluetoothManager: state.provider.apsManager.bluetoothManager!,
+                        unit: state.settingsManager.settings.units,
+                        completionDelegate: state
+                    )
+                } else {
+                    CGMSetupView(
+                        CGMType: state.cgmCurrent,
+                        bluetoothManager: state.provider.apsManager.bluetoothManager!,
+                        unit: state.settingsManager.settings.units,
+                        completionDelegate: state,
+                        setupDelegate: state,
+                        pluginCGMManager: self.state.pluginCGMManager
+                    )
+                }
+            }
         }
         }
     }
     }
 }
 }

+ 1 - 1
FreeAPS/Sources/Modules/DynamicSettings/View/DynamicSettingsRootView.swift

@@ -229,7 +229,7 @@ extension DynamicSettings {
                         miniHint: "Weight of 24-hr TDD against 10-day TDD.",
                         miniHint: "Weight of 24-hr TDD against 10-day TDD.",
                         verboseHint:
                         verboseHint:
                         VStack(alignment: .leading, spacing: 10) {
                         VStack(alignment: .leading, spacing: 10) {
-                            Text("Default: 65%").bold()
+                            Text("Default: 35%").bold()
                             Text(
                             Text(
                                 "This setting adjusts how much weight is given to your recent total daily insulin dose when calculating Dynamic ISF and Dynamic CR."
                                 "This setting adjusts how much weight is given to your recent total daily insulin dose when calculating Dynamic ISF and Dynamic CR."
                             )
                             )

+ 1 - 3
FreeAPS/Sources/Modules/Home/View/Chart/ChartElements/SelectionPopoverView.swift

@@ -70,9 +70,7 @@ struct SelectionPopoverView: ChartContent {
             .font(.body).padding(.bottom, 5)
             .font(.body).padding(.bottom, 5)
 
 
             HStack {
             HStack {
-                Text(units == .mgdL ? glucoseToDisplay.description : glucoseToDisplay.formattedAsMmolL)
-                    .bold()
-                    + Text(" \(units.rawValue)")
+                Text(glucoseToDisplay.description).bold() + Text(" \(units.rawValue)")
             }
             }
             .foregroundStyle(pointMarkColor)
             .foregroundStyle(pointMarkColor)
             .font(.body)
             .font(.body)

+ 18 - 18
FreeAPS/Sources/Modules/PumpConfig/View/PumpConfigRootView.swift

@@ -96,24 +96,6 @@ extension PumpConfig {
                 .navigationTitle("Insulin Pump")
                 .navigationTitle("Insulin Pump")
                 .navigationBarTitleDisplayMode(.automatic)
                 .navigationBarTitleDisplayMode(.automatic)
                 .navigationBarItems(leading: displayClose ? Button("Close", action: state.hideModal) : nil)
                 .navigationBarItems(leading: displayClose ? Button("Close", action: state.hideModal) : nil)
-                .sheet(isPresented: $state.setupPump) {
-                    if let pumpManager = state.provider.apsManager.pumpManager {
-                        PumpSettingsView(
-                            pumpManager: pumpManager,
-                            bluetoothManager: state.provider.apsManager.bluetoothManager!,
-                            completionDelegate: state,
-                            setupDelegate: state
-                        )
-                    } else {
-                        PumpSetupView(
-                            pumpType: state.setupPumpType,
-                            pumpInitialSettings: state.initialSettings,
-                            bluetoothManager: state.provider.apsManager.bluetoothManager!,
-                            completionDelegate: state,
-                            setupDelegate: state
-                        )
-                    }
-                }
                 .sheet(isPresented: $shouldDisplayHint) {
                 .sheet(isPresented: $shouldDisplayHint) {
                     SettingInputHintView(
                     SettingInputHintView(
                         hintDetent: $hintDetent,
                         hintDetent: $hintDetent,
@@ -130,6 +112,24 @@ extension PumpConfig {
                     Button("Pump Simulator") { state.addPump(.simulator) }
                     Button("Pump Simulator") { state.addPump(.simulator) }
                 } message: { Text("Select Pump Model") }
                 } message: { Text("Select Pump Model") }
             }
             }
+            .sheet(isPresented: $state.setupPump) {
+                if let pumpManager = state.provider.apsManager.pumpManager {
+                    PumpSettingsView(
+                        pumpManager: pumpManager,
+                        bluetoothManager: state.provider.apsManager.bluetoothManager!,
+                        completionDelegate: state,
+                        setupDelegate: state
+                    )
+                } else {
+                    PumpSetupView(
+                        pumpType: state.setupPumpType,
+                        pumpInitialSettings: state.initialSettings,
+                        bluetoothManager: state.provider.apsManager.bluetoothManager!,
+                        completionDelegate: state,
+                        setupDelegate: state
+                    )
+                }
+            }
         }
         }
     }
     }
 }
 }

+ 5 - 3
FreeAPS/Sources/Modules/Settings/SettingItems.swift

@@ -185,19 +185,21 @@ enum SettingItems {
             view: .userInterfaceSettings,
             view: .userInterfaceSettings,
             searchContents: [
             searchContents: [
                 "Show X-Axis Grid Lines",
                 "Show X-Axis Grid Lines",
-                "Show Y-Axis Grid Line",
+                "Show Y-Axis Grid Lines",
                 "Show Low and High Thresholds",
                 "Show Low and High Thresholds",
                 "Low Threshold",
                 "Low Threshold",
                 "High Threshold",
                 "High Threshold",
                 "X-Axis Interval Step",
                 "X-Axis Interval Step",
                 "Total Insulin Display Type",
                 "Total Insulin Display Type",
-                "Total Daily Dose",
-                "Total Insulin in Scope",
+                "Total Daily Dose (TDD)",
+                "Total Insulin in Scope (TINS)",
                 "Override HbA1c Unit",
                 "Override HbA1c Unit",
                 "Standing / Laying TIR Chart",
                 "Standing / Laying TIR Chart",
                 "Show Carbs Required Badge",
                 "Show Carbs Required Badge",
                 "Carbs Required Threshold",
                 "Carbs Required Threshold",
                 "Forecast Display Type",
                 "Forecast Display Type",
+                "Cone",
+                "Lines",
                 "Trio Color Scheme",
                 "Trio Color Scheme",
                 "Glucose Color Scheme"
                 "Glucose Color Scheme"
             ],
             ],

+ 1 - 1
FreeAPS/Sources/Services/Network/Nightscout/NightscoutManager.swift

@@ -192,7 +192,7 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
             .sink { [weak self] _ in
             .sink { [weak self] _ in
                 guard let self = self else { return }
                 guard let self = self else { return }
                 Task {
                 Task {
-                    await self.uploadOverrides()
+                    await self.uploadTempTargets()
 
 
                     // Post a notification indicating that the upload has finished and that we can end the background task in the TempTargetPresetsIntentRequest
                     // Post a notification indicating that the upload has finished and that we can end the background task in the TempTargetPresetsIntentRequest
                     Foundation.NotificationCenter.default.post(name: .didUpdateTempTargetConfiguration, object: nil)
                     Foundation.NotificationCenter.default.post(name: .didUpdateTempTargetConfiguration, object: nil)

+ 3 - 3
FreeAPS/Sources/Shortcuts/TempPresets/ApplyTempPresetIntent.swift

@@ -54,7 +54,7 @@ struct ApplyTempPresetIntent: AppIntent {
             let displayName: String = presetToApply.name
             let displayName: String = presetToApply.name
             if confirmBeforeApplying {
             if confirmBeforeApplying {
                 try await requestConfirmation(
                 try await requestConfirmation(
-                    result: .result(dialog: "Confirm to apply temporary target '\(displayName)'")
+                    result: .result(dialog: "Confirm to apply Temporary Target '\(displayName)'")
                 )
                 )
             }
             }
 
 
@@ -62,7 +62,7 @@ struct ApplyTempPresetIntent: AppIntent {
                 return .result(
                 return .result(
                     dialog: IntentDialog(
                     dialog: IntentDialog(
                         LocalizedStringResource(
                         LocalizedStringResource(
-                            "TempTarget '\(presetToApply.name)' applied",
+                            "Temporary Target '\(presetToApply.name)' applied",
                             table: "ShortcutsDetail"
                             table: "ShortcutsDetail"
                         )
                         )
                     )
                     )
@@ -71,7 +71,7 @@ struct ApplyTempPresetIntent: AppIntent {
                 return .result(
                 return .result(
                     dialog: IntentDialog(
                     dialog: IntentDialog(
                         LocalizedStringResource(
                         LocalizedStringResource(
-                            "TempTarget '\(presetToApply.name)' failed",
+                            "Temporary Target '\(presetToApply.name)' failed",
                             table: "ShortcutsDetail"
                             table: "ShortcutsDetail"
                         )
                         )
                     )
                     )

+ 20 - 0
FreeAPS/Sources/Shortcuts/TempPresets/TempPresetsIntentRequest.swift

@@ -132,6 +132,26 @@ final class TempPresetsIntentRequest: BaseIntentsRequest {
 
 
                 // Await the notification
                 // Await the notification
                 print("Waiting for notification...")
                 print("Waiting for notification...")
+
+                guard let tempTargetDate = tempTargetObject.date, let tempTarget = tempTargetObject.target,
+                      let tempTargetDuration = tempTargetObject.duration else { return false }
+
+                let tempTargetToStoreAsJSON = TempTarget(
+                    name: tempTargetObject.name,
+                    createdAt: tempTargetDate,
+                    targetTop: tempTarget as Decimal,
+                    targetBottom: tempTarget as Decimal,
+                    duration: tempTargetDuration as Decimal,
+                    enteredBy: TempTarget.local,
+                    reason: TempTarget.custom,
+                    isPreset: tempTargetObject.isPreset,
+                    enabled: tempTargetObject.enabled,
+                    halfBasalTarget: tempTargetObject.halfBasalTarget as Decimal?
+                )
+
+                // Save the temp targets to JSON so that they get used by oref
+                tempTargetsStorage.saveTempTargetsToStorage([tempTargetToStoreAsJSON])
+
                 await awaitNotification(.didUpdateTempTargetConfiguration)
                 await awaitNotification(.didUpdateTempTargetConfiguration)
                 print("Notification received, continuing...")
                 print("Notification received, continuing...")