Skip to content

VAndrJ/VANavigator

Repository files navigation

VANavigator

StandWithUkraine Support Ukraine

License Platform

Version SPM  VANavigator

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Minimum deployment target: iOS 14

Installation

VANavigator is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'VANavigator'

VANavigator is available through SPM. To install it, simply add to your Package Dependencies:

https://github.com/VAndrJ/VANavigator.git

Description

VANavigator is designed to simplify and streamline navigation in an application, alleviating the complexities associated with searching for and transitioning to specific view controllers. At its core, VANavigator revolves around the concept of NavigationIdentity, a key element that enables the seamless discovery of the required view controller in UIWindow, facilitating easy navigation back to it or opening a new one based on the specified NavigationStrategy.

Navigation strategies:

  • Replace UIWindow root view controller.

Code example:

navigator.navigate(
    destination: .identity(MainNavigationIdentity()),
    strategy: .replaceWindowRoot()
)
  • Present view controller.

Code example:

navigator.navigate(
    destination: .identity(MainNavigationIdentity()),
    strategy: .present()
)
  • Closes presented controllers to the given controller if it exists.

Code example:

navigator.navigate(
    destination: .identity(MainNavigationIdentity()),
    strategy: .closeToExisting
)
  • Push view controller.

Code example:

navigator.navigate(
    destination: .identity(MainNavigationIdentity()),
    strategy: .push()
)
  • Pops to existing controller in UINavigationController's navigation stack.

Code example:

navigator.navigate(
    destination: .identity(MainNavigationIdentity()),
    strategy: .popToExisting()
)
  • Replace the UINavigationController's navigation stack with a new controller.

Code example:

navigator.navigate(
    destination: .identity(MainNavigationIdentity()),
    strategy: .replaceNavigationRoot
)
  • Close (pop or dismiss) the controller if it is the top one.

Code example:

navigator.navigate(
    destination: .identity(MainNavigationIdentity()),
    strategy: .closeIfTop()
)
  • *Under development. Shows in a UISplitViewController with the given strategy.

Code example:

navigator?.navigate(
    destination: .identity(MainNavigationIdentity()),
    strategy: .split(strategy: ...)
)

Navigation interception

Use the NavigationInterceptor to intercept the navigation flow and replace it with a new one based on the provided conditions. Continue the intercepted navigation after resolving the interception reason.

Author

Volodymyr Andriienko, [email protected]

License

VANavigator is available under the MIT license. See the LICENSE file for more info.