The view hierarchy is managed through the PathPresenter.Path() structure.
You can push new views into it using .append methods and delete views from the top using .removeLatest.
Internally, the view’s layout is managed by ZStack, so all views history is visible.
Possible presentation ways:
enum PathType {
/**
* Just show a view. No animation, no transition.
* Show view above all other views
*/
case plain
/**
* Show view with in and out transitions.
* Transition animation also can be specified.
*/
case animated(transition: AnyTransition, animation: Animation)
/**
* Show view in .sheet()
* - Note: If you want to present several views in sheet,
* you can create a second RoutingView and use it in sheet!
*/
case sheet(onDismiss: Action)
}
PathPresenter
https://user-images.githubusercontent.com/25539425/181922855-3ff3aa77-757b-4091-b682-63456fe963a1.mp4
Pure SwiftUI routing with transitions, animations, and
.sheet()
support.In SwiftUI, View is a function of the state. Routing is not an exception. Reasoning and under the hood explanation can be found on my blog:
http://alexdremov.me/swiftui-navigation-is-a-mess-heres-what-you-can-do/
Why
.sheet()
usages are usually messy, deviate from app architecture, and require additional business-logicAdvantages
.sheet()
support. No need to remaster the whole codebase to present the view with.sheet()
. It just works.Example
Example from the video: PathPresenterExample
The view hierarchy is managed through the
PathPresenter.Path()
structure. You can push new views into it using.append
methods and delete views from the top using.removeLatest
.Internally, the view’s layout is managed by
ZStack
, so all views history is visible.Possible presentation ways:
Complete example:
Transitions and animation example
Documentation
Code is mostly commented and simply structured. Check it out!
TODO