From 730308df3f4206baf22d2f9f91cf1be05b8b264b Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 14 Jun 2019 00:00:53 -0700 Subject: [PATCH] Re-add custom LargeImageViewController presentation/dismissal animations --- .../UIViewController+Delegates.swift | 39 +++++++++---------- Tusker/TuskerNavigationDelegate.swift | 2 + 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Tusker/Extensions/UIViewController+Delegates.swift b/Tusker/Extensions/UIViewController+Delegates.swift index 4861038f..eeec990e 100644 --- a/Tusker/Extensions/UIViewController+Delegates.swift +++ b/Tusker/Extensions/UIViewController+Delegates.swift @@ -10,32 +10,29 @@ import UIKit extension UIViewController: UIViewControllerTransitioningDelegate { public func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { - return nil -// if presented is LargeImageViewController { -// return LargeImageExpandAnimationController() -// } else { -// return nil -// } + if presented is LargeImageViewController { + return LargeImageExpandAnimationController() + } else { + return nil + } } public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { - return nil -// if let dismissed = dismissed as? LargeImageViewController { -// return LargeImageShrinkAnimationController(interactionController: dismissed.dismissInteractionController) -// } else { -// return nil -// } + if let dismissed = dismissed as? LargeImageViewController { + return LargeImageShrinkAnimationController(interactionController: dismissed.dismissInteractionController) + } else { + return nil + } } public func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? { - return nil -// if let animator = animator as? LargeImageShrinkAnimationController, -// let interactionController = animator.interactionController, -// interactionController.inProgress { -// -// return interactionController -// } else { -// return nil -// } + if let animator = animator as? LargeImageShrinkAnimationController, + let interactionController = animator.interactionController, + interactionController.inProgress { + + return interactionController + } else { + return nil + } } } diff --git a/Tusker/TuskerNavigationDelegate.swift b/Tusker/TuskerNavigationDelegate.swift index 01e7d1a0..e891d449 100644 --- a/Tusker/TuskerNavigationDelegate.swift +++ b/Tusker/TuskerNavigationDelegate.swift @@ -108,6 +108,7 @@ extension TuskerNavigationDelegate where Self: UIViewController { let sourceCornerRadius = sourceView.layer.cornerRadius let vc = LargeImageViewController(image: image, description: description, sourceFrame: sourceFrame, sourceCornerRadius: sourceCornerRadius) vc.transitioningDelegate = self + vc.modalPresentationStyle = .fullScreen return vc } @@ -125,6 +126,7 @@ extension TuskerNavigationDelegate where Self: UIViewController { let vc = LargeImageViewController(image: UIImage(data: gifData)!, description: description, sourceFrame: sourceFrame, sourceCornerRadius: sourceCornerRadius) vc.transitioningDelegate = self vc.gifData = gifData + vc.modalPresentationStyle = .fullScreen return vc }