- August 1, 2025
- Mins Read
Implement navigation in your project in no time. Keep your code clean
Navigattie is a free, and open-source library for SwiftUI that makes navigation easier and much cleaner.
push(with:)
method.pop()
. Simple as never.Platforms | Minimum Swift Version |
---|---|
iOS 15+ | 5.0 |
Swift package manager is a tool for automating the distribution of Swift code and is integrated into the Swift compiler.
Once you have your Swift package set up, adding Navigattie as a dependency is as easy as adding it to the dependencies
value of your Package.swift
.
dependencies: [
.package(url: “https://github.com/Mijick/Navigattie”, branch(“main”))
]
Inside the @main
structure, call the implementNavigationView(config:)
method on the view that is to be the root view in your navigation structure. The view to be the root must be of type NavigatableView
. The method takes an optional argument – config
, that can be used to configure some modifiers for all navigation views in the application.
var body: some Scene {
WindowGroup {
ContentView()
.implementNavigationView(config: nil)
}
}
Navigattie provides the ability to push (or pop) any view using its built-in stack. In order to do so, it is necessary to confirm to NavigatableView
protocol. So that an example view you want to push will have the following declaration:
struct ExampleView: NavigatableView {
…
}
Fill your view with content
struct ExampleView: NavigatableView {
var body: some View {
VStack(spacing: 0) {
Text(“Witaj okrutny świecie”)
Spacer()
Button(action: pop) { Text(“Pop”) }
}
}
…
}
This step is optional – if you wish, you can skip this step and leave the configuration as default.
Each view has its own set of methods that can be used to customise it, regardless of the config we mentioned in step 1.
struct ExampleView: NavigatableView {
func configure(view: NavigationConfig) -> NavigationConfig { view.backgroundColour(.red) }
var body: some View {
VStack(spacing: 0) {
Text(“Witaj okrutny świecie”)
Spacer()
Button(action: pop) { Text(“Pop”) }
}
}
…
}
Just call ExampleView().push(with:)
from the selected place
struct SettingsViewModel {
…
func openSettings() {
…
ExampleView().push(with: .verticalSlide)
…
}
…
}
There are two ways to do so:
pop
, pop(to type:)
, popToRoot
inside any view
struct ExampleView: NavigatableView {
…
func createButton() -> some View {
Button(action: popToRoot) { Text(“Tap to return to root”) }
}
…
}
NavigationManager.pop()
NavigationManager.pop(to type:)
where type is the type of view you want to return toNavigationManager.popToRoot()
A Figma component preview for your SwiftUI views. You can use Figma components instead of real views within your app ...
Motivation At WWDC 2019, Apple announced SwiftUI a new library for building UI in a simple and fast way. Xcode’s ...
Make use of SwiftUI previews for rapidly prototyping your UIViewControllers and UIViews! The SwiftUI preview canvas is tied to a specific version of ...
Requirements Dev environment: Xcode 13+, macOS 12+ iOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+ Usage
Horizontal wheel picker for SwiftUI Requirements iOS 13.0+ Installation CocoaPods