@@ -53,18 +53,54 @@ struct PredictedGlucoseContext {
5353 }
5454}
5555
56- extension NetBasalContext : RawRepresentable {
57- typealias RawValue = [ String : Any ]
56+ struct DeviceStatusHighlightContext : DeviceStatusHighlight {
57+ var localizedMessage : String
58+ var imageSystemName : String
59+ var state : DeviceStatusHighlightState
60+
61+ init ( localizedMessage: String ,
62+ imageSystemName: String ,
63+ state: DeviceStatusHighlightState )
64+ {
65+ self . localizedMessage = localizedMessage
66+ self . imageSystemName = imageSystemName
67+ self . state = state
68+ }
69+
70+ init ? ( from deviceStatusHighlight: DeviceStatusHighlight ? ) {
71+ guard let deviceStatusHighlight = deviceStatusHighlight else {
72+ return nil
73+ }
74+
75+ self . init ( localizedMessage: deviceStatusHighlight. localizedMessage,
76+ imageSystemName: deviceStatusHighlight. imageSystemName,
77+ state: deviceStatusHighlight. state)
78+ }
79+ }
5880
59- var rawValue : RawValue {
60- var value : RawValue = [
61- " rate " : rate,
62- " percentage " : percentage,
63- " start " : start
64- ]
65- value [ " end " ] = end
66- return value
81+ struct DeviceLifecycleProgressContext : DeviceLifecycleProgress {
82+ var percentComplete : Double
83+ var progressState : DeviceLifecycleProgressState
84+
85+ init ( percentComplete: Double ,
86+ progressState: DeviceLifecycleProgressState )
87+ {
88+ self . percentComplete = percentComplete
89+ self . progressState = progressState
90+ }
91+
92+ init ? ( from deviceLifecycleProgress: DeviceLifecycleProgress ? ) {
93+ guard let deviceLifecycleProgress = deviceLifecycleProgress else {
94+ return nil
95+ }
96+
97+ self . init ( percentComplete: deviceLifecycleProgress. percentComplete,
98+ progressState: deviceLifecycleProgress. progressState)
6799 }
100+ }
101+
102+ extension NetBasalContext : RawRepresentable {
103+ typealias RawValue = [ String : Any ]
68104
69105 init ? ( rawValue: RawValue ) {
70106 guard
@@ -80,23 +116,21 @@ extension NetBasalContext: RawRepresentable {
80116 self . start = start
81117 self . end = rawValue [ " end " ] as? Date
82118 }
119+
120+ var rawValue : RawValue {
121+ var value : RawValue = [
122+ " rate " : rate,
123+ " percentage " : percentage,
124+ " start " : start
125+ ]
126+ value [ " end " ] = end
127+ return value
128+ }
83129}
84130
85131extension SensorDisplayableContext : RawRepresentable {
86132 typealias RawValue = [ String : Any ]
87133
88- var rawValue : RawValue {
89- var raw : RawValue = [
90- " isStateValid " : isStateValid,
91- " stateDescription " : stateDescription,
92- " isLocal " : isLocal
93- ]
94- raw [ " trendType " ] = trendType? . rawValue
95- raw [ " glucoseValueType " ] = glucoseValueType? . rawValue
96-
97- return raw
98- }
99-
100134 init ( _ other: SensorDisplayable ) {
101135 isStateValid = other. isStateValid
102136 stateDescription = other. stateDescription
@@ -130,20 +164,23 @@ extension SensorDisplayableContext: RawRepresentable {
130164 glucoseValueType = nil
131165 }
132166 }
167+
168+ var rawValue : RawValue {
169+ var raw : RawValue = [
170+ " isStateValid " : isStateValid,
171+ " stateDescription " : stateDescription,
172+ " isLocal " : isLocal
173+ ]
174+ raw [ " trendType " ] = trendType? . rawValue
175+ raw [ " glucoseValueType " ] = glucoseValueType? . rawValue
176+
177+ return raw
178+ }
133179}
134180
135181extension PredictedGlucoseContext : RawRepresentable {
136182 typealias RawValue = [ String : Any ]
137183
138- var rawValue : RawValue {
139- return [
140- " values " : values,
141- " unit " : unit. unitString,
142- " startDate " : startDate,
143- " interval " : interval
144- ]
145- }
146-
147184 init ? ( rawValue: RawValue ) {
148185 guard
149186 let values = rawValue [ " values " ] as? [ Double ] ,
@@ -159,6 +196,64 @@ extension PredictedGlucoseContext: RawRepresentable {
159196 self . startDate = startDate
160197 self . interval = interval
161198 }
199+
200+ var rawValue : RawValue {
201+ return [
202+ " values " : values,
203+ " unit " : unit. unitString,
204+ " startDate " : startDate,
205+ " interval " : interval
206+ ]
207+ }
208+ }
209+
210+ extension DeviceStatusHighlightContext : RawRepresentable {
211+ typealias RawValue = [ String : Any ]
212+
213+ init ? ( rawValue: RawValue ) {
214+ guard let localizedMessage = rawValue [ " localizedMessage " ] as? String ,
215+ let imageSystemName = rawValue [ " imageSystemName " ] as? String ,
216+ let rawState = rawValue [ " state " ] as? DeviceStatusHighlightState . RawValue ,
217+ let state = DeviceStatusHighlightState ( rawValue: rawState) else
218+ {
219+ return nil
220+ }
221+
222+ self . localizedMessage = localizedMessage
223+ self . imageSystemName = imageSystemName
224+ self . state = state
225+ }
226+
227+ var rawValue : RawValue {
228+ return [
229+ " localizedMessage " : localizedMessage,
230+ " imageSystemName " : imageSystemName,
231+ " state " : state. rawValue,
232+ ]
233+ }
234+ }
235+
236+ extension DeviceLifecycleProgressContext : RawRepresentable {
237+ typealias RawValue = [ String : Any ]
238+
239+ init ? ( rawValue: RawValue ) {
240+ guard let percentComplete = rawValue [ " percentComplete " ] as? Double ,
241+ let rawProgressState = rawValue [ " progressState " ] as? DeviceLifecycleProgressState . RawValue ,
242+ let progressState = DeviceLifecycleProgressState ( rawValue: rawProgressState) else
243+ {
244+ return nil
245+ }
246+
247+ self . percentComplete = percentComplete
248+ self . progressState = progressState
249+ }
250+
251+ var rawValue : RawValue {
252+ return [
253+ " percentComplete " : percentComplete,
254+ " progressState " : progressState. rawValue,
255+ ]
256+ }
162257}
163258
164259struct PumpManagerHUDViewContext : RawRepresentable {
@@ -194,6 +289,10 @@ struct StatusExtensionContext: RawRepresentable {
194289 var reservoirCapacity : Double ?
195290 var sensor : SensorDisplayableContext ?
196291 var pumpManagerHUDViewContext : PumpManagerHUDViewContext ?
292+ var pumpStatusHighlightContext : DeviceStatusHighlightContext ?
293+ var pumpLifecycleProgressContext : DeviceLifecycleProgressContext ?
294+ var cgmStatusHighlightContext : DeviceStatusHighlightContext ?
295+ var cgmLifecycleProgressContext : DeviceLifecycleProgressContext ?
197296
198297 init ( ) { }
199298
@@ -221,6 +320,22 @@ struct StatusExtensionContext: RawRepresentable {
221320 if let rawPumpManagerHUDViewContext = rawValue [ " pumpManagerHUDViewContext " ] as? PumpManagerHUDViewContext . RawValue {
222321 pumpManagerHUDViewContext = PumpManagerHUDViewContext ( rawValue: rawPumpManagerHUDViewContext)
223322 }
323+
324+ if let rawPumpStatusHighlightContext = rawValue [ " pumpStatusHighlightContext " ] as? DeviceStatusHighlightContext . RawValue {
325+ pumpStatusHighlightContext = DeviceStatusHighlightContext ( rawValue: rawPumpStatusHighlightContext)
326+ }
327+
328+ if let rawPumpLifecycleProgressContext = rawValue [ " pumpLifecycleProgressContext " ] as? DeviceLifecycleProgressContext . RawValue {
329+ pumpLifecycleProgressContext = DeviceLifecycleProgressContext ( rawValue: rawPumpLifecycleProgressContext)
330+ }
331+
332+ if let rawCGMStatusHighlightContext = rawValue [ " cgmStatusHighlightContext " ] as? DeviceStatusHighlightContext . RawValue {
333+ cgmStatusHighlightContext = DeviceStatusHighlightContext ( rawValue: rawCGMStatusHighlightContext)
334+ }
335+
336+ if let rawCGMLifecycleProgressContext = rawValue [ " cgmLifecycleProgressContext " ] as? DeviceLifecycleProgressContext . RawValue {
337+ cgmLifecycleProgressContext = DeviceLifecycleProgressContext ( rawValue: rawCGMLifecycleProgressContext)
338+ }
224339 }
225340
226341 var rawValue : RawValue {
@@ -235,6 +350,10 @@ struct StatusExtensionContext: RawRepresentable {
235350 raw [ " reservoirCapacity " ] = reservoirCapacity
236351 raw [ " sensor " ] = sensor? . rawValue
237352 raw [ " pumpManagerHUDViewContext " ] = pumpManagerHUDViewContext? . rawValue
353+ raw [ " pumpStatusHighlightContext " ] = pumpStatusHighlightContext? . rawValue
354+ raw [ " pumpLifecycleProgressContext " ] = pumpLifecycleProgressContext? . rawValue
355+ raw [ " cgmStatusHighlightContext " ] = cgmStatusHighlightContext? . rawValue
356+ raw [ " cgmLifecycleProgressContext " ] = cgmLifecycleProgressContext? . rawValue
238357
239358 return raw
240359 }
0 commit comments