@@ -61,10 +61,11 @@ struct Scaler {
6161 return CGPoint ( x: CGFloat ( x. timeIntervalSince ( startDate) ) * xScale, y: CGFloat ( y - glucoseMin) * yScale)
6262 }
6363
64- func rect( for range: WatchDatedRange ) -> CGRect {
64+ // By default enforce a minimum height so that the range is visible
65+ func rect( for range: WatchDatedRange , minHeight: CGFloat = 2 ) -> CGRect {
6566 let a = point ( range. startDate, range. minValue)
6667 let b = point ( range. endDate, range. maxValue)
67- let size = CGSize ( width: b. x - a. x, height: b. y - a. y)
68+ let size = CGSize ( width: b. x - a. x, height: max ( b. y - a. y, minHeight ) )
6869 return CGRect ( origin: CGPoint ( x: a. x + size. width / 2 , y: a. y + size. height / 2 ) , size: size)
6970 }
7071}
@@ -74,15 +75,15 @@ extension HKUnit {
7475 if unitString == " mg/dL " {
7576 return [ 150.0 , 200.0 , 250.0 , 300.0 , 350.0 , 400.0 ]
7677 } else {
77- return [ 8.3 , 11.1 , 13.9 , 16.6 , 19.4 , 22.2 ]
78+ return [ 8.0 , 11.0 , 14.0 , 17.0 , 20.0 , 23.0 ]
7879 }
7980 }
8081
8182 var lowWatermark : Double {
8283 if unitString == " mg/dL " {
8384 return 50.0
8485 } else {
85- return 2.8
86+ return 3.0
8687 }
8788 }
8889}
@@ -242,23 +243,23 @@ class GlucoseChartScene: SKScene {
242243
243244 targetRanges? . forEach { range in
244245 let sprite = getSprite ( forHash: range. hashValue)
245- sprite. color = UIColor . rangeColor. withAlphaComponent ( temporaryOverride != nil ? 0.2 : 0.4 )
246+ sprite. color = UIColor . rangeColor. withAlphaComponent ( temporaryOverride != nil ? 0.4 : 0.6 )
246247 sprite. move ( to: scaler. rect ( for: range) , animated: animated)
247248 inactiveNodes. removeValue ( forKey: range. hashValue)
248249 }
249250
250251 // Make temporary overrides visually match what we do in the Loop app. This means that we have
251252 // one darker box which represents the duration of the override, but we have a second lighter box which
252253 // extends to the end of the visible window.
253- if let range = temporaryOverride {
254+ if let range = temporaryOverride, range . endDate > Date ( ) {
254255 let sprite1 = getSprite ( forHash: range. hashValue)
255- sprite1. color = UIColor . rangeColor. withAlphaComponent ( 0.2 )
256+ sprite1. color = UIColor . rangeColor. withAlphaComponent ( 0.6 )
256257 sprite1. move ( to: scaler. rect ( for: range) , animated: animated)
257258 inactiveNodes. removeValue ( forKey: range. hashValue)
258259
259260 let extendedRange = WatchDatedRange ( startDate: range. startDate, endDate: Date ( ) + window, minValue: range. minValue, maxValue: range. maxValue)
260261 let sprite2 = getSprite ( forHash: extendedRange. hashValue)
261- sprite2. color = UIColor . rangeColor. withAlphaComponent ( 0.2 )
262+ sprite2. color = UIColor . rangeColor. withAlphaComponent ( 0.4 )
262263 sprite2. move ( to: scaler. rect ( for: extendedRange) , animated: animated)
263264 inactiveNodes. removeValue ( forKey: extendedRange. hashValue)
264265 }
0 commit comments