Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bbc6bae9/pangu
Quickly build a bugfree SwiftUI Router App (TabView + Navigation + Router) with one line of code.
https://github.com/bbc6bae9/pangu
ios macos router swiftui tvos visionos
Last synced: 26 days ago
JSON representation
Quickly build a bugfree SwiftUI Router App (TabView + Navigation + Router) with one line of code.
- Host: GitHub
- URL: https://github.com/bbc6bae9/pangu
- Owner: BBC6BAE9
- License: mit
- Created: 2024-09-03T16:50:20.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-09-08T06:14:10.000Z (about 2 months ago)
- Last Synced: 2024-10-10T22:41:53.559Z (26 days ago)
- Topics: ios, macos, router, swiftui, tvos, visionos
- Language: Swift
- Homepage:
- Size: 2.76 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![pangu](./pangu.png)
Quickly build a bugfree SwiftUI Router App (`TabView` + `Navigation` + `Router`) with one line of code.
## Feature
🔥 Perfect router solution
🚶 Lazy tab root page
🌲 The `init` and `body` methods of each page under the navigation system will only be called once.
📱 Minimum deployment iOS14
## Usage
1、 Define your Tab model
```swift
import SwiftUI
import Panguenum Tab: Tabable {
case home
case profile@ViewBuilder
func rootPage() -> some View {
switch self {
case .home:
HomePage()
case .profile:
ProfilePage()
}
}func label() -> some View {
switch self {
case .home:
return Label("Home", systemImage: "house")
case .profile:
return Label("Profile", systemImage: "hand.thumbsup.fill")
}
}
}
```2、Define your route and it‘s page (SwiftUI.View)
```swift
import SwiftUI
import Panguenum Route: Routable {
case detail
case more
@ViewBuilder
func destinationView() -> some View {
switch self {
case .detail:
DetailPage()
case .more:
MorePage()
}
}
}
```3、Quickly build a SwiftUI App scaffold with one line of code.
```swift
import Pangu
struct DemoApp: App {
var body: some Scene {
WindowGroup {
PanguTabView(tab: .home)
}
}
}
```4、Define your Router type
```swift
typealias PGRouter = PanguRouter
```4、Route from any View
```swift
struct HomePage: View {
@EnvironmentObject var router: PGRoutervar body: some View {
Button("push") {
router.pushToActiveTab(route: .detail(name: "hello"))
}
.navigationTitle("Home")
}
}
```