To run the example project, clone the repo, and run pod install
from the Example directory first.
Minimum deployment target: iOS 14
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
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 givenstrategy
.
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.
Volodymyr Andriienko, [email protected]
VANavigator is available under the MIT license. See the LICENSE file for more info.