Skip to content

Commit

Permalink
Loop-5057 Preset Editing (#752)
Browse files Browse the repository at this point in the history
* Preset editing

* Preset editing updates

* Add duration editing

* Add duration for legacy workout override
  • Loading branch information
ps2 authored Feb 4, 2025
1 parent a364437 commit 802506a
Show file tree
Hide file tree
Showing 13 changed files with 836 additions and 69 deletions.
12 changes: 12 additions & 0 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@
C138C6F82C1B8A2C00F08F1A /* GlucoseCondition.swift in Sources */ = {isa = PBXBuildFile; fileRef = C138C6F72C1B8A2C00F08F1A /* GlucoseCondition.swift */; };
C13DA2B024F6C7690098BB29 /* UIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C13DA2AF24F6C7690098BB29 /* UIViewController.swift */; };
C148CEE724FD91BD00711B3B /* DeliveryUncertaintyAlertManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C148CEE624FD91BD00711B3B /* DeliveryUncertaintyAlertManager.swift */; };
C14F68C92D4AC54300BC3B8D /* DurationPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C14F68C82D4AC54000BC3B8D /* DurationPickerView.swift */; };
C152B9F52C9C7D4A00ACBC06 /* AutomationHistoryEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = C152B9F42C9C7D4A00ACBC06 /* AutomationHistoryEntry.swift */; };
C152B9F72C9C7EF100ACBC06 /* AutomationHistoryEntryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C152B9F62C9C7EF100ACBC06 /* AutomationHistoryEntryTests.swift */; };
C159C82F286787EF00A86EC0 /* LoopKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C159C82E286787EF00A86EC0 /* LoopKit.framework */; };
Expand All @@ -445,6 +446,8 @@
C16575732538AFF6004AE16E /* CGMStalenessMonitorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16575722538AFF6004AE16E /* CGMStalenessMonitorTests.swift */; };
C16575752539FD60004AE16E /* LoopCoreConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16575742539FD60004AE16E /* LoopCoreConstants.swift */; };
C16575762539FEF3004AE16E /* LoopCoreConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16575742539FD60004AE16E /* LoopCoreConstants.swift */; };
C16971DF2D10C21C001B7DF6 /* EditPresetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16971DE2D10C216001B7DF6 /* EditPresetView.swift */; };
C16971F92D1231B5001B7DF6 /* EditPresetRangeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16971F82D1231AB001B7DF6 /* EditPresetRangeView.swift */; };
C16B983E26B4893300256B05 /* DoseEnactor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16B983D26B4893300256B05 /* DoseEnactor.swift */; };
C16B984026B4898800256B05 /* DoseEnactorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16B983F26B4898800256B05 /* DoseEnactorTests.swift */; };
C16DA84222E8E112008624C2 /* PluginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16DA84122E8E112008624C2 /* PluginManager.swift */; };
Expand Down Expand Up @@ -1391,6 +1394,7 @@
C13DA2AF24F6C7690098BB29 /* UIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewController.swift; sourceTree = "<group>"; };
C148CEE624FD91BD00711B3B /* DeliveryUncertaintyAlertManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeliveryUncertaintyAlertManager.swift; sourceTree = "<group>"; };
C14952142995822A0095AA84 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/InfoPlist.strings; sourceTree = "<group>"; };
C14F68C82D4AC54000BC3B8D /* DurationPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DurationPickerView.swift; sourceTree = "<group>"; };
C152B9F42C9C7D4A00ACBC06 /* AutomationHistoryEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutomationHistoryEntry.swift; sourceTree = "<group>"; };
C152B9F62C9C7EF100ACBC06 /* AutomationHistoryEntryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutomationHistoryEntryTests.swift; sourceTree = "<group>"; };
C155A8F32986396E009BD257 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
Expand All @@ -1407,6 +1411,8 @@
C16575702538A36B004AE16E /* CGMStalenessMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGMStalenessMonitor.swift; sourceTree = "<group>"; };
C16575722538AFF6004AE16E /* CGMStalenessMonitorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGMStalenessMonitorTests.swift; sourceTree = "<group>"; };
C16575742539FD60004AE16E /* LoopCoreConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoopCoreConstants.swift; sourceTree = "<group>"; };
C16971DE2D10C216001B7DF6 /* EditPresetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditPresetView.swift; sourceTree = "<group>"; };
C16971F82D1231AB001B7DF6 /* EditPresetRangeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditPresetRangeView.swift; sourceTree = "<group>"; };
C16B983D26B4893300256B05 /* DoseEnactor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoseEnactor.swift; sourceTree = "<group>"; };
C16B983F26B4898800256B05 /* DoseEnactorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoseEnactorTests.swift; sourceTree = "<group>"; };
C16DA84122E8E112008624C2 /* PluginManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PluginManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2494,6 +2500,9 @@
84E8BBAF2CC979300078E6CF /* Presets */ = {
isa = PBXGroup;
children = (
C14F68C82D4AC54000BC3B8D /* DurationPickerView.swift */,
C16971F82D1231AB001B7DF6 /* EditPresetRangeView.swift */,
C16971DE2D10C216001B7DF6 /* EditPresetView.swift */,
84E8BBC92CCA16290078E6CF /* PresetsView.swift */,
84FA9D322CF7FD0D004162B4 /* PresetsHistoryView.swift */,
84E8BBB02CC9793C0078E6CF /* PresetsTrainingView.swift */,
Expand Down Expand Up @@ -3496,6 +3505,7 @@
C1F2075C26D6F9B0007AB7EB /* AppExpirationAlerter.swift in Sources */,
B4FEEF7D24B8A71F00A8DF9B /* DeviceDataManager+DeviceStatus.swift in Sources */,
142CB7592A60BF2E0075748A /* EditMode.swift in Sources */,
C14F68C92D4AC54300BC3B8D /* DurationPickerView.swift in Sources */,
14C9706E2C5A83AF00E8A01B /* IOBChartView.swift in Sources */,
E95D380324EADF36005E2F50 /* CarbStoreProtocol.swift in Sources */,
84E8BBCE2CCA1E070078E6CF /* PresetsTrainingCard.swift in Sources */,
Expand Down Expand Up @@ -3530,6 +3540,7 @@
84E8BBC62CC9BF830078E6CF /* PercentPickerView.swift in Sources */,
84F20DFB2D0A56CB0089DF02 /* PresetStatsView.swift in Sources */,
1DA649A7244126CD00F61E75 /* UserNotificationAlertScheduler.swift in Sources */,
C16971F92D1231B5001B7DF6 /* EditPresetRangeView.swift in Sources */,
439A7942211F631C0041B75F /* RootNavigationController.swift in Sources */,
149A28BD2A853E6C00052EDF /* CarbEntryView.swift in Sources */,
4F11D3C020DCBEEC006E072C /* GlucoseBackfillRequestUserInfo.swift in Sources */,
Expand Down Expand Up @@ -3695,6 +3706,7 @@
DDC389FE2A2C4C830066E2E8 /* GlucoseBasedApplicationFactorSelectionView.swift in Sources */,
A9C62D842331700E00535612 /* DiagnosticLog+Subsystem.swift in Sources */,
895FE0952201234000FCF18A /* OverrideSelectionViewController.swift in Sources */,
C16971DF2D10C21C001B7DF6 /* EditPresetView.swift in Sources */,
C1EF747228D6A44A00C8C083 /* CrashRecoveryManager.swift in Sources */,
A9F66FC3247F451500096EA7 /* UIDevice+Loop.swift in Sources */,
84E8BBCA2CCA16290078E6CF /* PresetsView.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions Loop/Managers/DeviceDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,7 @@ extension DeviceDataManager: TherapySettingsViewModelDelegate {
settings.glucoseTargetRangeSchedule = therapySettings.glucoseTargetRangeSchedule
settings.preMealTargetRange = therapySettings.correctionRangeOverrides?.preMeal
settings.legacyWorkoutTargetRange = therapySettings.correctionRangeOverrides?.workout
settings.legacyWorkoutDuration = therapySettings.correctionRangeOverrides?.workoutDuration
settings.suspendThreshold = therapySettings.suspendThreshold
settings.basalRateSchedule = therapySettings.basalRateSchedule
settings.maximumBasalRatePerHour = therapySettings.maximumBasalRatePerHour
Expand Down
27 changes: 17 additions & 10 deletions Loop/Managers/SettingsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class SettingsManager {
glucoseTargetRangeSchedule: newLoopSettings.glucoseTargetRangeSchedule,
preMealTargetRange: newLoopSettings.preMealTargetRange,
workoutTargetRange: newLoopSettings.legacyWorkoutTargetRange,
workoutDefaultDuration: newLoopSettings.legacyWorkoutDuration,
overridePresets: newLoopSettings.overridePresets,
maximumBasalRatePerHour: newLoopSettings.maximumBasalRatePerHour,
maximumBolus: newLoopSettings.maximumBolus,
Expand Down Expand Up @@ -295,16 +296,22 @@ extension SettingsManager {
public var therapySettings: TherapySettings {
get {
let settings = self.settings
return TherapySettings(glucoseTargetRangeSchedule: settings.glucoseTargetRangeSchedule,
correctionRangeOverrides: CorrectionRangeOverrides(preMeal: settings.preMealTargetRange, workout: settings.workoutTargetRange),
overridePresets: settings.overridePresets,
maximumBasalRatePerHour: settings.maximumBasalRatePerHour,
maximumBolus: settings.maximumBolus,
suspendThreshold: settings.suspendThreshold,
insulinSensitivitySchedule: settings.insulinSensitivitySchedule,
carbRatioSchedule: settings.carbRatioSchedule,
basalRateSchedule: settings.basalRateSchedule,
defaultRapidActingModel: settings.defaultRapidActingModel?.presetForRapidActingInsulin)
return TherapySettings(
glucoseTargetRangeSchedule: settings.glucoseTargetRangeSchedule,
correctionRangeOverrides: CorrectionRangeOverrides(
preMeal: settings.preMealTargetRange,
workout: settings.workoutTargetRange,
workoutDuration: settings.workoutDefaultDuration
),
overridePresets: settings.overridePresets,
maximumBasalRatePerHour: settings.maximumBasalRatePerHour,
maximumBolus: settings.maximumBolus,
suspendThreshold: settings.suspendThreshold,
insulinSensitivitySchedule: settings.insulinSensitivitySchedule,
carbRatioSchedule: settings.carbRatioSchedule,
basalRateSchedule: settings.basalRateSchedule,
defaultRapidActingModel: settings.defaultRapidActingModel?.presetForRapidActingInsulin
)
}

set {
Expand Down
Loading

0 comments on commit 802506a

Please sign in to comment.