Fix Safari VCs being presented incorrectly from peek/pop, cleanup VC previewing code
This commit is contained in:
parent
17ebfa6fd0
commit
18b38d0145
|
@ -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)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
Loading…
Reference in New Issue