NavigationBackport icon indicating copy to clipboard operation
NavigationBackport copied to clipboard

Adds Navigator and navigation utilities

Open johnpatrickmorgan opened this issue 3 years ago • 0 comments

This PR:

  • Adds a Navigator object accessible via the environment, which gives access to the current navigation path.
  • Adds utilities for pushing and popping via the navigator, or directly with an Array or NBNavigationPath.

Usage:

The navigator can be accessed via the environment, e.g. for a NBNavigationPath-backed stack:

@EnvironmentObject var navigator: PathNavigator

Or for an Array-backed stack:

@EnvironmentObject var navigator: Navigator<Screen>

The navigator can then be used in a variety of ways:

navigator.push(Profile(name: "John"))

navigator.pop()

navigator.popToRoot()

navigator.popTo(Profile.self)

johnpatrickmorgan avatar Oct 14 '22 22:10 johnpatrickmorgan