Member-only story

Navigation Checkpoints in SwiftUI

Introducing a powerful tool for SwiftUI navigation.

Michael Long
5 min read4 days ago

From this point on I’m going to be referencing my new open source library Navigator and how it solves many of the problems inherent in SwiftUI navigation.

And one of those problems is one that we’ve all faced. How can we return to a specific place in the navigation tree?

Overview

Like most open sourced navigation systems based on NavigationStack, Navigator supports operations like popping back to a previous view, dismissing a presented view, and so on.

Button("Pop To Previous Screen") {
navigator.pop()
}

Button("Dismiss Presented View") {
navigator.dismiss()
}

Handy operations to be sure, but they’re also imperative operations.

While one can programmatically pop and dismiss their way out of a screen, that approach is problematic and tends to be fragile. Why? Because it assumes that the code has explicit knowledge of the application structure and navigation tree.

One could pass bindings or callback handlers down the tree, but those can also be cumbersome and difficult to maintain.

Fortunately, Navigator supports checkpoints; named points in the navigation stack to which one can easily…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.