Advertisement
Guest User

PresentTransition

a guest
Apr 9th, 2020
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.88 KB | None | 0 0
  1. struct PresentTransition: RouteTransition {
  2.  
  3.     let route: Route
  4.     let routeWrapper: RouteWrapper?
  5.     let presentationStyle: UIModalPresentationStyle
  6.  
  7.     init(route: Route, embedIn routeWrapper: RouteWrapper? = nil, presentationStyle: UIModalPresentationStyle = .fullScreen) {
  8.         self.route = route
  9.         self.routeWrapper = routeWrapper
  10.         self.presentationStyle = presentationStyle
  11.     }
  12.  
  13.     func execute(with vc: UIViewController, using resolver: RouteResolver, animated: Bool) {
  14.         guard strategy.prepareForTransition(from: vc, to: route) else { return }
  15.  
  16.         let destination = routeWrapper?.wrapRoute(route, using: resolver) ?? route.prepare(using: resolver)
  17.         destination.modalPresentationStyle = presentationStyle
  18.         destination.popoverPresentationController?.sourceView = vc.view
  19.         vc.present(destination, animated: animated)
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement