Tusker/Tusker/Extensions/UIViewController+Delegates....

47 lines
2.1 KiB
Swift
Raw Normal View History

2018-09-02 20:59:20 +00:00
//
// 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 {
2019-06-15 00:23:03 +00:00
return GalleryExpandAnimationController()
}
2019-06-15 00:23:03 +00:00
return nil
2018-09-02 20:59:20 +00:00
}
2019-06-15 00:23:03 +00:00
2018-09-02 20:59:20 +00:00
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 {
2019-06-15 00:23:03 +00:00
return GalleryShrinkAnimationController(interactionController: dismissed.dismissInteractionController)
}
2019-06-15 00:23:03 +00:00
return nil
2018-09-02 20:59:20 +00:00
}
2019-06-15 00:23:03 +00:00
2018-09-02 20:59:20 +00:00
public func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
if let animator = animator as? LargeImageShrinkAnimationController,
let interactionController = animator.interactionController,
interactionController.inProgress {
return interactionController
2019-06-15 00:23:03 +00:00
} else if let animator = animator as? GalleryShrinkAnimationController,
let interactionController = animator.interactionController,
interactionController.inProgress {
return interactionController
}
2019-06-15 00:23:03 +00:00
return nil
2018-09-02 20:59:20 +00:00
}
}