Giter VIP home page Giter VIP logo

navigator's Introduction

๐Ÿšฃ Navigator

Swift4 compatible

Navigator.swift allow decoupled navigation in iOS apps, useful to handle external requests such as deep linking, push notifications or shortcuts (open a given viewController from AppDelegate) and/or to simply call funcs on VCs not directly accessible.

Navigator recursively scan all instantiated view controllers in your view hierarchy looking for the class.Type you're searching for in childs and/or presentedViewController.

It can then navigate to it using all native container view controllers methods (UITabBarController, UISplitViewController and UINavigationController).

NOTE: If you use custom containers then you can navigate to them and complete navigation steps in closure, same for not loaded UIViewControllers.

Usage

Use the UIViewController extension on your view controller itself. It returns the vc instance (auto-inferred type) synchronously while navigation always happen async on the main thread:

// return the running instance and call one of its funcs in one line:
HelloVC.find()?.sayHelloInConsole()

// go to it
HelloVC.select()

// execute something in the main thread asynchronously:
HelloVC.find { (helloVCParent, helloVC) in
    helloVC?.sayHelloWithAlertFromRootViewController()
    print("HelloVC found: ", helloVC?.title as? String)
}

let hVC = HelloVC.select { (helloVCParent, helloVC) in
    helloVC?.sayHelloWithAlert()
    print("HelloVC found, printing on main thread async: ", helloVC?.title as? String)
}
hVC.doSomething() // sync

Activate debug and whatch the view hierarchy printed on console:

Navigator.debug = true

Globals

APP_DELEGATE // Returns the AppDelegate
APP_WINDOW // Returns the App Window
APP_ROOT // Returns the root viewController also if it is not in the view hierarchy
APP_ROOT_VH // Returns the root viewController which is in the view hierarchy
APP_TOP // Returns the top most viewController

Installation

Simply drag Navigator.swift inside your project and start using it.

Communication

Author

License

Navigator.swift is available under the MIT license. See the LICENSE file for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.