Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions WatchApp Extension/Controllers/ChartHUDController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ final class ChartHUDController: HUDInterfaceController, WKCrownDelegate {
}

if !hasInitialActivation && UserDefaults.standard.startOnChartPage {
log.default("Switching to startOnChartPage")
log.default("Switching to start on Chart page")
becomeCurrentPage()
}

Expand Down Expand Up @@ -117,18 +117,15 @@ final class ChartHUDController: HUDInterfaceController, WKCrownDelegate {
return numberFormatter
}()

iobLabel.setHidden(true)
if let activeInsulin = activeContext.iob, let valueStr = insulinFormatter.string(from: activeInsulin) {
iobLabel.setText(String(format: NSLocalizedString(
"IOB %1$@ U",
comment: "The subtitle format describing units of active insulin. (1: localized insulin value description)"
),
valueStr
))
iobLabel.setHidden(false)
}

cobLabel.setHidden(true)
if let carbsOnBoard = activeContext.cob {
let carbFormatter = NumberFormatter()
carbFormatter.numberStyle = .decimal
Expand All @@ -141,10 +138,8 @@ final class ChartHUDController: HUDInterfaceController, WKCrownDelegate {
),
valueStr!
))
cobLabel.setHidden(false)
}

basalLabel.setHidden(true)
if let tempBasal = activeContext.lastNetTempBasalDose {
let basalFormatter = NumberFormatter()
basalFormatter.numberStyle = .decimal
Expand All @@ -158,7 +153,6 @@ final class ChartHUDController: HUDInterfaceController, WKCrownDelegate {
comment: "The subtitle format describing the current temp basal rate. (1: localized basal rate description)"),
valueStr!)
basalLabel.setText(basalLabelText)
basalLabel.setHidden(false)
}

