CGMSettingsDataFlow.swift 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import LoopKit
  2. import SwiftUI
  3. enum CGMSettings {
  4. enum Config {}
  5. }
  6. protocol CGMSettingsProvider: Provider {}
  7. /// `cgmStatusHighlight` reduced to message + tier — what the home UI needs.
  8. /// `imageName` is the SF Symbol name the manager wants to associate with this
  9. /// state (G6/G7/LibreLoop all surface this); empty string when the manager
  10. /// doesn't provide one.
  11. struct CgmDisplayState: Equatable {
  12. let localizedMessage: String
  13. let imageName: String
  14. let status: CgmDisplayStatus
  15. }
  16. enum CgmDisplayStatus {
  17. case normal
  18. case warning
  19. case critical
  20. var color: Color {
  21. switch self {
  22. case .critical: return .critical
  23. case .warning: return .warning
  24. case .normal: return .loopAccent
  25. }
  26. }
  27. static func from(_ state: LoopKit.DeviceStatusHighlightState) -> CgmDisplayStatus {
  28. switch state {
  29. case .normalCGM,
  30. .normalPump:
  31. return .normal
  32. case .warning:
  33. return .warning
  34. case .critical:
  35. return .critical
  36. }
  37. }
  38. }