@@ -65,43 +65,40 @@ final class NavigationTransitionAnimatorProvider: NSObject, UIViewControllerAnim
6565 if let cached = cachedAnimators [ ObjectIdentifier ( transitionContext) ] {
6666 return cached
6767 }
68-
6968 let animator = UIViewPropertyAnimator (
7069 duration: transitionDuration ( using: transitionContext) ,
7170 timingParameters: transition. animation. timingParameters
7271 )
72+ cachedAnimators [ ObjectIdentifier ( transitionContext) ] = animator
7373
74- // Handle NavigationTransition setup
75- if let ( fromView, toView) = transientViews ( for: transition, animator: animator, context: transitionContext) {
76- fromView. setUIViewProperties ( to: \. initial)
77- animator. addAnimations { fromView. setUIViewProperties ( to: \. animation) }
78- animator. addCompletion { _ in fromView. setUIViewProperties ( to: \. completion) }
79-
80- toView. setUIViewProperties ( to: \. initial)
81- animator. addAnimations { toView. setUIViewProperties ( to: \. animation) }
82- animator. addCompletion { _ in toView. setUIViewProperties ( to: \. completion) }
83- }
74+ switch transition. handler {
75+ case . transient( let handler) :
76+ if let ( fromView, toView) = transientViews ( for: handler, animator: animator, context: transitionContext) {
77+ fromView. setUIViewProperties ( to: \. initial)
78+ animator. addAnimations { fromView. setUIViewProperties ( to: \. animation) }
79+ animator. addCompletion { _ in fromView. setUIViewProperties ( to: \. completion) }
8480
85- // Handle PrimitiveNavigationTransition setup
86- if let handler = transition. primitiveHandler {
81+ toView. setUIViewProperties ( to: \. initial)
82+ animator. addAnimations { toView. setUIViewProperties ( to: \. animation) }
83+ animator. addCompletion { _ in toView. setUIViewProperties ( to: \. completion) }
84+ }
85+ case . primitive( let handler) :
8786 handler ( animator, operation, transitionContext)
8887 }
8988
9089 animator. addCompletion { _ in
9190 transitionContext. completeTransition ( !transitionContext. transitionWasCancelled)
9291 }
9392
94- cachedAnimators [ ObjectIdentifier ( transitionContext) ] = animator
9593 return animator
9694 }
9795
9896 private func transientViews(
99- for transition : AnyNavigationTransition ,
97+ for handler : AnyNavigationTransition . TransientHandler ,
10098 animator: Animator ,
10199 context: UIViewControllerContextTransitioning
102100 ) -> ( fromView: AnimatorTransientView , toView: AnimatorTransientView ) ? {
103101 guard
104- let handler = transition. handler,
105102 let fromUIView = context. view ( forKey: . from) ,
106103 let fromUIViewSnapshot = fromUIView. snapshotView ( afterScreenUpdates: false ) ,
107104 let toUIView = context. view ( forKey: . to) ,
0 commit comments