Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating #2

Merged
merged 170 commits into from
Oct 31, 2016
Merged
Changes from 1 commit
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
127da85
Fixing old targets in schemes
loudnate Jul 12, 2016
28172f9
Early prototyping of workout mode
loudnate Jul 12, 2016
52977a5
Adjusting the enable/disable interface
loudnate Jul 14, 2016
6ad0bba
Using the configured workout range from LoopKit
loudnate Jul 16, 2016
8f20eba
Updating LoopKit to 0.3.5
loudnate Jul 16, 2016
276b832
Fixing tests
loudnate Jul 16, 2016
f58244f
Merge pull request #69 from loudnate/workout-mode
loudnate Jul 17, 2016
862f7d4
Displaying the units when highlighting chart values, and re-using hig…
loudnate Jul 16, 2016
9dc486f
git mv
loudnate Jul 17, 2016
b35b2aa
Fixing project file
loudnate Jul 17, 2016
17c6f62
Merge pull request #70 from loudnate/chart-improvements
loudnate Jul 17, 2016
755b4d0
Update for x22 Pumps to Display Reservoir Status HUD (#71)
jlucasvt Jul 17, 2016
193074b
Adding a duration selection action sheet for workout targets
loudnate Jul 18, 2016
1c5dc45
Merge pull request #73 from loudnate/workout-target-duration
loudnate Jul 18, 2016
4eb5490
Adding support for Minimed CGM data
loudnate Jul 18, 2016
a523ac2
Updating README
loudnate Jul 18, 2016
d8aa6b7
Merge pull request #74 from loudnate/minimed-glucose
loudnate Jul 18, 2016
1cb0bf0
Updating RileyLink frameworks
loudnate Jul 21, 2016
fd483d9
Merge pull request #76 from loudnate/rl
loudnate Jul 21, 2016
4e045cb
Version 0.7.0
loudnate Jul 21, 2016
7620a23
Making it easier to null-out the nightscout credentials
loudnate Jul 21, 2016
34532f9
Removes RemoteSettings.plist from the project
loudnate Jul 21, 2016
aca213e
Removes support for RemoteSettings.plist
loudnate Jul 21, 2016
04884e9
Merge pull request #78 from loudnate/remote-settings
loudnate Jul 21, 2016
c21b788
Merge pull request #77 from loudnate/dev
loudnate Jul 21, 2016
ea0afd7
Using project-wide bundle versioning
loudnate Jul 21, 2016
dd1105c
Update to RL 0.7.1 frameworks
ps2 Jul 21, 2016
291e509
Highlight project selection on bundle identifier screenshot
ps2 Jul 21, 2016
0a5f1d6
Show version on settings page as top section header
ps2 Jul 21, 2016
bdcd0c0
Merge pull request #80 from ps2/rl-deps-update
loudnate Jul 22, 2016
9aa09ca
Merge pull request #82 from ps2/show-version
loudnate Jul 22, 2016
0cf5070
Merge pull request #81 from ps2/highlight-project-selection
loudnate Jul 22, 2016
dd016ac
Version 0.7.1
loudnate Jul 22, 2016
8d8d541
Merge pull request #83 from loudnate/dev
loudnate Jul 22, 2016
1029ee2
Add support for G4 Share over BLE
mddub Jul 24, 2016
01a765a
Commit xDripG4Share.framework
mddub Jul 25, 2016
e7b07f9
Update README.md
apabari Jul 25, 2016
646e93d
Merge pull request #90 from apabari/patch-1
loudnate Jul 25, 2016
83d902e
map/filter -> flatMap
mddub Jul 25, 2016
862fb0a
xDripG4Share -> G4ShareSpy
mddub Jul 28, 2016
30b50fc
Merge pull request #89 from mddub/add-g4-share-ble
loudnate Jul 29, 2016
5e888a6
Leveraging protocols to simplify multiple sources of glucose
loudnate Jul 29, 2016
9cdd499
Merge pull request #91 from loudnate/protocol-cleanup
loudnate Jul 30, 2016
486d157
Updating README to reflect G4 w/ Share support!
loudnate Jul 30, 2016
511fb64
Reflecting @mddub's LICENSE
loudnate Jul 30, 2016
ad893ec
Clarifying x23 support
loudnate Jul 30, 2016
7b494ad
Updating screenshots
loudnate Jul 30, 2016
5e3a2f0
mvers 0.8.0
loudnate Jul 30, 2016
8d457b2
Merge pull request #92 from loudnate/dev
loudnate Jul 31, 2016
215606f
Update documentation for MM554 pump (#93)
johnmales Jul 31, 2016
5dbbe30
Cleaning up SettingsTableViewController a bit
loudnate Jul 31, 2016
ce7f8cc
Merge pull request #94 from loudnate/settings-cleanup
loudnate Jul 31, 2016
0cb7a98
Updating to LoopKit 0.4.0 (#95)
loudnate Aug 1, 2016
6a238eb
Fixing glucose trend on the watch
loudnate Aug 2, 2016
910233e
Reporting pump status from x22 devices (#99)
ps2 Aug 4, 2016
60c98e5
Adjustments to pump status uploading: (#101)
loudnate Aug 5, 2016
2be6d40
Update G4ShareSpy to 0.2.1 (#102)
mddub Aug 6, 2016
640e45f
Fixing the watch description (#103)
loudnate Aug 6, 2016
6870b09
reservoir change analytics, readme update (#105)
loudnate Aug 6, 2016
77d94bd
Merge pull request #104 from loudnate/dev
loudnate Aug 6, 2016
4d5f0d0
Updating versions
loudnate Aug 6, 2016
b06d3e1
Updating dev version
loudnate Aug 6, 2016
e6b0fa6
Updating xDripG5 (#106)
loudnate Aug 7, 2016
402b201
Fixing glucose state display, and fixing graph whitespace (#107)
loudnate Aug 7, 2016
3ff93e9
Graphing glucose using the system's preferred unit (#108)
loudnate Aug 7, 2016
664a4a3
Update G4ShareSpy to 0.2.2 (#111)
mddub Aug 9, 2016
2c1d82f
Add change context for the LoopDataUpdatedNotification (#112)
loudnate Aug 9, 2016
240995a
Loop status upload (#110)
ps2 Aug 11, 2016
0bdd2ee
Marking classes as final (#115)
loudnate Aug 11, 2016
d7ff802
Loop status upload disable (#118)
ps2 Aug 12, 2016
4ed60e2
LoopKit 0.5.1 (#119)
loudnate Aug 13, 2016
88d1621
Fixing arrows rendering as emoji (#122)
loudnate Aug 17, 2016
67aeca6
new-marketing-version 0.10.0
loudnate Aug 18, 2016
d2f7d53
Add the critical issues mailing list link to README
loudnate Aug 18, 2016
c38e71a
Remove "beta" label from G4 Share Receiver (#126)
mddub Aug 19, 2016
df59a1f
Merge pull request #116 from loudnate/dev
loudnate Aug 20, 2016
745193f
Updating Amplitude framework to 3.8.4
loudnate Aug 20, 2016
a6d7d8e
Removing old project ref
loudnate Aug 20, 2016
97fcc08
Merge pull request #129 from loudnate/amplitude
loudnate Aug 20, 2016
66311be
Upload to loop plugin (#132)
ps2 Aug 27, 2016
7447db9
Version bump
loudnate Aug 27, 2016
0bc3ce4
Merge pull request #136 from loudnate/dev
loudnate Aug 27, 2016
ba63f6b
Saving pump history into LoopKit and delegating upload to Nightscout …
loudnate Aug 27, 2016
ccf05cb
0.11.0
loudnate Aug 27, 2016
5115dca
Hide the navigation bar on the status screen to give more vertical sp…
loudnate Aug 28, 2016
1d030ac
Adding a current glucose HUD
loudnate Aug 4, 2016
d352ff0
Reverting font weight change
loudnate Aug 7, 2016
4753b48
Getting insulin dosing data from pump event history
loudnate Aug 27, 2016
326952c
Update Amplitude.framework
loudnate Aug 31, 2016
7628aff
Update Amplitude.framework (#143)
loudnate Aug 31, 2016
47c8ba9
Updating LoopKit to 0.6.0.
loudnate Aug 31, 2016
0f28464
LoopKit 0.6.0: Event History preference and safety considerations (#144)
loudnate Aug 31, 2016
d2cefde
Version 0.12.0
loudnate Aug 31, 2016
7d536c0
Provide bolus amount suggestions for all watch boluses, and honor max…
loudnate Aug 31, 2016
5e260d1
Provide bolus amount suggestions for all watch boluses, and honor max…
loudnate Aug 31, 2016
1cfc97d
Grammar
loudnate Aug 31, 2016
ee27fa8
0.11.0... oops.
loudnate Aug 31, 2016
3573ed9
Merge branch 'dev' of github.com:loudnate/Loop into dev
loudnate Aug 31, 2016
35090a0
Fix order of pump events delivered to NightscoutUploadKit (#147)
loudnate Sep 1, 2016
2ebe5d9
Merge pull request #146 from loudnate/dev
loudnate Sep 3, 2016
70070c8
Changing the bundle identifier setup process (#151)
loudnate Sep 3, 2016
2c62c17
Upgrade to LoopKit 0.7.0 (#152)
loudnate Sep 3, 2016
1f8ce5d
RileyLink 0.11.1 upgrade (#153)
ps2 Sep 4, 2016
54fadae
Version 0.11.1
loudnate Sep 4, 2016
ad5c27a
Merge pull request #154 from loudnate/dev
loudnate Sep 4, 2016
9001c7c
Color and Icons (#149)
loudnate Sep 5, 2016
3316fa4
Update to RileyLink frameworks v0.11.2
ps2 Sep 5, 2016
fe102ae
v0.11.2
loudnate Sep 5, 2016
7891a88
Merge pull request #162 from ps2/temp-basal-upload-fix
ps2 Sep 6, 2016
f65db57
Adding an interactive display to visualize prediction (#160)
loudnate Sep 7, 2016
2d2ec63
Fix for display of glucose (#163)
beached Sep 10, 2016
0d4a107
Display sensor state as a binary warning on the glucose HUD (#164)
loudnate Sep 11, 2016
c7bceaf
Merge branch 'master' into dev
loudnate Sep 11, 2016
e20a0ac
Merge pull request #165 from loudnate/dev
loudnate Sep 11, 2016
aad268b
Xcode 8 + Swift 3 (#167)
loudnate Sep 17, 2016
27a37e5
agvtool bump
loudnate Sep 17, 2016
74f9aef
Merge pull request #168 from loudnate/dev
loudnate Sep 17, 2016
78472fa
Prevent recommending a temp basal right after a bolus was set (#176)
loudnate Sep 19, 2016
d4ca38a
Updates to RileyLink 0.12.1.
loudnate Sep 20, 2016
220471e
Remove development team
loudnate Sep 20, 2016
89eea3b
Merge pull request #178 from loudnate/dev
loudnate Sep 20, 2016
c9d6ed6
Glucose chart range (#179)
channemann Sep 21, 2016
8ed7522
Missed a few casts during Swift 3 migration (#182)
loudnate Sep 22, 2016
78e8c0b
Fixing the removal of Pump and G5 Transmitter ID (#183)
loudnate Sep 22, 2016
cb6deb1
Minor chart improvements (#184)
loudnate Sep 23, 2016
f836e0e
Fixing a crash in the last commit when no COB data is available (#187)
loudnate Sep 24, 2016
01b22c2
Update RileyLink dependency to use hotfix 0.12.2 for high basal rates
ps2 Sep 25, 2016
a0ecb82
Merge pull request #189 from ps2/hotfix-basal-rate-decoding
ps2 Sep 25, 2016
69b7bfd
Merge pull request #190 from loudnate/master
loudnate Sep 26, 2016
7701ed1
Show recommended basal only when applicable, at the top of the graph …
loudnate Sep 27, 2016
2b8392b
Improving VoiceOver accessibility for the HUD and Bolus screens (#192)
loudnate Sep 28, 2016
339625b
Graph improvements (#193)
loudnate Sep 29, 2016
58dbe87
RileyLink 0.12.3 (#194)
loudnate Sep 29, 2016
d2c8904
Updated app icon (#197)
loudnate Sep 29, 2016
e53c4d5
Ensuring service credentials can be removed from the Keychain (#196)
loudnate Sep 29, 2016
8444e1d
Merge pull request #195 from loudnate/dev
loudnate Sep 29, 2016
2265776
Version bump
loudnate Sep 29, 2016
1c8b1c6
Migrate to UserNotifications.framework for iOS 10 (#175)
loudnate Sep 23, 2016
5806ace
watchOS 3 support (#185)
loudnate Sep 23, 2016
02cf86b
Merge pull request #198 from loudnate/ios10
loudnate Sep 29, 2016
04f9c79
Better fix for #159 (#199)
loudnate Sep 30, 2016
eb678fe
Version bump
loudnate Sep 30, 2016
5c8a113
Updating xDripG5 (#201)
loudnate Sep 30, 2016
0032c31
Displaying an indicator for glucose values downloaded from Share (#202)
loudnate Oct 1, 2016
57445d6
Using the crown sequencer directly for carb/bolus input (#203)
loudnate Oct 1, 2016
0bab4d8
Fixing disappearing chart on rotation.
loudnate Oct 1, 2016
36d39c0
Showing where carb absorption defaults can be overridden (#206)
loudnate Oct 1, 2016
cacf2c2
Fixing watch app changes. (#207)
loudnate Oct 1, 2016
0eee072
Fixed typo (#208)
beached Oct 1, 2016
830553b
LoopKit 1.0, WW switch, Report Issue button (#209)
loudnate Oct 1, 2016
a505fd8
Updating RileyLink (#210)
loudnate Oct 1, 2016
6cf7790
git commit -a -m "Version 1.0rc1"
loudnate Oct 1, 2016
5aa4d42
Merge pull request #211 from LoopKit/dev
loudnate Oct 1, 2016
52fc355
Preventing truncation of insulin action duration (Fixes #213) (#214)
loudnate Oct 2, 2016
8bbedd5
Updating LoopKit and RileyLinkKit with more conservative support for …
loudnate Oct 3, 2016
16cec2e
1.0
loudnate Oct 3, 2016
785d7b4
Merge pull request #216 from LoopKit/dev
loudnate Oct 3, 2016
1627ada
Fix Gitter Button
channemann Oct 6, 2016
25b44ea
Merge pull request #218 from LoopKit/gitter-button-fix
channemann Oct 6, 2016
558e674
Upload carbs-on-board to Nightscout
mddub Oct 20, 2016
d995753
Merge pull request #228 from mddub/cob-to-nightscout
mddub Oct 21, 2016
17e97e2
Update README.md
ps2 Oct 22, 2016
b221ebc
Update README.md
ps2 Oct 22, 2016
4be7b47
Update README.md
ps2 Oct 22, 2016
6c4b149
Update README.md
ps2 Oct 22, 2016
99def0c
Update README.md
ps2 Oct 22, 2016
5a49c90
Upload carbs (#229)
ps2 Oct 23, 2016
ab4842a
Bump version to 1.1
ps2 Oct 23, 2016
5e71bab
Merge pull request #230 from LoopKit/version-bump
ps2 Oct 23, 2016
997f982
Merge pull request #231 from LoopKit/dev
ps2 Oct 23, 2016
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
Displaying the units when highlighting chart values, and re-using hig…
…hlight views while panning.
loudnate committed Jul 17, 2016
commit 862f7d4f116add1cb86ac1345f1921a0810830d7
4 changes: 4 additions & 0 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -126,6 +126,7 @@
43EB40861C82646A00472A8C /* StatusChartManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EB40851C82646A00472A8C /* StatusChartManager.swift */; };
43EB40C21C83F84900472A8C /* StatusChartHighlightLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EB40C11C83F84900472A8C /* StatusChartHighlightLayer.swift */; };
43EDDBF31C361C75007D89B5 /* xDripG5.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43EDDBF11C361C75007D89B5 /* xDripG5.framework */; };
43F41C331D3A17AA00C11ED6 /* ChartAxisValueDoubleUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F41C321D3A17AA00C11ED6 /* ChartAxisValueDoubleUnit.swift */; };
43F4EF1D1BA2A57600526CE1 /* DiagnosticLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F4EF1C1BA2A57600526CE1 /* DiagnosticLogger.swift */; };
43F5C2C91B929C09003EB13D /* HealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43F5C2C81B929C09003EB13D /* HealthKit.framework */; };
43F5C2DB1B92A5E1003EB13D /* SettingsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43F5C2DA1B92A5E1003EB13D /* SettingsTableViewController.swift */; };
@@ -337,6 +338,7 @@
43EDDBF51C361D24007D89B5 /* CommonCrypto.framework.dSYM */ = {isa = PBXFileReference; lastKnownFileType = wrapper.dsym; name = CommonCrypto.framework.dSYM; path = Carthage/Build/iOS/CommonCrypto.framework.dSYM; sourceTree = "<group>"; };
43EDDBF61C361D24007D89B5 /* xDripG5.framework.dSYM */ = {isa = PBXFileReference; lastKnownFileType = wrapper.dsym; name = xDripG5.framework.dSYM; path = Carthage/Build/iOS/xDripG5.framework.dSYM; sourceTree = "<group>"; };
43EDEE6B1CF2E12A00393BE3 /* Loop.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Loop.entitlements; sourceTree = "<group>"; };
43F41C321D3A17AA00C11ED6 /* ChartAxisValueDoubleUnit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartAxisValueDoubleUnit.swift; sourceTree = "<group>"; };
43F4EF1C1BA2A57600526CE1 /* DiagnosticLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiagnosticLogger.swift; sourceTree = "<group>"; };
43F5C2C81B929C09003EB13D /* HealthKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HealthKit.framework; path = System/Library/Frameworks/HealthKit.framework; sourceTree = SDKROOT; };
43F5C2D41B92A4A6003EB13D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -434,6 +436,7 @@
43DE92601C555C26001FFDE1 /* AbsorptionTimeType+CarbKit.swift */,
438849EB1D29EC34003B3F23 /* AmplitudeService.swift */,
4331E0791C85650D00FBE832 /* ChartAxisValueDoubleLog.swift */,
43F41C321D3A17AA00C11ED6 /* ChartAxisValueDoubleUnit.swift */,
434F24CA1CFCB7AB0004498F /* GlucoseRxMessage.swift */,
436FACED1D0BA636004E2427 /* InsulinDataSource.swift */,
436A0DA41D236A2A00104B24 /* LoopError.swift */,
@@ -953,6 +956,7 @@
43776F901B8022E90074EA36 /* AppDelegate.swift in Sources */,
437CCADA1D284ADF0075D2C3 /* AuthenticationTableViewCell.swift in Sources */,
43CE7CDE1CA8B63E003CC1B0 /* NSDate.swift in Sources */,
43F41C331D3A17AA00C11ED6 /* ChartAxisValueDoubleUnit.swift in Sources */,
43F5C2DB1B92A5E1003EB13D /* SettingsTableViewController.swift in Sources */,
43B371861CE583890013C5A6 /* BasalStateView.swift in Sources */,
434FF1EA1CF26C29000DB779 /* IdentifiableClass.swift in Sources */,
53 changes: 36 additions & 17 deletions Loop/Managers/StatusChartManager.swift
Original file line number Diff line number Diff line change
@@ -73,23 +73,31 @@ class StatusChartsManager {

var glucoseValues: [GlucoseValue] = [] {
didSet {
glucosePoints = glucoseValues.map({
// TODO: Use the preferred unit
let unit = HKUnit.milligramsPerDeciliterUnit()
let unitString = unit.glucoseUnitDisplayString

glucosePoints = glucoseValues.map {
return ChartPoint(
x: ChartAxisValueDate(date: $0.startDate, formatter: dateFormatter),
y: ChartAxisValueDouble($0.quantity.doubleValueForUnit(HKUnit.milligramsPerDeciliterUnit()))
y: ChartAxisValueDoubleUnit($0.quantity.doubleValueForUnit(unit), unitString: unitString)
)
})
}
}
}

var predictedGlucoseValues: [GlucoseValue] = [] {
didSet {
predictedGlucosePoints = predictedGlucoseValues.map({
// TODO: Use the preferred unit
let unit = HKUnit.milligramsPerDeciliterUnit()
let unitString = unit.glucoseUnitDisplayString

predictedGlucosePoints = predictedGlucoseValues.map {
return ChartPoint(
x: ChartAxisValueDate(date: $0.startDate, formatter: dateFormatter),
y: ChartAxisValueDouble($0.quantity.doubleValueForUnit(HKUnit.milligramsPerDeciliterUnit()), formatter: integerFormatter)
y: ChartAxisValueDoubleUnit($0.quantity.doubleValueForUnit(unit), unitString: unitString, formatter: integerFormatter)
)
})
}
}
}

@@ -98,18 +106,21 @@ class StatusChartsManager {
IOBPoints = IOBValues.map {
return ChartPoint(
x: ChartAxisValueDate(date: $0.startDate, formatter: dateFormatter),
y: ChartAxisValueDouble($0.value, formatter: decimalFormatter)
y: ChartAxisValueDoubleUnit($0.value, unitString: "U", formatter: decimalFormatter)
)
}
}
}

var COBValues: [CarbValue] = [] {
didSet {
let unit = HKUnit.gramUnit()
let unitString = unit.unitString

COBPoints = COBValues.map {
ChartPoint(
x: ChartAxisValueDate(date: $0.startDate, formatter: dateFormatter),
y: ChartAxisValueDouble($0.quantity.doubleValueForUnit(HKUnit.gramUnit()), formatter: integerFormatter)
y: ChartAxisValueDoubleUnit($0.quantity.doubleValueForUnit(unit), unitString: unitString, formatter: integerFormatter)
)
}
}
@@ -122,7 +133,7 @@ class StatusChartsManager {
let startX = ChartAxisValueDate(date: entry.startDate, formatter: dateFormatter)
let endX = ChartAxisValueDate(date: entry.endDate, formatter: dateFormatter)
let zero = ChartAxisValueInt(0)
let value = ChartAxisValueDoubleLog(actualDouble: entry.value, formatter: decimalFormatter)
let value = ChartAxisValueDoubleLog(actualDouble: entry.value, unitString: "U/hour", formatter: decimalFormatter)

let newPoints = [
ChartPoint(x: startX, y: zero),
@@ -214,6 +225,14 @@ class StatusChartsManager {

private var doseChart: Chart?

private var glucoseChartCache: ChartPointsTouchHighlightLayerViewCache?

private var IOBChartCache: ChartPointsTouchHighlightLayerViewCache?

private var COBChartCache: ChartPointsTouchHighlightLayerViewCache?

private var doseChartCache: ChartPointsTouchHighlightLayerViewCache?

// MARK: - Generators

func glucoseChartWithFrame(frame: CGRect) -> Chart? {
@@ -275,7 +294,7 @@ class StatusChartsManager {
prediction = ChartPointsScatterCirclesLayer(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, chartPoints: predictedGlucosePoints, displayDelay: 0, itemSize: CGSize(width: 2, height: 2), itemFillColor: UIColor.glucoseTintColor.colorWithAlphaComponent(0.75))
}

let highlightLayer = StatusChartHighlightLayer(
glucoseChartCache = ChartPointsTouchHighlightLayerViewCache(
xAxis: xAxis,
yAxis: yAxis,
innerFrame: innerFrame,
@@ -292,7 +311,7 @@ class StatusChartsManager {
targetOverrideDurationLayer,
xAxis,
yAxis,
highlightLayer,
glucoseChartCache?.highlightLayer,
prediction,
circles
]
@@ -356,7 +375,7 @@ class StatusChartsManager {
return v
})

let highlightLayer = StatusChartHighlightLayer(
IOBChartCache = ChartPointsTouchHighlightLayerViewCache(
xAxis: xAxis,
yAxis: yAxis,
innerFrame: innerFrame,
@@ -371,7 +390,7 @@ class StatusChartsManager {
xAxis,
yAxis,
zeroGuidelineLayer,
highlightLayer,
IOBChartCache?.highlightLayer,
IOBArea,
IOBLine,
]
@@ -425,7 +444,7 @@ class StatusChartsManager {
let gridLayer = ChartGuideLinesLayer(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, axis: .XAndY, settings: guideLinesLayerSettings, onlyVisibleX: true, onlyVisibleY: false)


let highlightLayer = StatusChartHighlightLayer(
COBChartCache = ChartPointsTouchHighlightLayerViewCache(
xAxis: xAxis,
yAxis: yAxis,
innerFrame: innerFrame,
@@ -439,7 +458,7 @@ class StatusChartsManager {
gridLayer,
xAxis,
yAxis,
highlightLayer,
COBChartCache?.highlightLayer,
COBArea,
COBLine
]
@@ -492,7 +511,7 @@ class StatusChartsManager {
return v
})

let highlightLayer = StatusChartHighlightLayer(
doseChartCache = ChartPointsTouchHighlightLayerViewCache(
xAxis: xAxis,
yAxis: yAxis,
innerFrame: innerFrame,
@@ -507,7 +526,7 @@ class StatusChartsManager {
xAxis,
yAxis,
zeroGuidelineLayer,
highlightLayer,
doseChartCache?.highlightLayer,
doseArea,
doseLine
]
13 changes: 12 additions & 1 deletion Loop/Models/ChartAxisValueDoubleLog.swift
Original file line number Diff line number Diff line change
@@ -12,7 +12,9 @@ import SwiftCharts

class ChartAxisValueDoubleLog: ChartAxisValueDoubleScreenLoc {

init(actualDouble: Double, formatter: NSNumberFormatter, labelSettings: ChartLabelSettings = ChartLabelSettings()) {
let unitString: String?

init(actualDouble: Double, unitString: String? = nil, formatter: NSNumberFormatter, labelSettings: ChartLabelSettings = ChartLabelSettings()) {
let screenLocDouble: Double

switch actualDouble {
@@ -24,6 +26,8 @@ class ChartAxisValueDoubleLog: ChartAxisValueDoubleScreenLoc {
screenLocDouble = 0
}

self.unitString = unitString

super.init(screenLocDouble: screenLocDouble, actualDouble: actualDouble, formatter: formatter, labelSettings: labelSettings)
}

@@ -39,7 +43,14 @@ class ChartAxisValueDoubleLog: ChartAxisValueDoubleScreenLoc {
actualDouble = 0
}

self.unitString = nil

super.init(screenLocDouble: screenLocDouble, actualDouble: actualDouble, formatter: formatter, labelSettings: labelSettings)
}

override var description: String {
let suffix = unitString != nil ? " \(unitString!)" : ""

return super.description + suffix
}
}
31 changes: 31 additions & 0 deletions Loop/Models/ChartAxisValueDoubleUnit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// ChartAxisValueDoubleUnit.swift
// Loop
//
// Created by Nate Racklyeft on 7/16/16.
// Copyright © 2016 Nathan Racklyeft. All rights reserved.
//

import UIKit
import SwiftCharts


class ChartAxisValueDoubleUnit: ChartAxisValueDouble {
let unitString: String

init(_ double: Double, unitString: String, formatter: NSNumberFormatter) {
self.unitString = unitString

super.init(double, formatter: formatter)
}

init(_ double: Double, unitString: String) {
self.unitString = unitString

super.init(double)
}

override var description: String {
return "\(super.description) \(unitString)"
}
}
98 changes: 64 additions & 34 deletions Loop/Views/StatusChartHighlightLayer.swift
Original file line number Diff line number Diff line change
@@ -10,73 +10,103 @@ import Foundation
import SwiftCharts


class StatusChartHighlightLayer<T: ChartPoint, U: UIView>: ChartPointsTouchHighlightLayer<T, U> {
init(
xAxis: ChartAxisLayer,
yAxis: ChartAxisLayer,
innerFrame: CGRect,
chartPoints: [T],
tintColor: UIColor,
labelCenterY: CGFloat = 0,
gestureRecognizer: UIPanGestureRecognizer? = nil
) {
super.init(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, chartPoints: chartPoints, gestureRecognizer: gestureRecognizer,
modelFilter: { (screenLoc, chartPointModels) -> ChartPointLayerModel<T>? in
class ChartPointsTouchHighlightLayerViewCache {
private lazy var containerView = UIView(frame: .zero)

private lazy var xAxisOverlayView = UIView()

private lazy var point = ChartPointEllipseView(center: .zero, diameter: 16)

private lazy var labelY: UILabel = {
let label = UILabel()
label.font = UIFont.monospacedDigitSystemFontOfSize(15, weight: UIFontWeightBold)
label.textAlignment = .Center
label.backgroundColor = UIColor.whiteColor()

return label
}()

private lazy var labelX: UILabel = {
let label = UILabel()
label.font = UIFont.preferredFontForTextStyle(UIFontTextStyleCaption1)
label.textColor = UIColor.secondaryLabelColor

return label
}()

private(set) var highlightLayer: ChartPointsTouchHighlightLayer<ChartPoint, UIView>!

init(xAxis: ChartAxisLayer, yAxis: ChartAxisLayer, innerFrame: CGRect, chartPoints: [ChartPoint], tintColor: UIColor, labelCenterY: CGFloat, gestureRecognizer: UIPanGestureRecognizer? = nil) {

highlightLayer = ChartPointsTouchHighlightLayer(
xAxis: xAxis,
yAxis: yAxis,
innerFrame: innerFrame,
chartPoints: chartPoints,
gestureRecognizer: gestureRecognizer,
modelFilter: { (screenLoc, chartPointModels) -> ChartPointLayerModel<ChartPoint>? in
if let index = chartPointModels.map({ $0.screenLoc.x }).findClosestElementIndexToValue(screenLoc.x) {
return chartPointModels[index]
} else {
return nil
}
},
viewGenerator: { (chartPointModel, layer, chart) -> U? in
let containerView = U(frame: chart.bounds)
viewGenerator: { [unowned self] (chartPointModel, layer, chart) -> UIView? in
let containerView = self.containerView
containerView.frame = chart.bounds
containerView.alpha = 1 // This is animated to 0 when touch last ended

let xAxisOverlayView = UIView(frame: xAxis.rect.offsetBy(dx: 0, dy: 1))
xAxisOverlayView.backgroundColor = UIColor.whiteColor()
xAxisOverlayView.opaque = true
containerView.addSubview(xAxisOverlayView)
let xAxisOverlayView = self.xAxisOverlayView
if xAxisOverlayView.superview == nil {
xAxisOverlayView.frame = xAxis.rect.offsetBy(dx: 0, dy: 1)
xAxisOverlayView.backgroundColor = UIColor.whiteColor()
xAxisOverlayView.opaque = true
containerView.addSubview(xAxisOverlayView)
}

let point = ChartPointEllipseView(center: chartPointModel.screenLoc, diameter: 16)
point.fillColor = tintColor.colorWithAlphaComponent(0.5)
containerView.addSubview(point)
let point = self.point
point.center = chartPointModel.screenLoc
if point.superview == nil {
point.fillColor = tintColor.colorWithAlphaComponent(0.5)
containerView.addSubview(point)
}

if let text = chartPointModel.chartPoint.y.labels.first?.text {
let label = UILabel()
label.font = UIFont.monospacedDigitSystemFontOfSize(15, weight: UIFontWeightBold)
let label = self.labelY

label.text = text
label.textColor = tintColor
label.textAlignment = .Center
label.sizeToFit()
label.frame.size.height += 4
label.frame.size.width += label.frame.size.height / 2
label.center.y = innerFrame.origin.y - 1
label.center.x = chartPointModel.screenLoc.x
label.frame.origin.x = min(max(label.frame.origin.x, innerFrame.origin.x), innerFrame.maxX - label.frame.size.width)
label.frame.origin.makeIntegralInPlaceWithDisplayScale(chart.view.traitCollection.displayScale)
label.layer.borderColor = tintColor.CGColor
label.layer.borderWidth = 1 / chart.view.traitCollection.displayScale
label.layer.cornerRadius = label.frame.size.height / 2
label.backgroundColor = UIColor.whiteColor()
label.layer.borderWidth = 1 / max(1, chart.view.traitCollection.displayScale)

if label.superview == nil {
label.textColor = tintColor
label.layer.borderColor = tintColor.CGColor

containerView.addSubview(label)
containerView.addSubview(label)
}
}

if let text = chartPointModel.chartPoint.x.labels.first?.text {
let label = UILabel()
label.font = UIFont.preferredFontForTextStyle(UIFontTextStyleCaption1)
let label = self.labelX
label.text = text
label.textColor = UIColor.secondaryLabelColor
label.sizeToFit()
label.center = CGPoint(x: chartPointModel.screenLoc.x, y: xAxisOverlayView.center.y)
label.frame.origin.makeIntegralInPlaceWithDisplayScale(chart.view.traitCollection.displayScale)

containerView.addSubview(label)
if label.superview == nil {
containerView.addSubview(label)
}
}

return containerView
}
)

}
}