HUDProvider.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. }
  13. public protocol HUDProvider: class {
  14. var managerIdentifier: String { get }
  15. typealias HUDViewsRawState = [String: Any]
  16. // Creates the initial views to be shown in Loop HUD.
  17. func createHUDViews() -> [BaseHUDView]
  18. // Returns the action that should be taken when the view is tapped
  19. func didTapOnHUDView(_ view: BaseHUDView) -> HUDTapAction?
  20. // The current, serializable state of the HUD views
  21. var hudViewsRawState: HUDViewsRawState { get }
  22. // This notifies the HUDProvider whether hud views are offscreen or
  23. // backgrounded. When not visible, updates should be deferred to better
  24. // inform the user when they are returning to the views. Showing
  25. // changed state via animations might be appropriate when becoming
  26. // visible. When not visible, the HUDProvider should limit work done to
  27. // save cpu resources while backgrounded.
  28. var visible: Bool { get set }
  29. }