ferranabello/Viperit

Advanced navigation

pgawlowski opened this issue · 1 comments

@ferranabello
Any hints on advanced navigation?

Routing examples:

let's start LoggedOutModule without navigation bar
we've got 2 paths:

  • register - with navigationBar
  • login - with navigationBar

Register process got 3 steps:

  • registerFormModule - with navigationBar
  • terms&conditionsModule - with navigationBar
  • registerSuccessModule - without navigation bar

After register process we should unwind/jump back/show LoggedOutModule once again (without navigationBar).

How to handle whole navigation bar embedding/showing/hiding process + backrouting to previous modules (without navigation bars e.x).

My current idea is for showing-hiding of navigation controller is

    override func viewIsAboutToAppear() {
        super.viewIsAboutToAppear()
        _view.navigationController?.setNavigationBarHidden(true, animated: false)
    }

And for routback to view is to just dismiss view which is currently presented over LoggedOutView

// MARK: - RegisterSuccessRouter API
extension RegisterSuccessRouter: RegisterSuccessRouterApi {
    func routeToLoggedOutModule() {
        _view.dismiss(animated: true, completion: nil)
    }
}

Is this correct approach?

Hi @pgawlowski ,
this looks like view presentation logic, not much to do with routing itself.

Showing or hiding certain things in the view should be done by the presenter or the view itself.

If this is a problem that you need to solve through the entire application, I suggest you to create some BaseView class with properties like "shouldShowNavigationBar", "shouldShowTabBar", etc. They could have a default "true" value and you could override them wherever you need them.

Then your "BaseView" could check these values in the viewWillAppear, viewWillDisappear and do as told.

That's a possible solution :)