2021-07-14 14:28:41 +02:00
|
|
|
//
|
2021-07-15 09:49:30 +02:00
|
|
|
// SearchTransitionController.swift
|
2021-07-14 14:28:41 +02:00
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK Cirno on 2021-7-13.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
2021-07-15 09:49:30 +02:00
|
|
|
final class SearchTransitionController: NSObject {
|
2021-07-14 14:28:41 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - UINavigationControllerDelegate
|
2021-07-15 09:49:30 +02:00
|
|
|
extension SearchTransitionController: UINavigationControllerDelegate {
|
2021-07-14 14:28:41 +02:00
|
|
|
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
|
|
|
|
switch operation {
|
|
|
|
case .push where fromVC is SearchViewController && toVC is SearchDetailViewController:
|
|
|
|
return SearchToSearchDetailViewControllerAnimatedTransitioning(operation: operation)
|
|
|
|
case .pop where fromVC is SearchDetailViewController && toVC is SearchViewController:
|
|
|
|
return SearchToSearchDetailViewControllerAnimatedTransitioning(operation: operation)
|
|
|
|
default:
|
|
|
|
// fix edge dismiss gesture
|
|
|
|
toVC.navigationController?.interactivePopGestureRecognizer?.delegate = nil
|
|
|
|
// assertionFailure("Wrong setup. Edge-drag gesture will be invalid. Set delegate to nil when using system push configuration")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
2021-07-15 14:28:36 +02:00
|
|
|
|
|
|
|
func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
|
|
|
|
switch viewController {
|
|
|
|
case is SearchDetailViewController:
|
|
|
|
navigationController.interactivePopGestureRecognizer?.isEnabled = false
|
|
|
|
default:
|
|
|
|
navigationController.interactivePopGestureRecognizer?.isEnabled = true
|
|
|
|
}
|
|
|
|
}
|
2021-07-14 14:28:41 +02:00
|
|
|
}
|