URLNavigator
URLNavigator copied to clipboard
How to pop an viewController?
hello, I implement the push like this in my viewModel:
let context = ["merch":merch]
DJNavigator.share.push("myApp://roomList/",context:context)
And In the roomListViewController I want pop to current viewController when I click the back button. But I have to write the code in the viewController (not in the viewModel) use origin pop:
self.navigationController?.popViewController(animated: true)
Can I do it using the URLNavigator so that I can write all view navigtion logic in viewModel ?
URLNavigator doesn't support popping view controllers. If it is needed, you can still make an extension.
@devxoul How?
@thepinyo Like this:
extension Navigator {
func pop(animated: Bool = true) {
UIViewController.topMost?.navigationController?.popViewController(animated: animated)
}
}