Skip to content

Commit eba93b4

Browse files
author
Bharat Mediratta
authored
Merge pull request #4 from elnjensen/dev-watch-sk-ej
Fix override range display, mmol/L limits
2 parents 39ec79e + e1c3886 commit eba93b4

File tree

23 files changed

+72
-95
lines changed

23 files changed

+72
-95
lines changed

WatchApp Extension/Scenes/GlucoseChartScene.swift

+9-8
Original file line numberDiff line numberDiff line change
@@ -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
}

WatchApp/Assets.xcassets/Graph menu icons/1-hour-graph-38mm.imageset/Contents.json

-13
This file was deleted.

WatchApp/Assets.xcassets/Graph menu icons/1-hour-graph-42mm.imageset/Contents.json

-13
This file was deleted.
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "watch",
5+
"filename" : "1-hour-graph-38mm.png",
6+
"screen-width" : "<=145",
7+
"scale" : "2x"
8+
},
9+
{
10+
"idiom" : "watch",
11+
"filename" : "1-hour-graph-42mm.png",
12+
"screen-width" : ">145",
13+
"scale" : "2x"
14+
}
15+
],
16+
"info" : {
17+
"version" : 1,
18+
"author" : "xcode"
19+
}
20+
}

WatchApp/Assets.xcassets/Graph menu icons/2-hour-graph-38mm.imageset/Contents.json

-13
This file was deleted.

WatchApp/Assets.xcassets/Graph menu icons/2-hour-graph-42mm.imageset/Contents.json

-13
This file was deleted.
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "watch",
5+
"filename" : "2-hour-graph-38mm.png",
6+
"screen-width" : "<=145",
7+
"scale" : "2x"
8+
},
9+
{
10+
"idiom" : "watch",
11+
"filename" : "2-hour-graph-42mm.png",
12+
"screen-width" : ">145",
13+
"scale" : "2x"
14+
}
15+
],
16+
"info" : {
17+
"version" : 1,
18+
"author" : "xcode"
19+
}
20+
}

WatchApp/Assets.xcassets/Graph menu icons/3-hour-graph-38mm.imageset/Contents.json

-13
This file was deleted.

WatchApp/Assets.xcassets/Graph menu icons/3-hour-graph-42mm.imageset/Contents.json

-13
This file was deleted.
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "watch",
5+
"filename" : "3-hour-graph-38mm.png",
6+
"screen-width" : "<=145",
7+
"scale" : "2x"
8+
},
9+
{
10+
"idiom" : "watch",
11+
"filename" : "3-hour-graph-42mm.png",
12+
"screen-width" : ">145",
13+
"scale" : "2x"
14+
}
15+
],
16+
"info" : {
17+
"version" : 1,
18+
"author" : "xcode"
19+
}
20+
}

WatchApp/Base.lproj/Interface.storyboard

+3-9
Original file line numberDiff line numberDiff line change
@@ -389,23 +389,17 @@
389389
</items>
390390
<menu key="menu" id="Da1-jh-2yL">
391391
<items>
392-
<menuItem title="1 hour" image="1-hour-graph-38mm" id="vL1-NA-WZ1">
393-
<variation key="device=watch38mm" image="1-hour-graph-38mm"/>
394-
<variation key="device=watch42mm" image="1-hour-graph-42mm"/>
392+
<menuItem title="1 hour" image="1-hour-graph" id="vL1-NA-WZ1">
395393
<connections>
396394
<action selector="setChartWindow1Hour" destination="v5b-sO-bb8" id="yp1-H2-0e5"/>
397395
</connections>
398396
</menuItem>
399-
<menuItem title="2 hours" image="2-hour-graph-38mm" id="dPh-7b-Tfv">
400-
<variation key="device=watch38mm" image="2-hour-graph-38mm"/>
401-
<variation key="device=watch42mm" image="2-hour-graph-42mm"/>
397+
<menuItem title="2 hours" image="2-hour-graph" id="dPh-7b-Tfv">
402398
<connections>
403399
<action selector="setChartWindow2Hours" destination="v5b-sO-bb8" id="IQe-Uh-AOb"/>
404400
</connections>
405401
</menuItem>
406-
<menuItem title="3 hours" image="3-hour-graph-38mm" id="fR1-7h-SNe">
407-
<variation key="device=watch38mm" image="3-hour-graph-38mm"/>
408-
<variation key="device=watch42mm" image="3-hour-graph-42mm"/>
402+
<menuItem title="3 hours" image="3-hour-graph" id="fR1-7h-SNe">
409403
<connections>
410404
<action selector="setChartWindow3Hours" destination="v5b-sO-bb8" id="HhZ-89-5Yp"/>
411405
</connections>

0 commit comments

Comments
 (0)