Skip to content

Commit f7a4d17

Browse files
authored
Nate/feature/LOOP-1113/status bar reorder with style (#118)
* First pass at adding the CGM status view to the status bar * initial pass at the pump status * clean up * changing HUD provided protocol from BaseHUDView -> LevelHUDView * responses to PR comments * tapping add cgm/pump starts the workflow * updates based on design feedback * color change * refactor to just 1 pump manager provider HUD view * responses to PR comments * added missing cancel button * do not forget to add the cgm simulator * manager selection refactor
1 parent d693f47 commit f7a4d17

20 files changed

+1375
-298
lines changed

Common/Models/PumpManagerUI.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ private let managersByIdentifier: [String: PumpManagerUI.Type] = staticPumpManag
1414
map[Type.managerIdentifier] = Type
1515
}
1616

17-
typealias PumpManagerHUDViewsRawValue = [String: Any]
17+
typealias PumpManagerHUDViewRawValue = [String: Any]
1818

19-
func PumpManagerHUDViewsFromRawValue(_ rawValue: PumpManagerHUDViewsRawValue, pluginManager: PluginManager) -> [BaseHUDView]? {
19+
func PumpManagerHUDViewFromRawValue(_ rawValue: PumpManagerHUDViewRawValue, pluginManager: PluginManager) -> LevelHUDView? {
2020
guard
2121
let identifier = rawValue["managerIdentifier"] as? String,
22-
let rawState = rawValue["hudProviderViews"] as? HUDProvider.HUDViewsRawState,
22+
let rawState = rawValue["hudProviderViews"] as? HUDProvider.HUDViewRawState,
2323
let manager = pluginManager.getPumpManagerTypeByIdentifier(identifier) ?? staticPumpManagersByIdentifier[identifier] as? PumpManagerUI.Type else
2424
{
2525
return nil
2626
}
27-
return manager.createHUDViews(rawValue: rawState)
27+
return manager.createHUDView(rawValue: rawState)
2828
}
2929

30-
func PumpManagerHUDViewsRawValueFromHUDProvider(_ hudProvider: HUDProvider) -> PumpManagerHUDViewsRawValue {
30+
func PumpManagerHUDViewRawValueFromHUDProvider(_ hudProvider: HUDProvider) -> PumpManagerHUDViewRawValue {
3131
return [
3232
"managerIdentifier": hudProvider.managerIdentifier,
33-
"hudProviderViews": hudProvider.hudViewsRawState
33+
"hudProviderView": hudProvider.hudViewRawState
3434
]
3535
}

Common/Models/StatusExtensionContext.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,25 +152,25 @@ extension PredictedGlucoseContext: RawRepresentable {
152152
}
153153
}
154154

155-
struct PumpManagerHUDViewsContext: RawRepresentable {
155+
struct PumpManagerHUDViewContext: RawRepresentable {
156156
typealias RawValue = [String: Any]
157157

158-
let pumpManagerHUDViewsRawValue: PumpManagerHUDViewsRawValue
158+
let pumpManagerHUDViewRawValue: PumpManagerHUDViewRawValue
159159

160-
init(pumpManagerHUDViewsRawValue: PumpManagerHUDViewsRawValue) {
161-
self.pumpManagerHUDViewsRawValue = pumpManagerHUDViewsRawValue
160+
init(pumpManagerHUDViewRawValue: PumpManagerHUDViewRawValue) {
161+
self.pumpManagerHUDViewRawValue = pumpManagerHUDViewRawValue
162162
}
163163

164164
init?(rawValue: RawValue) {
165-
if let pumpManagerHUDViewsRawValue = rawValue["pumpManagerHUDViewsRawValue"] as? PumpManagerHUDViewsRawValue {
166-
self.pumpManagerHUDViewsRawValue = pumpManagerHUDViewsRawValue
165+
if let pumpManagerHUDViewRawValue = rawValue["pumpManagerHUDViewRawValue"] as? PumpManagerHUDViewRawValue {
166+
self.pumpManagerHUDViewRawValue = pumpManagerHUDViewRawValue
167167
} else {
168168
return nil
169169
}
170170
}
171171

172172
var rawValue: RawValue {
173-
return ["pumpManagerHUDViewsRawValue": pumpManagerHUDViewsRawValue]
173+
return ["pumpManagerHUDViewRawValue": pumpManagerHUDViewRawValue]
174174
}
175175
}
176176

@@ -184,7 +184,7 @@ struct StatusExtensionContext: RawRepresentable {
184184
var batteryPercentage: Double?
185185
var reservoirCapacity: Double?
186186
var sensor: SensorDisplayableContext?
187-
var pumpManagerHUDViewsContext: PumpManagerHUDViewsContext?
187+
var pumpManagerHUDViewContext: PumpManagerHUDViewContext?
188188

189189
init() { }
190190

@@ -209,8 +209,8 @@ struct StatusExtensionContext: RawRepresentable {
209209
sensor = SensorDisplayableContext(rawValue: rawValue)
210210
}
211211

212-
if let rawPumpManagerHUDViewsContext = rawValue["pumpManagerHUDViewsContext"] as? PumpManagerHUDViewsContext.RawValue {
213-
pumpManagerHUDViewsContext = PumpManagerHUDViewsContext(rawValue: rawPumpManagerHUDViewsContext)
212+
if let rawPumpManagerHUDViewContext = rawValue["pumpManagerHUDViewContext"] as? PumpManagerHUDViewContext.RawValue {
213+
pumpManagerHUDViewContext = PumpManagerHUDViewContext(rawValue: rawPumpManagerHUDViewContext)
214214
}
215215
}
216216

@@ -225,7 +225,7 @@ struct StatusExtensionContext: RawRepresentable {
225225
raw["batteryPercentage"] = batteryPercentage
226226
raw["reservoirCapacity"] = reservoirCapacity
227227
raw["sensor"] = sensor?.rawValue
228-
raw["pumpManagerHUDViewsContext"] = pumpManagerHUDViewsContext?.rawValue
228+
raw["pumpManagerHUDViewContext"] = pumpManagerHUDViewContext?.rawValue
229229

230230
return raw
231231
}

Loop Status Extension/StatusViewController.swift

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,17 @@ class StatusViewController: UIViewController, NCWidgetProviding {
206206
return
207207
}
208208

209-
let hudViews: [BaseHUDView]
210-
211-
if let hudViewsContext = context.pumpManagerHUDViewsContext,
212-
let contextHUDViews = PumpManagerHUDViewsFromRawValue(hudViewsContext.pumpManagerHUDViewsRawValue, pluginManager: self.pluginManager)
209+
let pumpManagerHUDView: LevelHUDView
210+
if let hudViewContext = context.pumpManagerHUDViewContext,
211+
let contextHUDView = PumpManagerHUDViewFromRawValue(hudViewContext.pumpManagerHUDViewRawValue, pluginManager: self.pluginManager)
213212
{
214-
hudViews = contextHUDViews
213+
pumpManagerHUDView = contextHUDView
215214
} else {
216-
hudViews = [ReservoirVolumeHUDView.instantiate(), BatteryLevelHUDView.instantiate()]
215+
pumpManagerHUDView = ReservoirVolumeHUDView.instantiate()
217216
}
218-
217+
pumpManagerHUDView.stateColors = .pumpStatus
219218
self.hudView.removePumpManagerProvidedViews()
220-
for view in hudViews {
221-
view.stateColors = .pumpStatus
222-
self.hudView.addHUDView(view)
223-
}
219+
self.hudView.addHUDView(pumpManagerHUDView)
224220

225221
if let netBasal = context.netBasal {
226222
self.hudView.basalRateHUD.setNetBasalRate(netBasal.rate, percent: netBasal.percentage, at: netBasal.start)

Loop.xcodeproj/project.pbxproj

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,15 @@
424424
A9F703732489BC8500C98AD8 /* CarbStore+SimulatedCoreData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F703722489BC8500C98AD8 /* CarbStore+SimulatedCoreData.swift */; };
425425
A9F703752489C9A000C98AD8 /* GlucoseStore+SimulatedCoreData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F703742489C9A000C98AD8 /* GlucoseStore+SimulatedCoreData.swift */; };
426426
A9F703772489D8AA00C98AD8 /* PersistentDeviceLog+SimulatedCoreData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F703762489D8AA00C98AD8 /* PersistentDeviceLog+SimulatedCoreData.swift */; };
427+
B48B0BAC24900093009A48DE /* PumpStatusHUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B48B0BAB24900093009A48DE /* PumpStatusHUDView.swift */; };
428+
B4E96D4B248A6B6E002DABAD /* DeviceStatusHUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E96D4A248A6B6E002DABAD /* DeviceStatusHUDView.swift */; };
429+
B4E96D4F248A6E20002DABAD /* CGMStatusHUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E96D4E248A6E20002DABAD /* CGMStatusHUDView.swift */; };
430+
B4E96D53248A7386002DABAD /* GlucoseValueHUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E96D52248A7386002DABAD /* GlucoseValueHUDView.swift */; };
431+
B4E96D55248A7509002DABAD /* GlucoseTrendHUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E96D54248A7509002DABAD /* GlucoseTrendHUDView.swift */; };
432+
B4E96D57248A7B0F002DABAD /* AlertStatusHUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E96D56248A7B0F002DABAD /* AlertStatusHUDView.swift */; };
433+
B4E96D59248A7F9A002DABAD /* AlertStatusHUDView.xib in Resources */ = {isa = PBXBuildFile; fileRef = B4E96D58248A7F9A002DABAD /* AlertStatusHUDView.xib */; };
434+
B4E96D5B248A8229002DABAD /* StatusBarHUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E96D5A248A8229002DABAD /* StatusBarHUDView.swift */; };
435+
B4E96D5D248A82A2002DABAD /* StatusBarHUDView.xib in Resources */ = {isa = PBXBuildFile; fileRef = B4E96D5C248A82A2002DABAD /* StatusBarHUDView.xib */; };
427436
C10B28461EA9BA5E006EA1FC /* far_future_high_bg_forecast.json in Resources */ = {isa = PBXBuildFile; fileRef = C10B28451EA9BA5E006EA1FC /* far_future_high_bg_forecast.json */; };
428437
C11C87DE1E21EAAD00BB71D3 /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F526D5E1DF2459000A04910 /* HKUnit.swift */; };
429438
C1201E2C23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1201E2B23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift */; };
@@ -1141,6 +1150,15 @@
11411150
A9F703722489BC8500C98AD8 /* CarbStore+SimulatedCoreData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CarbStore+SimulatedCoreData.swift"; sourceTree = "<group>"; };
11421151
A9F703742489C9A000C98AD8 /* GlucoseStore+SimulatedCoreData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GlucoseStore+SimulatedCoreData.swift"; sourceTree = "<group>"; };
11431152
A9F703762489D8AA00C98AD8 /* PersistentDeviceLog+SimulatedCoreData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PersistentDeviceLog+SimulatedCoreData.swift"; sourceTree = "<group>"; };
1153+
B48B0BAB24900093009A48DE /* PumpStatusHUDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PumpStatusHUDView.swift; sourceTree = "<group>"; };
1154+
B4E96D4A248A6B6E002DABAD /* DeviceStatusHUDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceStatusHUDView.swift; sourceTree = "<group>"; };
1155+
B4E96D4E248A6E20002DABAD /* CGMStatusHUDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGMStatusHUDView.swift; sourceTree = "<group>"; };
1156+
B4E96D52248A7386002DABAD /* GlucoseValueHUDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlucoseValueHUDView.swift; sourceTree = "<group>"; };
1157+
B4E96D54248A7509002DABAD /* GlucoseTrendHUDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlucoseTrendHUDView.swift; sourceTree = "<group>"; };
1158+
B4E96D56248A7B0F002DABAD /* AlertStatusHUDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertStatusHUDView.swift; sourceTree = "<group>"; };
1159+
B4E96D58248A7F9A002DABAD /* AlertStatusHUDView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AlertStatusHUDView.xib; sourceTree = "<group>"; };
1160+
B4E96D5A248A8229002DABAD /* StatusBarHUDView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusBarHUDView.swift; sourceTree = "<group>"; };
1161+
B4E96D5C248A82A2002DABAD /* StatusBarHUDView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = StatusBarHUDView.xib; sourceTree = "<group>"; };
11441162
C10B28451EA9BA5E006EA1FC /* far_future_high_bg_forecast.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = far_future_high_bg_forecast.json; sourceTree = "<group>"; };
11451163
C1201E2B23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchContextRequestUserInfo.swift; sourceTree = "<group>"; };
11461164
C125F31A22FE7CE200FD0545 /* copy-frameworks.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "copy-frameworks.sh"; sourceTree = "<group>"; };
@@ -1798,6 +1816,8 @@
17981816
4F75288E1DFE1DC600C322D6 /* Info.plist */,
17991817
4F2C15941E09BF3C00E160D4 /* HUDView.xib */,
18001818
4F2C15961E09E94E00E160D4 /* HUDAssets.xcassets */,
1819+
B4E96D58248A7F9A002DABAD /* AlertStatusHUDView.xib */,
1820+
B4E96D5C248A82A2002DABAD /* StatusBarHUDView.xib */,
18011821
);
18021822
path = LoopUI;
18031823
sourceTree = "<group>";
@@ -1819,6 +1839,13 @@
18191839
438DADC71CDE8F8B007697A5 /* LoopStateView.swift */,
18201840
1DA46B5F2492E2E300D71A63 /* NotificationsCriticalAlertPermissionsView.swift */,
18211841
1DA46B612492E37A00D71A63 /* NotificationsCriticalAlertPermissionsViewModel.swift */,
1842+
B4E96D4A248A6B6E002DABAD /* DeviceStatusHUDView.swift */,
1843+
B4E96D4E248A6E20002DABAD /* CGMStatusHUDView.swift */,
1844+
B4E96D52248A7386002DABAD /* GlucoseValueHUDView.swift */,
1845+
B4E96D54248A7509002DABAD /* GlucoseTrendHUDView.swift */,
1846+
B4E96D56248A7B0F002DABAD /* AlertStatusHUDView.swift */,
1847+
B4E96D5A248A8229002DABAD /* StatusBarHUDView.swift */,
1848+
B48B0BAB24900093009A48DE /* PumpStatusHUDView.swift */,
18221849
);
18231850
path = Views;
18241851
sourceTree = "<group>";
@@ -2593,6 +2620,8 @@
25932620
7D70764A1FE06EE1004AC8EA /* Localizable.strings in Resources */,
25942621
7D7076451FE06EE0004AC8EA /* InfoPlist.strings in Resources */,
25952622
4F2C15951E09BF3C00E160D4 /* HUDView.xib in Resources */,
2623+
B4E96D5D248A82A2002DABAD /* StatusBarHUDView.xib in Resources */,
2624+
B4E96D59248A7F9A002DABAD /* AlertStatusHUDView.xib in Resources */,
25962625
);
25972626
runOnlyForDeploymentPostprocessing = 0;
25982627
};
@@ -3157,6 +3186,8 @@
31573186
4326BA641F3A44D9007CCAD4 /* ChartLineModel.swift in Sources */,
31583187
43FCEEB9221BCF790013DD30 /* GlucoseChart.swift in Sources */,
31593188
4374B5F0209D857E00D17AA8 /* OSLog.swift in Sources */,
3189+
B4E96D4F248A6E20002DABAD /* CGMStatusHUDView.swift in Sources */,
3190+
B4E96D4B248A6B6E002DABAD /* DeviceStatusHUDView.swift in Sources */,
31603191
43FCEEB3221BC3B60013DD30 /* DoseChart.swift in Sources */,
31613192
4F7528AA1DFE215100C322D6 /* HKUnit.swift in Sources */,
31623193
1DA46B602492E2E300D71A63 /* NotificationsCriticalAlertPermissionsView.swift in Sources */,
@@ -3172,6 +3203,7 @@
31723203
1DA46B622492E37A00D71A63 /* NotificationsCriticalAlertPermissionsViewModel.swift in Sources */,
31733204
4FB76FB31E8C3EE400B39636 /* ChartAxisValueDoubleLog.swift in Sources */,
31743205
43F1C31A1F5DC87700395429 /* ChartPoint.swift in Sources */,
3206+
B4E96D5B248A8229002DABAD /* StatusBarHUDView.swift in Sources */,
31753207
4F7528A11DFE200B00C322D6 /* BasalStateView.swift in Sources */,
31763208
4F20AE631E6B87B100D07A06 /* ChartContainerView.swift in Sources */,
31773209
43FCEEAB221A61B40013DD30 /* IOBChart.swift in Sources */,
@@ -3180,13 +3212,17 @@
31803212
43FCEEBB22211C860013DD30 /* CarbEffectChart.swift in Sources */,
31813213
4F7528A01DFE1F9D00C322D6 /* LoopStateView.swift in Sources */,
31823214
1D8E1F982492DC4E00F3D1EB /* LoopNotificationsView.swift in Sources */,
3215+
B48B0BAC24900093009A48DE /* PumpStatusHUDView.swift in Sources */,
31833216
4FB76FCE1E8C835D00B39636 /* ChartColorPalette.swift in Sources */,
31843217
43FCEEAD221A66780013DD30 /* DateFormatter.swift in Sources */,
3218+
B4E96D55248A7509002DABAD /* GlucoseTrendHUDView.swift in Sources */,
31853219
4FB76FB51E8C41E200B39636 /* ChartPointsScatterDownTrianglesLayer.swift in Sources */,
31863220
43FCEEAF221A67A70013DD30 /* NumberFormatter+Charts.swift in Sources */,
31873221
4F75289A1DFE1F6000C322D6 /* BasalRateHUDView.swift in Sources */,
31883222
4F75289C1DFE1F6000C322D6 /* GlucoseHUDView.swift in Sources */,
3223+
B4E96D53248A7386002DABAD /* GlucoseValueHUDView.swift in Sources */,
31893224
4FB76FB81E8C429D00B39636 /* CGPoint.swift in Sources */,
3225+
B4E96D57248A7B0F002DABAD /* AlertStatusHUDView.swift in Sources */,
31903226
43FCEEB5221BCA020013DD30 /* COBChart.swift in Sources */,
31913227
4F75289E1DFE1F6000C322D6 /* LoopCompletionHUDView.swift in Sources */,
31923228
);

0 commit comments

Comments
 (0)