Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8ca862e
bump version for dev branch
ps2 Sep 25, 2017
57f19f8
Merge pull request #589 from LoopKit/bump-version
ps2 Sep 25, 2017
fec50e9
Set deployment target for WatchOS to 3.2
ps2 Sep 25, 2017
da39b9e
fix intermittent crash on deleting carbs
ps2 Sep 25, 2017
f5dc15d
Update Info.plist (#585)
paulforgione Sep 25, 2017
8b3ffb7
Merge pull request #590 from LoopKit/watchos3-build-fix
ps2 Sep 25, 2017
fa5124b
Merge pull request #591 from LoopKit/carb-crash
ps2 Sep 25, 2017
3a4fac4
Simplifying Rewind-Prime reconciliation
ps2 Oct 6, 2017
f50e1e1
Additional test coverage around suspend threshold behavior
ps2 Oct 6, 2017
6db6e6c
Faster status update
ps2 Oct 7, 2017
0e0816a
Autolayout warnings
ps2 Oct 7, 2017
f293561
Adjust time borders
ps2 Oct 7, 2017
c58dd8a
Merge pull request #602 from LoopKit/rewind-handling
ps2 Oct 7, 2017
d939229
Merge pull request #603 from LoopKit/test-suspend-threshold
ps2 Oct 7, 2017
448070b
Merge pull request #604 from LoopKit/faster-status-update
ps2 Oct 8, 2017
1affe64
Merge pull request #605 from LoopKit/autolayout-warnings
ps2 Oct 8, 2017
7b32162
Merge pull request #606 from LoopKit/green-loop-until-6-minutes
ps2 Oct 8, 2017
006a8cc
Remove Swift 3 support
ps2 Oct 8, 2017
27b9dbe
Merge pull request #607 from LoopKit/remove-swift3-support
ps2 Oct 8, 2017
0fdf10f
Merge pull request #2 from LoopKit/master
Kdisimone Oct 10, 2017
1ee1f7c
Merge pull request #3 from LoopKit/dev
Kdisimone Oct 11, 2017
bbc9a43
Update to LoopKit 1.5.1 (#617)
ps2 Nov 3, 2017
6a667eb
Revert inadvertant bundle id change, and add missing nib files
ps2 Nov 4, 2017
650a550
Merge pull request #619 from LoopKit/fix-missing-nibs
ps2 Nov 4, 2017
bb83268
Make carb entry time configurable when entered via Watch (#608) (#609)
mpangburn Nov 4, 2017
22980ac
Tweaks for 38mm watch
ps2 Nov 5, 2017
aa89841
Set pending bolus end date
ps2 Nov 13, 2017
5016266
Merge pull request #621 from LoopKit/master
ps2 Dec 5, 2017
337e4d5
Merge pull request #628 from LoopKit/set-pending-bolus-end-date
ps2 Dec 5, 2017
9f6de1e
Merge pull request #620 from LoopKit/38mm-tweaks
ps2 Dec 5, 2017
8b4f061
A few fixes to avoid compile-time warnings (#631)
elnjensen Dec 9, 2017
089360a
Fix logging and set background color
ps2 Dec 9, 2017
302bb40
Fix bolus end date charting
ps2 Dec 9, 2017
bea4d68
spanish translation for Loop
Kdisimone Dec 12, 2017
ef3be83
Merge pull request #4 from LoopKit/dev
Kdisimone Dec 13, 2017
a40da20
Merge pull request #638 from LoopKit/fix-bolus-end-date-charting
ps2 Dec 13, 2017
e10eff6
Merge pull request #637 from LoopKit/fix-logging
ps2 Dec 13, 2017
6453d5c
Add active insulin (IOB) value in Today widget (#635)
elnjensen Dec 13, 2017
9146f84
Update to LoopKit 1.5.2 and Swiftcharts 0.6.1
ps2 Dec 13, 2017
b935907
Merge pull request #640 from Kdisimone/spanish
ps2 Dec 13, 2017
56fd9e7
Merge pull request #639 from LoopKit/update-loopkit
ps2 Dec 13, 2017
32c9648
Merge pull request #6 from LoopKit/dev
Kdisimone Dec 14, 2017
6f5b030
testing russian redo
Kdisimone Dec 14, 2017
d305148
Merge pull request #643 from Kdisimone/test-russian
ps2 Dec 19, 2017
6f3a0e0
Update LoopKit to v1.5.3
ps2 Dec 19, 2017
ca1377d
Fetch pump data if needed, even after .noData CGM updates.
ps2 Dec 19, 2017
1cbf199
Merge pull request #646 from LoopKit/update-loopkit
ps2 Dec 19, 2017
07d7281
Merge pull request #647 from LoopKit/pump-data-fetch-fix
ps2 Dec 19, 2017
0792391
Bump version in prep for release
ps2 Dec 20, 2017
86f85bc
Merge pull request #649 from LoopKit/bump-version
ps2 Dec 20, 2017
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
Prev Previous commit
Next Next commit
Make carb entry time configurable when entered via Watch (#608) (#609)
* Make carb entry time configurable when entered via Watch

* Commit project.pbxproj

* Minor UI cleanup

* Revamped Watch date configuration UI

* Use WKTapGestureRecognizer rather than buttons in Watch carb entry screen

* WatchApp carb entry cleanup; revert project.pbxproj
  • Loading branch information
mpangburn authored and ps2 committed Nov 4, 2017
commit bb83268dc039574eb242d0e7c1a7889dd6977ea0
99 changes: 83 additions & 16 deletions WatchApp Extension/Controllers/AddCarbsInterfaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,45 @@ import WatchConnectivity

final class AddCarbsInterfaceController: WKInterfaceController, IdentifiableClass {

fileprivate var carbValue: Int = 15 {
private var carbValue: Int = 15 {
didSet {
guard carbValue >= 0 else {
if carbValue < 0 {
carbValue = 0
return
}

guard carbValue <= 100 else {
} else if carbValue > 100 {
carbValue = 100
return
}

valueLabel.setText(String(carbValue))
}
}

private var absorptionTime = AbsorptionTimeType.medium {
private let maximumDatePastInterval = TimeInterval(hours: 8)
private let maximumDateFutureInterval = TimeInterval(hours: 4)

private var date = Date() {
didSet {
let now = Date()
let minimumDate = now - maximumDatePastInterval
let maximumDate = now + maximumDateFutureInterval

if date < minimumDate {
date = minimumDate
} else if date > maximumDate {
date = maximumDate
}

dateLabel.setText(dateFormatter.string(from: date))
}
}

private let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateStyle = .none
formatter.timeStyle = .short
return formatter
}()

private var absorptionTime: AbsorptionTimeType = .medium {
didSet {
absorptionButtonA.setBackgroundColor(UIColor.darkCarbsColor)
absorptionButtonB.setBackgroundColor(UIColor.darkCarbsColor)
Expand All @@ -45,20 +67,41 @@ final class AddCarbsInterfaceController: WKInterfaceController, IdentifiableClas
}
}

@IBOutlet weak var valueLabel: WKInterfaceLabel!
@IBOutlet var valueLabel: WKInterfaceLabel!

@IBOutlet var dateLabel: WKInterfaceLabel!

@IBOutlet weak var absorptionButtonA: WKInterfaceButton!

@IBOutlet weak var absorptionButtonB: WKInterfaceButton!

@IBOutlet weak var absorptionButtonC: WKInterfaceButton!

private enum InputMode {
case value
case date
}

private var inputMode: InputMode = .value {
didSet {
switch inputMode {
case .value:
valueLabel.setTextColor(UIColor.carbsColor)
dateLabel.setTextColor(UIColor.lightGray)
case .date:
valueLabel.setTextColor(UIColor.lightGray)
dateLabel.setTextColor(UIColor.carbsColor)
}
}
}

override func awake(withContext context: Any?) {
super.awake(withContext: context)

// Configure interface objects here.
crownSequencer.delegate = self

date = Date()
absorptionTime = .medium
}

Expand All @@ -76,12 +119,29 @@ final class AddCarbsInterfaceController: WKInterfaceController, IdentifiableClas

// MARK: - Actions

private let valueIncrement = 5
private let dateIncrement = TimeInterval(minutes: 15)

@IBAction func decrement() {
carbValue -= 5
switch inputMode {
case .value:
carbValue -= valueIncrement
case .date:
date -= dateIncrement
}
}

@IBAction func increment() {
carbValue += 5
switch inputMode {
case .value:
carbValue += valueIncrement
case .date:
date += dateIncrement
}
}

@IBAction func toggleInputMode() {
inputMode = (inputMode == .value) ? .date : .value
}

@IBAction func setAbsorptionTimeFast() {
Expand All @@ -98,7 +158,7 @@ final class AddCarbsInterfaceController: WKInterfaceController, IdentifiableClas

@IBAction func save() {
if carbValue > 0 {
let entry = CarbEntryUserInfo(value: Double(carbValue), absorptionTimeType: absorptionTime, startDate: Date())
let entry = CarbEntryUserInfo(value: Double(carbValue), absorptionTimeType: absorptionTime, startDate: date)

do {
try WCSession.default.sendCarbEntryMessage(entry,
Expand All @@ -124,17 +184,24 @@ final class AddCarbsInterfaceController: WKInterfaceController, IdentifiableClas

// MARK: - Crown Sequencer

fileprivate var accumulatedRotation: Double = 0
private var accumulatedRotation: Double = 0
}

fileprivate let rotationsPerCarb: Double = 1/24
private let rotationsPerIncrement: Double = 1/24

extension AddCarbsInterfaceController: WKCrownDelegate {
func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) {
accumulatedRotation += rotationalDelta
let remainder = accumulatedRotation.truncatingRemainder(dividingBy: rotationsPerIncrement)
let delta = (accumulatedRotation - remainder) / rotationsPerIncrement

switch inputMode {
case .value:
carbValue += Int(delta)
case .date:
date += TimeInterval(minutes: delta)
}

let remainder = accumulatedRotation.truncatingRemainder(dividingBy: rotationsPerCarb)
carbValue += Int((accumulatedRotation - remainder) / rotationsPerCarb)
accumulatedRotation = remainder
}
}
98 changes: 58 additions & 40 deletions WatchApp/Base.lproj/Interface.storyboard
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="rNf-Mh-tID">
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="13529" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="rNf-Mh-tID">
<device id="watch42" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="watchOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="12029"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="13507"/>
</dependencies>
<scenes>
<!--AddCarbsInterfaceController-->
Expand All @@ -16,68 +16,85 @@
<items>
<group width="1" height="1" alignment="left" layout="vertical" spacing="1" id="uPt-Z4-ngs">
<items>
<group width="1" alignment="left" spacing="0.0" id="WLN-cX-0wl">
<group width="1" alignment="left" layout="vertical" id="hwe-wE-KAr">
<items>
<group width="22" height="22" alignment="left" verticalAlignment="center" radius="11" id="J90-Xm-Znp">
<group width="1" height="0.25" alignment="left" spacing="0.0" id="WLN-cX-0wl">
<items>
<button width="22" height="22" alignment="left" verticalAlignment="center" accessibilityLabel="Subtract" title="−" id="Dh9-HV-fXy">
<color key="titleColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="0.14000000000000001" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" type="system" weight="semibold" pointSize="20"/>
<connections>
<action selector="decrement" destination="zh0-gB-D44" id="6k1-iq-yYz"/>
</connections>
</button>
<group width="22" height="22" alignment="left" verticalAlignment="center" radius="11" id="J90-Xm-Znp">
<items>
<button width="22" height="22" alignment="left" verticalAlignment="center" accessibilityLabel="Subtract" title="−" id="Dh9-HV-fXy">
<color key="titleColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="0.14000000000000001" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" type="system" weight="semibold" pointSize="20"/>
<connections>
<action selector="decrement" destination="zh0-gB-D44" id="FdO-GD-e1m"/>
</connections>
</button>
</items>
</group>
<label height="37" alignment="center" text="15" id="CWt-7U-cnK">
<color key="textColor" red="0.38985729217529297" green="0.85640043020248413" blue="0.21795386075973511" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" type="system" pointSize="40"/>
</label>
<group width="22" height="22" alignment="right" verticalAlignment="center" radius="11" id="6ip-X6-F2J">
<items>
<button width="22" height="22" alignment="right" verticalAlignment="center" accessibilityLabel="Add" title="+" id="eu3-pj-GH3">
<color key="titleColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="0.14000000000000001" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" type="system" weight="semibold" pointSize="20"/>
<connections>
<action selector="increment" destination="zh0-gB-D44" id="6yb-Y8-oKu"/>
</connections>
</button>
</items>
</group>
</items>
</group>
<label height="37" alignment="center" text="15" textAlignment="center" id="E5r-2c-UZm">
<color key="textColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" type="system" weight="light" pointSize="40"/>
<label alignment="center" text="10:09 AM" id="Ury-of-vQg">
<color key="textColor" cocoaTouchSystemColor="lightTextColor"/>
<fontDescription key="font" type="system" pointSize="15"/>
</label>
<group width="22" height="22" alignment="right" verticalAlignment="center" radius="11" id="6ip-X6-F2J">
<items>
<button width="22" height="22" alignment="right" verticalAlignment="center" accessibilityLabel="Add" title="+" id="eu3-pj-GH3">
<color key="titleColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="0.14000000000000001" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" type="system" weight="semibold" pointSize="20"/>
<connections>
<action selector="increment" destination="zh0-gB-D44" id="itV-Ss-2Cc"/>
</connections>
</button>
</items>
</group>
<separator alignment="left" id="psX-Zk-dTM">
<color key="color" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</separator>
</items>
<gestureRecognizers>
<tapGestureRecognizer id="ZKu-em-Fme">
<connections>
<action selector="toggleInputMode" destination="zh0-gB-D44" id="iNJ-Rq-8w7"/>
</connections>
</tapGestureRecognizer>
</gestureRecognizers>
</group>
<label alignment="center" text="GRAMS" textAlignment="center" id="18G-mT-92P">
<color key="textColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" style="UICTFontTextStyleCaption2"/>
</label>
<separator alignment="left" id="psX-Zk-dTM">
<color key="color" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</separator>
<group width="1" alignment="left" spacing="0.0" id="XMa-yL-87D">
<group width="1" height="0.25" alignment="center" verticalAlignment="center" spacing="0.0" id="XMa-yL-87D">
<items>
<button width="0.33000000000000002" alignment="left" title="🍭" id="gAn-qe-OvX">
<button width="0.33000000000000002" height="1" alignment="left" title="🍭" id="gAn-qe-OvX">
<fontDescription key="font" type="system" pointSize="25"/>
<connections>
<action selector="setAbsorptionTimeFast" destination="zh0-gB-D44" id="Eoj-WC-Fod"/>
</connections>
</button>
<button width="0.33000000000000002" alignment="left" title="🌮" id="0fo-Z3-hTi">
<button width="0.33000000000000002" height="1" alignment="left" title="🌮" id="0fo-Z3-hTi">
<color key="backgroundColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" type="system" pointSize="25"/>
<connections>
<action selector="setAbsorptionTimeMedium" destination="zh0-gB-D44" id="GXY-aa-sz8"/>
</connections>
</button>
<button width="0.33000000000000002" alignment="left" title="🍕" id="dPF-QZ-sh6">
<button width="0.33000000000000002" height="1" alignment="left" title="🍕" id="dPF-QZ-sh6">
<fontDescription key="font" type="system" pointSize="25"/>
<connections>
<action selector="setAbsorptionTimeSlow" destination="zh0-gB-D44" id="qa3-FG-c9F"/>
</connections>
</button>
</items>
</group>
<separator alignment="left" id="arf-ic-MQs">
<color key="color" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</separator>
<separator alignment="left" id="EVD-AC-w2R">
<color key="color" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</separator>
<button width="1" alignment="left" verticalAlignment="bottom" title="Add Carbs" id="b6f-3I-jki">
<color key="backgroundColor" red="0.38823529410000002" green="0.85490196080000003" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="font" type="system" weight="semibold" pointSize="15"/>
Expand All @@ -92,7 +109,8 @@
<outlet property="absorptionButtonA" destination="gAn-qe-OvX" id="mMN-LG-P3Q"/>
<outlet property="absorptionButtonB" destination="0fo-Z3-hTi" id="bPH-HR-eTF"/>
<outlet property="absorptionButtonC" destination="dPF-QZ-sh6" id="KfE-KO-HcS"/>
<outlet property="valueLabel" destination="E5r-2c-UZm" id="oll-hK-YCN"/>
<outlet property="dateLabel" destination="Ury-of-vQg" id="tRT-Eb-SVK"/>
<outlet property="valueLabel" destination="CWt-7U-cnK" id="hJE-ER-FQy"/>
</connections>
</controller>
</objects>
Expand Down