-
Notifications
You must be signed in to change notification settings - Fork 8
nate/fix/LOOP-1927/manual-glucose-entry #256
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
Changes from 6 commits
8a38b70
0997628
f85bf26
e45842d
4f3e896
85ff522
7efb717
188a34a
fefdcb9
2dce93d
2d5d36a
51b99f0
82056ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -536,8 +536,14 @@ extension DeviceDataManager { | |
| return pumpManager?.status | ||
| } | ||
|
|
||
| var sensorState: SensorDisplayable? { | ||
| return cgmManager?.sensorState | ||
| func sensorState(for glucose: GlucoseSampleValue?) -> SensorDisplayable? { | ||
|
||
| if let glucose = glucose, glucose.wasUserEntered { | ||
| // the CGM manager needs to determine the glucoseValueType for a manual glucose based on its managed glucose thresholds | ||
| let glucoseValueType = (cgmManager as? CGMManagerUI)?.glucoseValueType(for: glucose) | ||
|
||
| return ManualGlucoseState(glucoseValueType: glucoseValueType) | ||
| } else { | ||
| return cgmManager?.sensorState | ||
| } | ||
| } | ||
|
|
||
| func updatePumpManagerBLEHeartbeatPreference() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // | ||
| // ManualGlucoseState.swift | ||
| // Loop | ||
| // | ||
| // Created by Nathaniel Hamming on 2020-09-18. | ||
| // Copyright © 2020 LoopKit Authors. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
| import LoopKit | ||
|
|
||
| struct ManualGlucoseState: SensorDisplayable { | ||
|
||
| let isStateValid: Bool | ||
| let trendType: GlucoseTrend? | ||
| let isLocal: Bool | ||
| let glucoseValueType: GlucoseValueType? | ||
|
|
||
| init(glucoseValueType: GlucoseValueType?) { | ||
| isStateValid = true | ||
| trendType = nil | ||
| isLocal = true | ||
| self.glucoseValueType = glucoseValueType | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,8 @@ public class CGMStatusHUDViewModel { | |
|
|
||
| var glucoseTrendTintColor: UIColor = .glucoseTintColor | ||
|
|
||
| var isManualGlucose: Bool = false | ||
|
|
||
| var staleGlucoseValueHandler: (String) -> Void | ||
|
|
||
| var isVisible: Bool = true { | ||
|
|
@@ -73,7 +75,8 @@ public class CGMStatusHUDViewModel { | |
| at glucoseStartDate: Date, | ||
| unit: HKUnit, | ||
| staleGlucoseAge: TimeInterval, | ||
| sensor: SensorDisplayable?) | ||
| sensor: SensorDisplayable?, | ||
| isManualGlucose: Bool) | ||
| { | ||
| var accessibilityStrings = [String]() | ||
|
|
||
|
|
@@ -108,7 +111,9 @@ public class CGMStatusHUDViewModel { | |
| } | ||
|
|
||
| glucoseValueTintColor = sensor?.glucoseValueType?.glucoseColor ?? .label | ||
| glucoseTrendTintColor = sensor?.glucoseValueType?.trendColor ?? .glucoseTintColor | ||
| glucoseTrendTintColor = isManualGlucose ? .destructive : sensor?.glucoseValueType?.trendColor ?? .glucoseTintColor | ||
|
||
|
|
||
| self.isManualGlucose = isManualGlucose | ||
|
|
||
| unitsString = unit.localizedShortUnitString | ||
| accessibilityString = accessibilityStrings.joined(separator: ", ") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the hud adjust its view itself if it's not given enough room? Adjust views depending on the size given would seem to be the view's responsibility, not a user of the view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overlooked this comment. Will do.