PresentationPresenterManager.swift 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // Created by Tom Baranes on 16/07/16.
  3. // Copyright © 2016 Jake Lin. All rights reserved.
  4. //
  5. import Foundation
  6. public class PresentationPresenterManager {
  7. // MARK: - Singleton
  8. public static let shared = PresentationPresenterManager()
  9. private init() {}
  10. // MARK: - Private
  11. private var cache = [PresentationAnimationType: PresentationPresenter]()
  12. // MARK: Internal Interface
  13. public func retrievePresenter(presentationAnimationType: PresentationAnimationType,
  14. transitionDuration: Duration = defaultPresentationDuration,
  15. interactiveGestureType: InteractiveGestureType? = nil) -> PresentationPresenter {
  16. let presenter = cache[presentationAnimationType]
  17. if let presenter = presenter {
  18. presenter.transitionDuration = transitionDuration
  19. return presenter
  20. }
  21. let newPresenter = PresentationPresenter(presentationAnimationType: presentationAnimationType, transitionDuration: transitionDuration)
  22. cache[presentationAnimationType] = newPresenter
  23. return newPresenter
  24. }
  25. }