Context based navigation written in Swift. Contains basic navigation logic in Routy
module and extended functionality for iOS platform in RoutyIOS
.
Context is an equtable abstraction which has two properties:
type
- identifies type of the screen (user, feed, order etc.)payload
- contains data OR another useful info to identify data currently shown by screen (userId, itemIds, orderId etc.), I suggest not to use it for passing callbacks (use your data layer instead), but it's up to you.
- Grab the current
NavigationElementProtocol
stack (UIViewController
conforms this protocol by default,RoutyIOS
hasViewControllerStackProvider
). - Check if we can reuse existing stack to show required context (in
NavigationTransitionProviderProtocol
).RoutyIOS
comes withBackstackTransition
which checks if current context already in hierarchy OR there is aUIViewController
of the sametype
but with differentpayload
AND is can show this payload (PayloadUpdateableViewControllerProtocol
might be adopted to support this option). - If its possible to complete navigation using current stack - it completes.
- If there's no possibility -
NavigationElementFactoryProtocol
, which is created in your app, - asked to provide newNavigationElementProtocol
(UIViewController
) for required context. NavigationTransitionProviderProtocol
asked to provide transition for newly createdNavigationElementProtocol
(UIViewController
).- Transition completes and calls completion for navigation.
- Navigation logic can be easily tested because it decoupled from
UIViewController
s. - It supports
UITabBarController
,UINavigationController
,UIWindow.rootViewController
out of box. - New deeplinks are easily supported. Just convert your link into sequence of contexts.
- Navigation can be easily intercepted. For example, some contexts require user to be authorized, so you can either do not return transition and handle failed transitions externally or return transition to Authorization screen passing desired screen in
AuthorizationContextPayload
, so after successfull authorization you'll be able to route user where he wanted to be.
Routy is competely tested and RoutyIOS has tests for almost all the classes except simple wrappers for .present
, .push
.
Feel free to raise issues and contribute to solve them :)