forked from shadowfacts/Tusker
47 lines
2.1 KiB
Swift
47 lines
2.1 KiB
Swift
//
|
|
// UIViewController+StatusTableViewCellDelegate.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 8/27/18.
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
extension UIViewController: UIViewControllerTransitioningDelegate {
|
|
public func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
|
|
if let presented = presented as? LargeImageViewController,
|
|
presented.sourceInfo?.image != nil {
|
|
return LargeImageExpandAnimationController()
|
|
} else if let presented = presented as? GalleryViewController,
|
|
presented.sourcesInfo[presented.startIndex]?.image != nil {
|
|
return GalleryExpandAnimationController()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
|
|
if let dismissed = dismissed as? LargeImageViewController,
|
|
dismissed.imageForDismissalAnimation() != nil {
|
|
return LargeImageShrinkAnimationController(interactionController: dismissed.dismissInteractionController)
|
|
} else if let dismissed = dismissed as? GalleryViewController,
|
|
dismissed.imageForDismissalAnimation() != nil {
|
|
return GalleryShrinkAnimationController(interactionController: dismissed.dismissInteractionController)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
public func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
|
|
if let animator = animator as? LargeImageShrinkAnimationController,
|
|
let interactionController = animator.interactionController,
|
|
interactionController.inProgress {
|
|
return interactionController
|
|
} else if let animator = animator as? GalleryShrinkAnimationController,
|
|
let interactionController = animator.interactionController,
|
|
interactionController.inProgress {
|
|
return interactionController
|
|
}
|
|
return nil
|
|
}
|
|
}
|