Skip to content

Commit a3cc9dd

Browse files
authored
[LOOP-2385] Propagating glucose unit changes (#357)
* therapy settings view model created in settings view model to allow propagation of glucose unit changes * naming update to displayGlucoseUnit
1 parent 07a00a0 commit a3cc9dd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Loop/View Models/SettingsViewModel.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public class SettingsViewModel: ObservableObject {
8484
let syncPumpSchedule: (() -> PumpManager.SyncSchedule?)?
8585
let sensitivityOverridesEnabled: Bool
8686
let supportInfoProvider: SupportInfoProvider
87-
87+
8888
@Published var isClosedLoopAllowed: Bool
8989

9090
var closedLoopPreference: Bool {
@@ -126,7 +126,7 @@ public class SettingsViewModel: ObservableObject {
126126
self.supportInfoProvider = supportInfoProvider
127127
self.availableSupports = availableSupports
128128
self.delegate = delegate
129-
129+
130130
// This strangeness ensures the composed ViewModels' (ObservableObjects') changes get reported to this ViewModel (ObservableObject)
131131
notificationsCriticalAlertPermissionsViewModel.objectWillChange.sink { [weak self] in
132132
self?.objectWillChange.send()
@@ -144,6 +144,5 @@ public class SettingsViewModel: ObservableObject {
144144
isClosedLoopAllowed
145145
.assign(to: \.isClosedLoopAllowed, on: self)
146146
.store(in: &cancellables)
147-
148147
}
149148
}

Loop/Views/SettingsView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import SwiftUI
1313
import HealthKit
1414

1515
public struct SettingsView: View {
16+
@EnvironmentObject private var displayGlucoseUnitObservable: DisplayGlucoseUnitObservable
1617
@Environment(\.dismiss) private var dismiss
1718
@Environment(\.appName) private var appName
1819
@Environment(\.guidanceColors) private var guidanceColors
@@ -121,6 +122,7 @@ extension SettingsView {
121122
syncPumpSchedule: self.viewModel.syncPumpSchedule,
122123
chartColors: .primary,
123124
didSave: self.viewModel.didSave))
125+
.environmentObject(displayGlucoseUnitObservable)
124126
.environment(\.dismiss, self.dismiss)
125127
.environment(\.appName, self.appName)
126128
.environment(\.carbTintColor, self.carbTintColor)

0 commit comments

Comments
 (0)