Skip to content

Commit c859818

Browse files
committed
Fix for preferences model
1 parent ea631cb commit c859818

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

basal_lock/basal_lock_2002.patch

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Submodule Loop e8c9584..045ead4:
1+
Submodule Loop 674d123..c484fe7:
22
diff --git a/Loop/Loop.xcodeproj/project.pbxproj b/Loop/Loop.xcodeproj/project.pbxproj
33
index 11819516..a22646b3 100644
44
--- a/Loop/Loop.xcodeproj/project.pbxproj
@@ -69,6 +69,62 @@ index 63164e69..f6accc52 100644
6969
)
7070
dosingRecommendation = AutomaticDoseRecommendation(basalAdjustment: temp)
7171
}
72+
diff --git a/Loop/Loop/Models/Preferences.swift b/Loop/Loop/Models/Preferences.swift
73+
new file mode 100644
74+
index 00000000..dc9150f8
75+
--- /dev/null
76+
+++ b/Loop/Loop/Models/Preferences.swift
77+
@@ -0,0 +1,50 @@
78+
+//
79+
+// Preferences.swift
80+
+// Loop
81+
+//
82+
+// Created by Jonas Björkert on 2024-02-25.
83+
+// Copyright © 2024 LoopKit Authors. All rights reserved.
84+
+//
85+
+
86+
+import Foundation
87+
+import LoopKit
88+
+import HealthKit
89+
+
90+
+struct Preferences: PreferencesProvider {
91+
+
92+
+ static var shared = Preferences()
93+
+
94+
+ private init() {}
95+
+
96+
+ // Basal Lock Threshold
97+
+ var basalLockThreshold: HKQuantity {
98+
+ get {
99+
+ let key = "basalLockThreshold"
100+
+ if let value = UserDefaults.standard.value(forKey: key) as? Double {
101+
+ return HKQuantity(unit: .milligramsPerDeciliter, doubleValue: value)
102+
+ } else {
103+
+ return HKQuantity(unit: .milligramsPerDeciliter, doubleValue: 250)
104+
+ }
105+
+ }
106+
+ set {
107+
+ let key = "basalLockThreshold"
108+
+ let value = newValue.doubleValue(for: .milligramsPerDeciliter)
109+
+ UserDefaults.standard.set(value, forKey: key)
110+
+ }
111+
+ }
112+
+
113+
+ // Basal Lock Enabled
114+
+ var isBasalLockEnabled: Bool {
115+
+ get {
116+
+ let key = "isBasalLockEnabled"
117+
+ if UserDefaults.standard.object(forKey: key) == nil {
118+
+ return false
119+
+ }
120+
+ return UserDefaults.standard.bool(forKey: key)
121+
+ }
122+
+ set {
123+
+ let key = "isBasalLockEnabled"
124+
+ UserDefaults.standard.set(newValue, forKey: key)
125+
+ }
126+
+ }
127+
+}
72128
diff --git a/Loop/Loop/Views/SettingsView.swift b/Loop/Loop/Views/SettingsView.swift
73129
index 74045900..f2a41195 100644
74130
--- a/Loop/Loop/Views/SettingsView.swift
@@ -117,7 +173,7 @@ index 74045900..f2a41195 100644
117173
private var cgmChoices: [ActionSheet.Button] {
118174
var result = viewModel.cgmManagerSettingsViewModel.availableDevices
119175
.sorted(by: {$0.localizedTitle < $1.localizedTitle})
120-
Submodule LoopKit 3a34b64..49a6dea:
176+
Submodule LoopKit 77793ca..c6d1a1a:
121177
diff --git a/LoopKit/LoopKit.xcodeproj/project.pbxproj b/LoopKit/LoopKit.xcodeproj/project.pbxproj
122178
index eec949bd..7ec12a27 100644
123179
--- a/LoopKit/LoopKit.xcodeproj/project.pbxproj

0 commit comments

Comments
 (0)