HUDProvider.swift 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // HUDProvider.swift
  3. // LoopKitUI
  4. //
  5. // Created by Pete Schwamb on 1/29/19.
  6. // Copyright © 2019 LoopKit Authors. All rights reserved.
  7. //
  8. import Foundation
  9. public enum HUDTapAction {
  10. case presentViewController(UIViewController & CompletionNotifying)
  11. case openAppURL(URL)
  12. case setupNewPump
  13. case setupNewCGM
  14. case takeNoAction
  15. }
  16. public protocol HUDProvider: AnyObject {
  17. var managerIdentifier: String { get }
  18. typealias HUDViewRawState = [String: Any]
  19. // Creates the initial view (typically reservoir volume) to be shown in Loop HUD.
  20. func createHUDView() -> BaseHUDView?
  21. // Returns the action that should be taken when the view is tapped
  22. func didTapOnHUDView(_ view: BaseHUDView, allowDebugFeatures: Bool) -> HUDTapAction?
  23. // The current, serializable state of the HUD views
  24. var hudViewRawState: HUDViewRawState { get }
  25. // This notifies the HUDProvider whether hud views are offscreen or
  26. // backgrounded. When not visible, updates should be deferred to better
  27. // inform the user when they are returning to the views. Showing
  28. // changed state via animations might be appropriate when becoming
  29. // visible. When not visible, the HUDProvider should limit work done to
  30. // save cpu resources while backgrounded.
  31. var visible: Bool { get set }
  32. }