ActionSheetPresenter.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // ActionSheetPresenter.swift
  3. // Sheeeeeeeeet
  4. //
  5. // Created by Daniel Saidi on 2017-11-18.
  6. // Copyright © 2017 Daniel Saidi. All rights reserved.
  7. //
  8. /*
  9. Action sheet presenters are used by Sheeeeeeeeet to present
  10. action sheets in different ways, e.g. with a default bottom
  11. slide, showing a popover from the tapped view etc.
  12. When implementing this protocol, `present(in:from:)` is the
  13. standard way to present an action sheet, while `dismiss` is
  14. the standard way to dismiss it.
  15. `isDismissableWithTapOnBackground` is used to specify if an
  16. action sheet can be dismissed by tapping on the background.
  17. */
  18. import Foundation
  19. public struct ActionSheetPresenterEvents {
  20. public init() {}
  21. public var didDismissWithBackgroundTap: (() -> ())?
  22. }
  23. public protocol ActionSheetPresenter: AnyObject {
  24. var availablePresentationSize: CGSize { get }
  25. var events: ActionSheetPresenterEvents { get set }
  26. var isDismissableWithTapOnBackground: Bool { get set }
  27. func dismiss(completion: @escaping () -> ())
  28. func present(sheet: ActionSheet, in vc: UIViewController, from view: UIView?)
  29. func present(sheet: ActionSheet, in vc: UIViewController, from item: UIBarButtonItem)
  30. func presentationFrame(for sheet: ActionSheet, in view: UIView) -> CGRect?
  31. }