https://github.com/dtrognn/swiftuicoordinator
https://github.com/dtrognn/swiftuicoordinator
coordinator coordinator-pattern swiftui uikit
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dtrognn/swiftuicoordinator
- Owner: dtrognn
- Created: 2025-04-17T11:15:16.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-23T08:57:52.000Z (about 1 year ago)
- Last Synced: 2025-10-30T11:14:05.690Z (8 months ago)
- Topics: coordinator, coordinator-pattern, swiftui, uikit
- Language: Swift
- Homepage:
- Size: 119 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SwiftUI + Coordinator Pattern Example
This project showcases the integration of SwiftUI with the Coordinator pattern to create a scalable and modular navigation system. It includes a custom base screen built from `UIViewController` and supports per-screen rotation configurations.
### Features
- SwiftUI + Coordinator Pattern: Combines SwiftUI for the user interface with the Coordinator pattern for navigation management.
- Custom Base Screen: Implements a reusable base screen derived from UIViewController to handle shared functionalities.
- Per-Screen Rotation Support: Enables individual screens to specify their supported orientations (e.g., portrait, landscape).
### Project Structure
- **Coordinators**: Classes managing navigation logic.
- `AppCoordinator.swift`: Oversees the app's main navigation flow.
- `HomeCoordinator.swift`: Manages navigation within the Home section.
- `ProfileCoordinator.swift`: Handles navigation within the Profile section.
- **Views**: SwiftUI views for the app's screens.
- `HomeView.swift`: Main view for the Home section.
- `ProfileView.swift`: Main view for the Profile section.
- **Utilities**: Supporting classes and configurations.
- `BaseNavigationController.swift`: Custom navigation controller with rotation support.
- `ScreenConfiguration.swift`: Defines screen-specific settings.
### Installation
1. Clone the repository:
```bash
git clone https://github.com/dtrognn/SwiftUICoordinator.git
```
2. Open the project in Xcode:
```bash
cd your-repo-name
open YourProject.xcodeproj
```
3. Build and run the project on a simulator or device.
### Usage
- The app uses coordinators to manage navigation between screens, starting from a root coordinator (`AppCoordinator`).
- Each screen leverages the custom base screen for consistent behavior and can define its own rotation settings via `ScreenConfiguration`.
- Navigation is handled programmatically by coordinators, ensuring a clean separation of concerns from the SwiftUI views.