Skip to content

Commit

Permalink
Early prototyping of workout mode
Browse files Browse the repository at this point in the history
  • Loading branch information
loudnate committed Jul 12, 2016
1 parent 127da85 commit 28172f9
Show file tree
Hide file tree
Showing 45 changed files with 359 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github "loudnate/LoopKit" ~> 0.3.4
github "loudnate/LoopKit" "glucose-range-override"
github "loudnate/xDripG5" ~> 0.5.0
github "loudnate/SwiftCharts" "loudnate/naterade"
github "mddub/dexcom-share-client-swift" ~> 0.1
Expand Down
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
github "amplitude/Amplitude-iOS" "a3d6720626e72a678489bce83ed9dacadb505dd7"
github "loudnate/Crypto" "13fee45175b88629aeabe60b4b4fc3daf86fa0a3"
github "loudnate/LoopKit" "v0.3.4"
github "loudnate/LoopKit" "370afac5dd1bd700cf1c57297106f3378d56ff1b"
github "loudnate/SwiftCharts" "8671287afb29640f9cffced6521b1098b7aac085"
github "mddub/dexcom-share-client-swift" "v0.1.3"
github "loudnate/xDripG5" "0.5.0"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 12 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Loop is released under the MIT license (MIT)
With exceptions for frameworks and graphics, noted below.

Copyright (c) 2015 Nathan Racklyeft

Expand Down Expand Up @@ -275,4 +276,14 @@ SwiftCharts is Copyright (c) 2015 Ivan Schütz and released as open source under
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> See the License for the specific language governing permissions and
> limitations under the License.
>
>
# Graphics licensed under CC BY-SA 4.0

## "Carbs Fork"

Designed by Sara Krugman

(C) 2015 Boston University and Tidepool Project

