Search code examples
cosmicmind

How to implement a SideNavigationViewController into a UIViewController?


A little confused on how to implement this into my main view controller. The example project shows it as a navigation controller, but I wasn't able to add an existing class on a fresh navigation controller or my current UIViewController. I could just be implementing it wrong though. Much appreciation if I can gain some traction on how to work with these.


Solution

  • If you could share some code that would be great.

    How things work:

    Navigation Controllers

    There are currently 4 different Navigation Controllers that each offer their own features. The controllers can be used individually, or together.

    SideNavigationViewController

    The SideNavigationViewController offers 3 bodies to display content: mainViewController, leftViewController, and rightViewController.

    MainViewController

    The mainViewController must always exist, and has a facility for transitioning between view controllers using the transitionFromMainViewController method. Using this method is as easy as passing a UIViewController in its first parameter.

    sideNavigationViewController?.transitionFromMainViewController(InboxViewController())
    

    There are further parameters that allow for animations, completions, etc... to be set when transitioning between view controllers.

    LeftViewController and RightViewController

    The leftViewController and rightViewController can be set only once. To make them dynamic, you would need to use another Navigation Controller as its view controller.

    NavigationBarViewController

    The NavigationBarViewController offers a NavigationBarView along side the ability to manage two UIViewControllers, the mainViewController and the floatingViewController.

    MainViewController

    The mainViewController is like the SideNavigationViewController's mainViewController, and has a transitionFromMainViewController method that transitions from view controller to view controller in the body portion of the NavigationBarViewController.

    FloatingViewController

    The floatingViewController is a modalViewController and when set, it pops over MainViewController and NavigationBarView. Setting that value is like so:

    navigationBarViewController?.floatingViewController = InboxViewController()
    

    To close and hide the floatingViewController set it to nil, like so.

    navigationBarViewController?.floatingViewController = nil
    

    SearchBarViewController

    The SearchBarViewController offers a single transitioning mainViewController, as well, has a SearchBarView at the top. Transitioning the mainViewController is like so:

    sideNavigationBarViewController?.transitionFromMainViewController(InboxViewController())
    

    MenuViewController

    The MenuViewController is another controller that has a mainViewController, which takes the entire screen. Floating above it, is a MenuView that is used to transition between mainViewControllers.

    menuViewController?.transitionFromMainViewController(InboxViewController())
    

    Final Notes

    These Navigation Controllers can be used in any combination and any amount of times creating a robust and intricate stack of controllers that act like one.

    I hope this helps :)