From ec2069eb91a9ca59babb657b204db9bf1d025c91 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 20 Oct 2018 15:35:56 -0400 Subject: [PATCH] Fix Safari VCs being presented incorrectly from peek/pop, cleanup VC previewing code --- Tusker/Screens/Utilities/Previewing.swift | 50 +---------------------- 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/Tusker/Screens/Utilities/Previewing.swift b/Tusker/Screens/Utilities/Previewing.swift index 7564282d..1f4a322a 100644 --- a/Tusker/Screens/Utilities/Previewing.swift +++ b/Tusker/Screens/Utilities/Previewing.swift @@ -7,24 +7,12 @@ // import UIKit - -enum PreviewCommitType { - case nav - case modal -} +import SafariServices protocol PreviewViewControllerProvider { func getPreviewViewController(forLocation location: CGPoint, sourceViewController: UIViewController) -> UIViewController? - func getPreviewCommitType(forViewController viewController: UIViewController) -> PreviewCommitType - -} - -extension PreviewViewControllerProvider { - func getPreviewCommitType(forViewController viewController: UIViewController) -> PreviewCommitType { - return viewController is LargeImageViewController ? .modal : .nav - } } @objc extension UITableViewController: UIViewControllerPreviewingDelegate { @@ -41,44 +29,10 @@ extension PreviewViewControllerProvider { } public func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) { - if viewControllerToCommit is LargeImageViewController { + if viewControllerToCommit is LargeImageViewController || viewControllerToCommit is SFSafariViewController { present(viewControllerToCommit, animated: false) } else { navigationController!.pushViewController(viewControllerToCommit, animated: false) } } } - -//class PreviewingController: NSObject, UIViewControllerPreviewingDelegate { -// -// var currentCommitType: PreviewCommitType? -// var owner: UIViewController? -// -// init(owner: UIViewController) { -// self.owner = owner -// } -// -// func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { -// if let owner = owner as? UITableViewController, -// let indexPath = owner.tableView.indexPathForRow(at: location), -// let cell = owner.tableView.cellForRow(at: indexPath) as? UITableViewCell & PreviewViewControllerProvider { -// let cellLocation = cell.convert(location, from: owner.tableView) -// if let vc = cell.getPreviewViewController(forLocation: cellLocation, sourceViewController: owner) { -// currentCommitType = cell.getPreviewCommitType(forViewController: vc) -// previewingContext.sourceRect = owner.tableView.rectForRow(at: indexPath) -// return vc -// } -// } -// return nil -// } -// -// func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) { -// switch currentCommitType ?? .nav { -// case .modal: -// owner?.present(viewControllerToCommit, animated: false) -// case .nav: -// owner?.navigationController!.pushViewController(viewControllerToCommit, animated: false) -// } -// } -// -//}