@@ -61,8 +61,9 @@ 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 {
65- let a = point ( range. startDate, range. minValue)
64+ func rect( for range: WatchDatedRange , future: Bool = false ) -> CGRect {
65+ let startDate = future ? Date ( ) : range. startDate
66+ let a = point ( startDate, range. minValue)
6667 let b = point ( range. endDate, range. maxValue)
6768 let size = CGSize ( width: b. x - a. x, height: max ( b. y - a. y, 2 ) )
6869 return CGRect ( origin: CGPoint ( x: a. x + size. width / 2 , y: a. y + size. height / 2 ) , size: size)
@@ -250,16 +251,16 @@ class GlucoseChartScene: SKScene {
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)
255256 sprite1. color = UIColor . rangeColor. withAlphaComponent ( 0.6 )
256- sprite1. move ( to: scaler. rect ( for: range) , animated: animated)
257+ sprite1. move ( to: scaler. rect ( for: range, future : true ) , 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)
261262 sprite2. color = UIColor . rangeColor. withAlphaComponent ( 0.4 )
262- sprite2. move ( to: scaler. rect ( for: extendedRange) , animated: animated)
263+ sprite2. move ( to: scaler. rect ( for: extendedRange, future : true ) , animated: animated)
263264 inactiveNodes. removeValue ( forKey: extendedRange. hashValue)
264265 }
265266
0 commit comments