diff --git a/Loop/Base.lproj/Main.storyboard b/Loop/Base.lproj/Main.storyboard index 9b3583fa92..7389695acf 100644 --- a/Loop/Base.lproj/Main.storyboard +++ b/Loop/Base.lproj/Main.storyboard @@ -18,7 +18,7 @@ - + @@ -46,21 +46,21 @@ - + - + - + - + @@ -123,7 +123,7 @@ - + @@ -165,7 +165,7 @@ - + @@ -197,7 +197,7 @@ - + @@ -662,7 +662,7 @@ - + @@ -704,7 +704,7 @@ - + @@ -745,7 +745,7 @@ - + diff --git a/Loop/Models/Glucose.swift b/Loop/Models/Glucose.swift index 4907322953..0ae2ca0cb1 100644 --- a/Loop/Models/Glucose.swift +++ b/Loop/Models/Glucose.swift @@ -51,4 +51,8 @@ extension Glucose: SensorDisplayable { return .upUpUp } } + + var isLocal: Bool { + return true + } } diff --git a/Loop/Models/GlucoseG4.swift b/Loop/Models/GlucoseG4.swift index da4603c138..30df44498d 100644 --- a/Loop/Models/GlucoseG4.swift +++ b/Loop/Models/GlucoseG4.swift @@ -39,4 +39,8 @@ extension GlucoseG4: SensorDisplayable { var trendType: GlucoseTrend? { return GlucoseTrend(rawValue: Int(trend)) } + + var isLocal: Bool { + return true + } } diff --git a/Loop/Models/MySentryPumpStatusMessageBody.swift b/Loop/Models/MySentryPumpStatusMessageBody.swift index f2ce8a911d..253a0423e7 100644 --- a/Loop/Models/MySentryPumpStatusMessageBody.swift +++ b/Loop/Models/MySentryPumpStatusMessageBody.swift @@ -38,4 +38,8 @@ extension MySentryPumpStatusMessageBody: SensorDisplayable { return .flat } } + + var isLocal: Bool { + return true + } } diff --git a/Loop/Models/SensorDisplayable.swift b/Loop/Models/SensorDisplayable.swift index 7cf7723110..f71838e3dd 100644 --- a/Loop/Models/SensorDisplayable.swift +++ b/Loop/Models/SensorDisplayable.swift @@ -18,6 +18,9 @@ protocol SensorDisplayable { /// Enumerates the trend of the sensor values var trendType: GlucoseTrend? { get } + + /// Returns wheter the data is from a locally-connected device + var isLocal: Bool { get } } diff --git a/Loop/Models/ShareGlucose+GlucoseKit.swift b/Loop/Models/ShareGlucose+GlucoseKit.swift index 0d1ab5746d..7aad5740e9 100644 --- a/Loop/Models/ShareGlucose+GlucoseKit.swift +++ b/Loop/Models/ShareGlucose+GlucoseKit.swift @@ -31,4 +31,8 @@ extension ShareGlucose: SensorDisplayable { var trendType: GlucoseTrend? { return GlucoseTrend(rawValue: Int(trend)) } + + var isLocal: Bool { + return false + } } diff --git a/Loop/View Controllers/PredictionTableViewController.swift b/Loop/View Controllers/PredictionTableViewController.swift index a5a0568d3d..ba16d503dd 100644 --- a/Loop/View Controllers/PredictionTableViewController.swift +++ b/Loop/View Controllers/PredictionTableViewController.swift @@ -300,7 +300,7 @@ class PredictionTableViewController: UITableViewController, IdentifiableClass, U if let eventualGlucose = eventualGlucoseDescription { cell.titleLabel?.text = String(format: NSLocalizedString("Eventually %@", comment: "The subtitle format describing eventual glucose. (1: localized glucose value description)"), eventualGlucose) } else { - cell.titleLabel?.text = nil + cell.titleLabel?.text = "–" } default: break @@ -321,7 +321,7 @@ class PredictionTableViewController: UITableViewController, IdentifiableClass, U override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { switch Section(rawValue: indexPath.section)! { case .charts: - return 270 + return 275 case .inputs, .settings: return 60 } diff --git a/Loop/Views/GlucoseHUDView.swift b/Loop/Views/GlucoseHUDView.swift index 3fecce9c80..ce3c8e539f 100644 --- a/Loop/Views/GlucoseHUDView.swift +++ b/Loop/Views/GlucoseHUDView.swift @@ -37,6 +37,34 @@ final class GlucoseHUDView: HUDView { } } + private enum SensorAlertState { + case ok + case missing + case invalid + case remote + } + + private var sensorAlertState = SensorAlertState.ok { + didSet { + var alertLabelAlpha: CGFloat = 1 + + switch sensorAlertState { + case .ok: + alertLabelAlpha = 0 + case .missing, .invalid: + alertLabel.backgroundColor = UIColor.agingColor + alertLabel.text = "!" + case .remote: + alertLabel.backgroundColor = UIColor.unknownColor + alertLabel.text = "☁︎" + } + + UIView.animate(withDuration: 0.25, animations: { + self.alertLabel.alpha = alertLabelAlpha + }) + } + } + func set(_ glucoseValue: GlucoseValue, for unit: HKUnit, from sensor: SensorDisplayable?) { var accessibilityStrings = [String]() @@ -56,16 +84,19 @@ final class GlucoseHUDView: HUDView { accessibilityStrings.append(trend.localizedDescription) } - if sensor?.isStateValid == false { + if sensor == nil { + sensorAlertState = .missing + } else if sensor!.isStateValid == false { + sensorAlertState = .invalid accessibilityStrings.append(NSLocalizedString("Needs attention", comment: "Accessibility label component for glucose HUD describing an invalid state")) + } else if sensor!.isLocal == false { + sensorAlertState = .remote + } else { + sensorAlertState = .ok } unitLabel.text = unitStrings.joined(separator: " ") accessibilityValue = accessibilityStrings.joined(separator: ", ") - - UIView.animate(withDuration: 0.25, animations: { - self.alertLabel.alpha = sensor?.isStateValid == true ? 0 : 1 - }) } private lazy var timeFormatter: DateFormatter = {