HUDProvider.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. import UIKit
  10. public enum HUDTapAction {
  11. case presentViewController(UIViewController & CompletionNotifying)
  12. case openAppURL(URL)
  13. case setupNewPump
  14. case setupNewCGM
  15. case takeNoAction
  16. }
  17. public protocol HUDProvider: AnyObject {
  18. var managerIdentifier: String { get }
  19. typealias HUDViewRawState = [String: Any]
  20. // Creates the initial view (typically reservoir volume) to be shown in Loop HUD.
  21. func createHUDView() -> BaseHUDView?
  22. // Returns the action that should be taken when the view is tapped
  23. func didTapOnHUDView(_ view: BaseHUDView, allowDebugFeatures: Bool) -> HUDTapAction?
  24. // The current, serializable state of the HUD views
  25. var hudViewRawState: HUDViewRawState { get }
  26. // This notifies the HUDProvider whether hud views are offscreen or
  27. // backgrounded. When not visible, updates should be deferred to better
  28. // inform the user when they are returning to the views. Showing
  29. // changed state via animations might be appropriate when becoming
  30. // visible. When not visible, the HUDProvider should limit work done to
  31. // save cpu resources while backgrounded.
  32. var visible: Bool { get set }
  33. }