This repository demonstrates how to implement a custom routing system in SwiftUI using NavigationPath and a Router class, providing a clean and modular approach to navigation in iOS 16 and later.
SwiftUI's NavigationPath offers a flexible way to manage navigation stacks programmatically. By integrating a Router class that conforms to the ObservableObject protocol, you can centralize navigation logic, making it easier to handle complex navigation flows, including presenting sheets and full-screen covers.
Programmatic Navigation: Navigate between views using the Router class without relying solely on NavigationLink. State Management: The Router class, as an ObservableObject, allows for reactive UI updates in response to navigation state changes. Modal Presentations: Support for presenting sheets and full-screen covers through the router. Getting Started
Xcode 14 or later iOS 16 or later
-
Clone the Repository:
git clone https://github.com/rmonu0189/RouterSample.git
-
Open the Project: Navigate to the project directory and open RouterSample.xcodeproj in Xcode.
-
Build and Run: Select the desired simulator or device and run the project.