https://creativecommons.org/licenses/by-sa/4.0/
12 changes: 1 addition & 11 deletions Loop.xcodeproj/xcshareddata/xcschemes/WatchApp.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,12 @@
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43F78D2A1C8FC58F002152D1"
BlueprintIdentifier = "43E2D90A1D20C581004DA55F"
BuildableName = "LoopTests.xctest"
BlueprintName = "LoopTests"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43E2D8FC1D20C508004DA55F"
BuildableName = "LoopTests2.xctest"
BlueprintName = "LoopTests2"
ReferencedContainer = "container:Loop.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
Expand Down
12 changes: 12 additions & 0 deletions Loop/Assets.xcassets/bolus.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "bolus.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added Loop/Assets.xcassets/bolus.imageset/bolus.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions Loop/Assets.xcassets/carbs.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "carbs.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added Loop/Assets.xcassets/carbs.imageset/carbs.pdf
Binary file not shown.
40 changes: 40 additions & 0 deletions Loop/Assets.xcassets/settings.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "settings.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
},
{
"idiom" : "universal",
"scale" : "1x",
"height-class" : "compact"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"height-class" : "compact",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"height-class" : "compact",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added Loop/Assets.xcassets/settings.imageset/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Loop/Assets.xcassets/workout-selected.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "workout-selected.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
15 changes: 15 additions & 0 deletions Loop/Assets.xcassets/workout.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "workout.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file added Loop/Assets.xcassets/workout.imageset/workout.pdf
Binary file not shown.
29 changes: 26 additions & 3 deletions Loop/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<accessibility key="accessibilityConfiguration">
<accessibilityTraits key="traits" summaryElement="YES"/>
<bool key="isElement" value="YES"/>
</accessibility>
<constraints>
<constraint firstItem="agu-6n-4Lf" firstAttribute="centerX" secondItem="H3C-gh-Vum" secondAttribute="centerX" id="8cU-Gb-Zpf"/>
<constraint firstAttribute="bottom" secondItem="krM-Ky-OTb" secondAttribute="bottom" id="JM7-AC-KBR"/>
Expand Down Expand Up @@ -247,6 +251,9 @@
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<accessibility key="accessibilityConfiguration">
<bool key="isElement" value="YES"/>
</accessibility>
<constraints>
<constraint firstAttribute="trailingMargin" secondItem="Wkb-m1-PVZ" secondAttribute="trailing" id="20s-OF-j7K"/>
<constraint firstItem="AbR-sM-aVG" firstAttribute="top" secondItem="BEG-xe-e6y" secondAttribute="top" constant="8" id="5Un-T7-Hcy"/>
Expand Down Expand Up @@ -289,6 +296,9 @@
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<accessibility key="accessibilityConfiguration">
<bool key="isElement" value="YES"/>
</accessibility>
<constraints>
<constraint firstItem="TfZ-En-Kls" firstAttribute="leading" secondItem="uVa-hu-HBZ" secondAttribute="leadingMargin" id="95H-Dr-Ehg"/>
<constraint firstAttribute="trailingMargin" secondItem="TfZ-En-Kls" secondAttribute="trailing" id="fAL-fC-zik"/>
Expand Down Expand Up @@ -327,6 +337,9 @@
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<accessibility key="accessibilityConfiguration">
<bool key="isElement" value="YES"/>
</accessibility>
<constraints>
<constraint firstItem="LaA-uX-OgX" firstAttribute="top" secondItem="Jjc-jK-Vci" secondAttribute="bottom" constant="4" id="9Nu-VX-htt"/>
<constraint firstAttribute="bottom" secondItem="LaA-uX-OgX" secondAttribute="bottom" id="C7U-r6-wZ8"/>
Expand Down Expand Up @@ -391,19 +404,25 @@
</connections>
</tableView>
<toolbarItems>
<barButtonItem title="Add Meal" id="lpE-RX-jWF">
<barButtonItem image="carbs" id="lpE-RX-jWF">
<connections>
<segue destination="YJ1-01-QoA" kind="presentation" identifier="CarbEntryEditViewController" id="viB-eQ-p7y"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="ava-EZ-v6i"/>
<barButtonItem title="Bolus" id="2kb-DB-Vag">
<barButtonItem image="bolus" id="2kb-DB-Vag">
<connections>
<segue destination="m6L-HW-ENd" kind="presentation" identifier="BolusViewController" id="PC7-vP-CUY"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="g6k-L0-2qh"/>
<barButtonItem enabled="NO" image="workout" id="8Qz-Cj-oVB">
<connections>
<action selector="toggleWorkoutMode:" destination="1zR-tC-i50" id="coy-UU-6Zu"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="d5h-bj-8ek"/>
<barButtonItem title="Settings" id="PHJ-4n-qiF">
<barButtonItem image="settings" id="PHJ-4n-qiF">
<connections>
<segue destination="Fr0-ut-OuL" kind="presentation" id="JAY-Kf-UMv"/>
</connections>
Expand Down Expand Up @@ -656,6 +675,10 @@
</scenes>
<resources>
<image name="battery_unknown" width="27" height="44"/>
<image name="bolus" width="22" height="23"/>
<image name="carbs" width="22" height="23"/>
<image name="reservoir_unknown" width="27" height="44"/>
<image name="settings" width="25" height="40"/>
<image name="workout" width="30" height="29"/>
</resources>
</document>
46 changes: 46 additions & 0 deletions Loop/Extensions/ChartPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,52 @@ extension ChartPoint {

return maxPoints + minPoints.reverse()
}

static func pointsForGlucoseRangeScheduleOverrideDuration(override: AbsoluteScheduleValue<DoubleRange>, xAxisValues: [ChartAxisValue]) -> [ChartPoint] {
let startDate = NSDate()

guard override.endDate.timeIntervalSinceDate(startDate) > 0,
let lastXAxisValue = xAxisValues.last as? ChartAxisValueDate
else {
return []
}

let dateFormatter = NSDateFormatter()
let startDateAxisValue = ChartAxisValueDate(date: startDate, formatter: dateFormatter)
let endDateAxisValue = ChartAxisValueDate(date: lastXAxisValue.date.earlierDate(override.endDate), formatter: dateFormatter)
let minValue = ChartAxisValueDouble(override.value.minValue)
let maxValue = ChartAxisValueDouble(override.value.maxValue)

return [
ChartPoint(x: startDateAxisValue, y: maxValue),
ChartPoint(x: endDateAxisValue, y: maxValue),
ChartPoint(x: endDateAxisValue, y: minValue),
ChartPoint(x: startDateAxisValue, y: minValue)
]
}

static func pointsForGlucoseRangeScheduleOverride(override: AbsoluteScheduleValue<DoubleRange>, xAxisValues: [ChartAxisValue]) -> [ChartPoint] {
let startDate = NSDate()

guard override.endDate.timeIntervalSinceDate(startDate) > 0,
let lastXAxisValue = xAxisValues.last as? ChartAxisValueDate
else {
return []
}

let dateFormatter = NSDateFormatter()
let startDateAxisValue = ChartAxisValueDate(date: startDate, formatter: dateFormatter)
let endDateAxisValue = ChartAxisValueDate(date: lastXAxisValue.date, formatter: dateFormatter)
let minValue = ChartAxisValueDouble(override.value.minValue)
let maxValue = ChartAxisValueDouble(override.value.maxValue)

return [
ChartPoint(x: startDateAxisValue, y: maxValue),
ChartPoint(x: endDateAxisValue, y: maxValue),
ChartPoint(x: endDateAxisValue, y: minValue),
ChartPoint(x: startDateAxisValue, y: minValue)
]
}
}


4 changes: 4 additions & 0 deletions Loop/Extensions/UIImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ extension UIImage {
static func reservoirHUDImageWithLevel(level: Double?) -> UIImage? {
return UIImage(named: "reservoir_\(imageSuffixForLevel(level))")
}

static func workoutImage(selected selected: Bool) -> UIImage? {
return UIImage(named: selected ? "workout-selected" : "workout")
}
}
Loading

0 comments on commit 28172f9

Please sign in to comment.