-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRouterExampleApp.swift
More file actions
81 lines (77 loc) 路 2.45 KB
/
Copy pathRouterExampleApp.swift
File metadata and controls
81 lines (77 loc) 路 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// RouterExampleApp.swift
// RouterExample
//
// Created by burt on 2021/03/05.
//
import SwiftUI
import Router
import Defaults
@main
struct RouterExampleApp: App {
@Default(.isFirstLaunch)
var isFirstLaunch
var body: some Scene {
WindowGroup {
RouterRootView { router in
Switch(isFirstLaunch)
.Case(true) { _ in
OnboardingView()
}
.Case(false) { _ in
ContentView()
}
.Else {
EmptyView()
}
.navigationBarHidden(true)
}
.path("myapp://onboarding") { data in
Switch(data.page.flatMap { Int($0) })
.Case(1) { _ in
OnboardingView()
}
.Case(2) { _ in
OnboardingView2()
}
.Else {
EmptyView()
}
.navigationBarHidden(true)
}
.path("myapp://content") { data in
Switch(data.as_root.flatMap { Bool($0) })
.Case(true) { _ in
ContentView()
.asRouterRootView()
}
.Else {
ContentView()
}
.navigationBarHidden(true)
}
.path("myapp://counter") { data in
CounterView(count: data.bindings.count)
.navigationBarHidden(true)
}
.path("myapp://color") { data in
If(data.color).Let { color in
ColorView(color: MyColor.from(string: color))
}
.navigationBarHidden(true)
// Switch(data.color)
// .Case("red") { color in
// ColorView(color: MyColor.from(string: color))
// .navigationBarHidden(true)
// }
// .Case("green") { color in
// ColorView(color: MyColor.from(string: color))
// .navigationBarHidden(true)
// }
// .Else {
// Text("OMG")
// }
}
}
}
}