Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lm/navigation-stack-backport
SwiftUI NavigationStack for iOS 14 and 15
https://github.com/lm/navigation-stack-backport
backport ios navigation navigationstack swift swiftui
Last synced: 5 days ago
JSON representation
SwiftUI NavigationStack for iOS 14 and 15
- Host: GitHub
- URL: https://github.com/lm/navigation-stack-backport
- Owner: lm
- License: mit
- Created: 2022-11-06T09:45:08.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-09T08:20:37.000Z (5 months ago)
- Last Synced: 2024-12-30T09:10:27.583Z (13 days ago)
- Topics: backport, ios, navigation, navigationstack, swift, swiftui
- Language: Swift
- Homepage:
- Size: 25.4 KB
- Stars: 113
- Watchers: 3
- Forks: 16
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftUI NavigationStack Backport
`NavigationStack` for iOS 14 and 15 implemented on top of `UINavigationController`. Backport just bridges to existing SwiftUI API on iOS 16 or newer.
## Features
- `NavigationPath` is fully supported including codable representation
- `View.navigationDestination()`, `View.navigationDestination(isPresented:destination:)` and `View.navigationDestination(item:destination:)`
- `NavigationLink` with value
- for now tested only on iOS## Getting Started
Installation via Swift Package Manager is supported. Use `https://github.com/lm/navigation-stack-backport` as depedency URL. For more information how to add dependency in Xcode see https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app or add dependency in your Package.swift `.package(url: "https://github.com/lm/navigation-stack-backport", from: "1.1.0")`
## Usage Example
Usage is the same as SwiftUI's `NavigationStack` on iOS 16, just prefix `NavigationStack` and other types with `NavigationStackBackport.` or import exact types from `NavigationStackBackport` package. For view modifiers introduced in iOS 16 use `backport.` prefix like `.backport.navigationDestination(for: …)`.
```
import NavigationStackBackportstruct ContentView: View {
@State private var navigationPath = NavigationStackBackport.NavigationPath()var body: some View {
NavigationStackBackport.NavigationStack(path: $navigationPath) {
Button("Push") {
navigationPath.append("Hello World")
}
.backport.navigationDestination(for: String.self) { value in
Image(systemName: "globe")
.navigationTitle(value) // use available SwiftUI's modifiers
}
}
}
}```
For more examples see the `TestApp` within this repository.