@@ -61,36 +61,6 @@ class StatusViewController: UIViewController, NCWidgetProviding {
6161 var defaults : UserDefaults ?
6262 final var observationContext = 1
6363
64- var loopCompletionHUD : LoopCompletionHUDView ! {
65- get {
66- return hudView. loopCompletionHUD
67- }
68- }
69-
70- var glucoseHUD : GlucoseHUDView ! {
71- get {
72- return hudView. glucoseHUD
73- }
74- }
75-
76- var basalRateHUD : BasalRateHUDView ! {
77- get {
78- return hudView. basalRateHUD
79- }
80- }
81-
82- var reservoirVolumeHUD : ReservoirVolumeHUDView ! {
83- get {
84- return hudView. reservoirVolumeHUD
85- }
86- }
87-
88- var batteryHUD : BatteryLevelHUDView ! {
89- get {
90- return hudView. batteryHUD
91- }
92- }
93-
9464 override func viewDidLoad( ) {
9565 super. viewDidLoad ( )
9666 subtitleLabel. isHidden = true
@@ -125,11 +95,13 @@ class StatusViewController: UIViewController, NCWidgetProviding {
12595 }
12696
12797 func widgetActiveDisplayModeDidChange( _ activeDisplayMode: NCWidgetDisplayMode , withMaximumSize maxSize: CGSize ) {
98+ let compactHeight = hudView. systemLayoutSizeFitting ( maxSize) . height + subtitleLabel. systemLayoutSizeFitting ( maxSize) . height
99+
128100 switch activeDisplayMode {
129101 case . compact:
130- preferredContentSize = maxSize
102+ preferredContentSize = CGSize ( width : maxSize. width , height : compactHeight )
131103 case . expanded:
132- preferredContentSize = CGSize ( width: maxSize. width, height: 210 )
104+ preferredContentSize = CGSize ( width: maxSize. width, height: compactHeight + 100 )
133105 }
134106 }
135107
@@ -168,29 +140,29 @@ class StatusViewController: UIViewController, NCWidgetProviding {
168140 return NCUpdateResult . failed
169141 }
170142 if let lastGlucose = context. glucose? . last {
171- glucoseHUD. setGlucoseQuantity ( lastGlucose. value,
143+ hudView . glucoseHUD. setGlucoseQuantity ( lastGlucose. value,
172144 at: lastGlucose. startDate,
173145 unit: lastGlucose. unit,
174146 sensor: context. sensor
175147 )
176148 }
177149
178150 if let batteryPercentage = context. batteryPercentage {
179- batteryHUD. batteryLevel = Double ( batteryPercentage)
151+ hudView . batteryHUD. batteryLevel = Double ( batteryPercentage)
180152 }
181153
182154 if let reservoir = context. reservoir {
183- reservoirVolumeHUD. reservoirLevel = min ( 1 , max ( 0 , Double ( reservoir. unitVolume / Double( reservoir. capacity) ) ) )
184- reservoirVolumeHUD. setReservoirVolume ( volume: reservoir. unitVolume, at: reservoir. startDate)
155+ hudView . reservoirVolumeHUD. reservoirLevel = min ( 1 , max ( 0 , Double ( reservoir. unitVolume / Double( reservoir. capacity) ) ) )
156+ hudView . reservoirVolumeHUD. setReservoirVolume ( volume: reservoir. unitVolume, at: reservoir. startDate)
185157 }
186158
187159 if let netBasal = context. netBasal {
188- basalRateHUD. setNetBasalRate ( netBasal. rate, percent: netBasal. percentage, at: netBasal. start)
160+ hudView . basalRateHUD. setNetBasalRate ( netBasal. rate, percent: netBasal. percentage, at: netBasal. start)
189161 }
190162
191163 if let loop = context. loop {
192- loopCompletionHUD. dosingEnabled = loop. dosingEnabled
193- loopCompletionHUD. lastLoopCompleted = loop. lastCompleted
164+ hudView . loopCompletionHUD. dosingEnabled = loop. dosingEnabled
165+ hudView . loopCompletionHUD. lastLoopCompleted = loop. lastCompleted
194166 }
195167
196168 subtitleLabel. isHidden = true
0 commit comments