iOS: Should be able to call showTunnelDetail multiple times
And the detail views should not stack up. Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
88c80d6694
commit
c30d491edc
|
@ -255,21 +255,21 @@ class TunnelsListTableViewController: UIViewController {
|
||||||
func showTunnelDetail(for tunnel: TunnelContainer, animated: Bool) {
|
func showTunnelDetail(for tunnel: TunnelContainer, animated: Bool) {
|
||||||
guard let tunnelsManager = tunnelsManager else { return }
|
guard let tunnelsManager = tunnelsManager else { return }
|
||||||
guard let splitViewController = splitViewController else { return }
|
guard let splitViewController = splitViewController else { return }
|
||||||
|
guard let navController = navigationController else { return }
|
||||||
|
|
||||||
if detailDisplayedTunnel != tunnel {
|
if detailDisplayedTunnel != tunnel {
|
||||||
let tunnelDetailVC = TunnelDetailTableViewController(tunnelsManager: tunnelsManager,
|
let tunnelDetailVC = TunnelDetailTableViewController(tunnelsManager: tunnelsManager,
|
||||||
tunnel: tunnel)
|
tunnel: tunnel)
|
||||||
let tunnelDetailNC = UINavigationController(rootViewController: tunnelDetailVC)
|
let tunnelDetailNC = UINavigationController(rootViewController: tunnelDetailVC)
|
||||||
tunnelDetailNC.restorationIdentifier = "DetailNC"
|
tunnelDetailNC.restorationIdentifier = "DetailNC"
|
||||||
if animated {
|
if splitViewController.isCollapsed && navController.viewControllers.count > 1 {
|
||||||
splitViewController.showDetailViewController(tunnelDetailNC, sender: self)
|
navController.setViewControllers([self, tunnelDetailNC], animated: animated)
|
||||||
} else {
|
} else {
|
||||||
UIView.performWithoutAnimation {
|
splitViewController.showDetailViewController(tunnelDetailNC, sender: self, animated: animated)
|
||||||
splitViewController.showDetailViewController(tunnelDetailNC, sender: self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
detailDisplayedTunnel = tunnel
|
detailDisplayedTunnel = tunnel
|
||||||
}
|
}
|
||||||
|
self.presentedViewController?.dismiss(animated: false, completion: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,3 +402,15 @@ extension TunnelsListTableViewController: TunnelsManagerListDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension UISplitViewController {
|
||||||
|
func showDetailViewController(_ vc: UIViewController, sender: Any?, animated: Bool) {
|
||||||
|
if animated {
|
||||||
|
showDetailViewController(vc, sender: sender)
|
||||||
|
} else {
|
||||||
|
UIView.performWithoutAnimation {
|
||||||
|
showDetailViewController(vc, sender: sender)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue