GlucoseDisplayable.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // GlucoseDisplayable.swift
  3. // Loop
  4. //
  5. // Created by Nate Racklyeft on 8/2/16.
  6. // Copyright © 2016 Nathan Racklyeft. All rights reserved.
  7. //
  8. import Foundation
  9. import HealthKit
  10. public protocol GlucoseDisplayable {
  11. /// Returns whether the current state is valid
  12. var isStateValid: Bool { get }
  13. /// Describes the state of the sensor in the current localization
  14. var stateDescription: String { get }
  15. /// Enumerates the trend of the sensor values
  16. var trendType: GlucoseTrend? { get }
  17. /// The trend rate of the sensor values, if available
  18. var trendRate: HKQuantity? { get }
  19. /// Returns whether the data is from a locally-connected device
  20. var isLocal: Bool { get }
  21. /// enumerates the glucose value type (e.g., normal, low, high)
  22. var glucoseRangeCategory: GlucoseRangeCategory? { get }
  23. }
  24. extension GlucoseDisplayable {
  25. public var stateDescription: String {
  26. if isStateValid {
  27. return LocalizedString("OK", comment: "Sensor state description for the valid state")
  28. } else {
  29. return LocalizedString("Needs Attention", comment: "Sensor state description for the non-valid state")
  30. }
  31. }
  32. }