CGMManagerUI.swift 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // CGMManagerUI.swift
  3. // LoopKitUI
  4. //
  5. // Copyright © 2018 LoopKit Authors. All rights reserved.
  6. //
  7. import HealthKit
  8. import SwiftUI
  9. import LoopKit
  10. public protocol CGMManagerUI: CGMManager, DeviceManagerUI {
  11. /// Provides a view controller for setting up and configuring the manager if needed.
  12. ///
  13. /// If this method returns nil, it's expected that `init?(rawState: [:])` creates a non-nil manager
  14. static func setupViewController(glucoseTintColor: Color, guidanceColors: GuidanceColors) -> (UIViewController & CGMManagerSetupViewController & CompletionNotifying)?
  15. func settingsViewController(for glucoseUnit: HKUnit, glucoseTintColor: Color, guidanceColors: GuidanceColors) -> (UIViewController & CompletionNotifying)
  16. /// a message from the cgm that needs to be brought to the user's attention in the status bar
  17. var cgmStatusHighlight: DeviceStatusHighlight? { get }
  18. /// the completed percent of the progress bar to display in the status bar
  19. var cgmLifecycleProgress: DeviceLifecycleProgress? { get }
  20. /// gets the range category of a glucose sample using the CGM manager managed glucose thresholds
  21. func glucoseRangeCategory(for glucose: GlucoseSampleValue) -> GlucoseRangeCategory?
  22. }
  23. extension CGMManagerUI {
  24. public func glucoseRangeCategory(for glucose: GlucoseSampleValue) -> GlucoseRangeCategory? {
  25. return nil
  26. }
  27. }
  28. public protocol CGMManagerSetupViewController {
  29. var setupDelegate: CGMManagerSetupViewControllerDelegate? { get set }
  30. }
  31. public protocol CGMManagerSetupViewControllerDelegate: class {
  32. func cgmManagerSetupViewController(_ cgmManagerSetupViewController: CGMManagerSetupViewController, didSetUpCGMManager cgmManager: CGMManagerUI)
  33. }