if glucoseScene.isPaused {
Expand Down
6 changes: 0 additions & 6 deletions WatchApp Extension/Controllers/HUDInterfaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class HUDInterfaceController: WKInterfaceController {
private var activeContextObserver: NSObjectProtocol?

@IBOutlet weak var loopHUDImage: WKInterfaceImage!
@IBOutlet weak var loopTimer: WKInterfaceTimer!
@IBOutlet weak var glucoseLabel: WKInterfaceLabel!
@IBOutlet weak var eventualGlucoseLabel: WKInterfaceLabel!

Expand Down Expand Up @@ -46,14 +45,9 @@ class HUDInterfaceController: WKInterfaceController {
let date = activeContext.loopLastRunDate
else {
loopHUDImage.setLoopImage(.unknown)
loopTimer.setHidden(true)
return
}

loopTimer.setDate(date)
loopTimer.setHidden(false)
loopTimer.start()

glucoseLabel.setHidden(true)
eventualGlucoseLabel.setHidden(true)
if let glucose = activeContext.glucose, let unit = activeContext.preferredGlucoseUnit {
Expand Down
13 changes: 13 additions & 0 deletions WatchApp Extension/Extensions/NSUserDefaults+WatchApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Foundation
extension UserDefaults {
private enum Key: String {
case StartOnChartPage = "com.loudnate.Naterade.StartOnChartPage"
case VisibleDuration = "com.loudnate.Naterade.VisibleDuration"
}

var startOnChartPage: Bool {
Expand All @@ -22,4 +23,16 @@ extension UserDefaults {
set(newValue, forKey: Key.StartOnChartPage.rawValue)
}
}

var visibleDuration: TimeInterval {
get {
if let rawValue = object(forKey: Key.VisibleDuration.rawValue) as? TimeInterval, let visibleDuration = TimeInterval(rawValue: rawValue) {
return visibleDuration
}
return TimeInterval (hours: 6)
}
set {
set(newValue.rawValue, forKey: Key.VisibleDuration.rawValue)
}
}
}
20 changes: 12 additions & 8 deletions WatchApp Extension/Scenes/GlucoseChartScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ class GlucoseChartScene: SKScene {
return lowerBound..<upperBound
}

var visibleDuration = TimeInterval(hours: 6) {
var visibleDuration = UserDefaults.standard.visibleDuration {
didSet {
setNeedsUpdate()
UserDefaults.standard.visibleDuration = visibleDuration
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea to save this and restore each time!

}
}
private var hoursLabel: SKLabelNode!
Expand All @@ -204,16 +205,19 @@ class GlucoseChartScene: SKScene {
}()

override init() {
// Use the fixed sizes specified in the storyboard, based on our guess of the model size
// Set the height based on the model size, which we guess from the screen width
let screen = WKInterfaceDevice.current().screenBounds
let width = screen.width - 2 /* insets */
let height: CGFloat

switch width {
case let x where x < 150: // 38mm
height = 68
case let x where x > 180: // 44mm
height = 106
switch screen.width {
case 136: // 38mm 136x170 px
height = 110
case 162: // 40mm 162x197 px
height = 127
case 156: // 42mm 156x195 px
height = 126
case 184: // 44mm 184x224 px
height = 144
default:
height = 86
}
Expand Down
86 changes: 56 additions & 30 deletions WatchApp/Base.lproj/Interface.storyboard
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14313.18" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="rNf-Mh-tID">
<device id="watch44" orientation="portrait">
<device id="watch42" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
Expand Down Expand Up @@ -137,10 +137,6 @@
<group width="0.25" alignment="left" layout="vertical" id="2Qn-78-Zex">
<items>
<imageView alignment="center" image="loop_unknown" contentMode="center" id="Q7C-xN-eH8"/>
<timer width="1" alignment="left" hidden="YES" textAlignment="center" enabled="YES" format="abbreviated" previewedSeconds="500" id="sG9-yO-4Xy">
<fontDescription key="font" style="UICTFontTextStyleCaption1"/>
<calendarUnit key="units" minute="YES"/>
</timer>
</items>
</group>
<group width="0.75" alignment="left" layout="vertical" id="QDM-Gw-2Ex">
Expand All @@ -157,9 +153,6 @@
</items>
<variation key="device=watch42mm" height="29"/>
</group>
<label width="1" alignment="right" verticalAlignment="bottom" textAlignment="right" minimumScaleFactor="0.5" id="cZW-uY-zIa">
<fontDescription key="font" style="UICTFontTextStyleCaption1"/>
</label>
</items>
<variation key="device=watch40mm" widthAdjustment="-8.5"/>
<variation key="device=watch44mm" widthAdjustment="-9.5"/>
Expand Down Expand Up @@ -263,7 +256,6 @@
<outlet property="eventualGlucoseLabel" destination="0zU-nK-BWD" id="0V7-RE-Lnr"/>
<outlet property="glucoseLabel" destination="MHD-Is-5mK" id="MDr-iV-fr1"/>
<outlet property="loopHUDImage" destination="Q7C-xN-eH8" id="CIe-B3-umI"/>
<outlet property="loopTimer" destination="sG9-yO-4Xy" id="tfl-hp-Eu5"/>
<outlet property="preMealButton" destination="jY0-1m-ful" id="IMe-rm-JYl"/>
<outlet property="preMealButtonBackground" destination="mBB-jG-wHy" id="Ouy-xo-rMR"/>
<outlet property="preMealButtonImage" destination="Asx-tm-mEg" id="DIe-5b-uc1"/>
Expand Down Expand Up @@ -359,10 +351,6 @@
<group width="0.25" alignment="left" layout="vertical" id="Z7g-qg-0wK">
<items>
<imageView alignment="center" image="loop_unknown" contentMode="center" id="ifw-dh-btK"/>
<timer width="1" alignment="left" hidden="YES" textAlignment="center" enabled="YES" format="abbreviated" previewedSeconds="500" id="P2b-9P-EbP">
<fontDescription key="font" style="UICTFontTextStyleCaption1"/>
<calendarUnit key="units" minute="YES"/>
</timer>
</items>
</group>
<group width="0.75" alignment="left" layout="vertical" id="nPX-XN-diX">
Expand All @@ -379,9 +367,6 @@
</items>
<variation key="device=watch42mm" height="29"/>
</group>
<label width="1" alignment="left" verticalAlignment="bottom" text="---" textAlignment="right" minimumScaleFactor="0.5" id="U5L-zt-Ck7">
<fontDescription key="font" style="UICTFontTextStyleCaption1"/>
</label>
</items>
<variation key="device=watch40mm" widthAdjustment="-8.5"/>
<variation key="device=watch44mm" widthAdjustment="-9.5"/>
Expand All @@ -392,20 +377,62 @@
<items>
<spriteKitScene width="1" height="1" alignment="center" verticalAlignment="center" scene="GlucoseChartScene" id="9BI-AC-l6c"/>
</items>
<variation key="device=watch38mm" height="68"/>
<variation key="device=watch44mm" height="106"/>
<variation key="device=watch38mm" height="110"/>
<variation key="device=watch40mm" height="127"/>
<variation key="device=watch42mm" height="126"/>
<variation key="device=watch44mm" height="144"/>
</group>
<group width="1" height="12" alignment="left" id="man-Ev-vTI" userLabel="Spacer"/>
<separator alignment="left" alpha="0.5" id="qXC-hQ-e1L">
<color key="color" white="0.66666666669999997" alpha="1" colorSpace="calibratedWhite"/>
</separator>
<group width="1" alignment="left" layout="vertical" spacing="0.0" id="mgy-04-czh">
<items>
<label alignment="left" text="TEMP BASAL" id="Lht-zi-xKw">
<color key="textColor" white="0.66666666669999997" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="font" style="UICTFontTextStyleFootnote"/>
</label>
<label alignment="left" text="+0.425 U/h" id="yBm-Bi-1HM">
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="font" style="UICTFontTextStyleTitle3"/>
</label>
</items>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<edgeInsets key="margins" left="4" right="4" top="4" bottom="4"/>
</group>
<separator alignment="left" alpha="0.5" id="Idh-32-omJ">
<color key="color" white="0.66666666669999997" alpha="1" colorSpace="calibratedWhite"/>
</separator>
<group width="1" alignment="left" layout="vertical" spacing="0.0" id="prj-d2-lfq">
<items>
<label alignment="left" text="ACTIVE INSULIN" id="CgF-0q-8tP">
<color key="textColor" white="0.66666666669999997" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="font" style="UICTFontTextStyleFootnote"/>
</label>
<label alignment="left" text="6.225 U" id="WWK-X3-2ZP">
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="font" style="UICTFontTextStyleTitle3"/>
</label>
</items>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<edgeInsets key="margins" left="4" right="4" top="4" bottom="4"/>
</group>
<group width="1" alignment="center" id="rSt-1g-97T">
<separator alignment="left" alpha="0.5" id="Gm6-EW-QpU">
<color key="color" white="0.66666666669999997" alpha="1" colorSpace="calibratedWhite"/>
</separator>
<group width="1" alignment="left" layout="vertical" spacing="0.0" id="mbG-2a-yiB">
<items>
<label alignment="left" verticalAlignment="bottom" text="---" minimumScaleFactor="0.5" id="PI8-dB-Ykw" userLabel="IOB Label">
<fontDescription key="font" style="UICTFontTextStyleCaption1"/>
<label alignment="left" text="ACTIVE CARBS" id="zMo-N8-tex">
<color key="textColor" white="0.66666666669999997" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="font" style="UICTFontTextStyleFootnote"/>
</label>
<label alignment="right" verticalAlignment="bottom" text="---" minimumScaleFactor="0.5" id="gC1-LZ-QMz" userLabel="COB Label">
<fontDescription key="font" style="UICTFontTextStyleCaption1"/>
<label alignment="left" text="125 g" id="Bix-bw-zdh">
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="font" style="UICTFontTextStyleTitle3"/>
</label>
</items>
<variation key="device=watch40mm" widthAdjustment="-17"/>
<variation key="device=watch44mm" widthAdjustment="-19"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<edgeInsets key="margins" left="4" right="4" top="4" bottom="4"/>
</group>
</items>
<menu key="menu" id="Da1-jh-2yL">
Expand All @@ -428,18 +455,17 @@
</items>
</menu>
<connections>
<outlet property="basalLabel" destination="U5L-zt-Ck7" id="mM0-Vf-6uk"/>
<outlet property="cobLabel" destination="gC1-LZ-QMz" id="zeH-DE-pAh"/>
<outlet property="basalLabel" destination="yBm-Bi-1HM" id="bnX-p6-wMh"/>
<outlet property="cobLabel" destination="Bix-bw-zdh" id="gdF-gd-MBZ"/>
<outlet property="eventualGlucoseLabel" destination="yl8-ZP-c3l" id="PTg-ax-ppQ"/>
<outlet property="glucoseLabel" destination="Dt1-kz-jMZ" id="MQj-0o-PaV"/>
<outlet property="glucoseScene" destination="9BI-AC-l6c" id="O4a-P8-cHI"/>
<outlet property="iobLabel" destination="PI8-dB-Ykw" id="S3x-RE-C7L"/>
<outlet property="iobLabel" destination="WWK-X3-2ZP" id="Lv5-07-80I"/>
<outlet property="loopHUDImage" destination="ifw-dh-btK" id="Bc0-er-dfe"/>
<outlet property="loopTimer" destination="P2b-9P-EbP" id="5xU-ne-x8i"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="342" y="754"/>
<point key="canvasLocation" x="340" y="751.48717948717956"/>
</scene>
<!--Static Notification Interface Controller-->
<scene sceneID="AEw-b0-oYE">
Expand Down