File tree Expand file tree Collapse file tree
Examples/SingleNavigator/SingleTicTacToe/SingleTicTacToe/Page Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,9 +6,14 @@ struct GameRouteBuilder<RootNavigator: RootNavigatorType> {
66 static func generate( ) -> RouteBuilderOf < RootNavigator > {
77 var matchPath : String { " game " }
88 return . init( matchPath: matchPath) { navigator, items, diContainer -> RouteViewController ? in
9+ let query : GameInjectionData ? = items. decoded ( )
910 return WrappingController ( matchPath: matchPath) {
10- GameView ( navigator: navigator)
11+ GameView ( navigator: navigator, injectionData : query )
1112 }
1213 }
1314 }
1415}
16+
17+ struct GameInjectionData : Equatable , Codable {
18+ let gameTitle : String
19+ }
Original file line number Diff line number Diff line change @@ -4,8 +4,27 @@ import LinkNavigator
44struct GameView : View {
55
66 let navigator : RootNavigatorType
7+ let injectionData : GameInjectionData ?
8+
9+ var gameTitle : String {
10+ injectionData? . gameTitle ?? " "
11+ }
712
813 var body : some View {
9- Text ( " GameView " )
14+ VStack ( spacing: 30 ) {
15+ PathIndicator ( currentPath: navigator. getCurrentPaths ( ) . joined ( separator: " -> " ) )
16+ . padding ( . top, 32 )
17+
18+ Text ( " \( gameTitle) ๊ฒ์ " )
19+
20+ Spacer ( )
21+
22+ Button ( action: {
23+ navigator. back ( isAnimated: true )
24+ } ) {
25+ Text ( " ๊ฒ์ ์ข
๋ฃ " )
26+ }
27+ }
28+ . padding ( )
1029 }
1130}
Original file line number Diff line number Diff line change @@ -5,7 +5,26 @@ struct HomeView: View {
55
66 let navigator : RootNavigatorType
77
8+ @State private var isLogin = UserDefaults . standard. bool ( forKey: " isLogin " )
9+
810 var body : some View {
9- Text ( " HomeView " )
11+ VStack ( spacing: 30 ) {
12+ PathIndicator ( currentPath: navigator. getCurrentPaths ( ) . joined ( separator: " -> " ) )
13+ . padding ( . top, 32 )
14+
15+ Button ( action: {
16+ navigator. sheet ( linkItem: . init( path: " login " ) , isAnimated: true )
17+ } ) {
18+ Text ( " go to Login " )
19+ }
20+
21+ Spacer ( )
22+ }
23+ . padding ( )
24+ . onAppear {
25+ if isLogin {
26+ navigator. replace ( linkItem: . init( path: " newGame " ) , isAnimated: true )
27+ }
28+ }
1029 }
1130}
Original file line number Diff line number Diff line change @@ -5,7 +5,34 @@ struct LoginView: View {
55
66 let navigator : RootNavigatorType
77
8+ @State private var message : String = " "
9+ @State private var password : String = " "
10+
811 var body : some View {
9- Text ( " LoginView " )
12+ VStack ( spacing: 30 ) {
13+ PathIndicator ( currentPath: navigator. getCurrentPaths ( ) . joined ( separator: " -> " ) )
14+ . padding ( . top, 32 )
15+
16+ VStack ( spacing: 16 ) {
17+ TextField ( " id " , text: $message)
18+ . textFieldStyle ( . roundedBorder)
19+ . padding ( . horizontal)
20+
21+ SecureField ( " password " , text: $password)
22+ . textFieldStyle ( . roundedBorder)
23+ . padding ( . horizontal)
24+
25+ Button ( action: {
26+ UserDefaults . standard. setValue ( true , forKey: " isLogin " )
27+ navigator. close ( isAnimated: true ) {
28+ navigator. rootReloadLast ( items: . init( path: " home " ) , isAnimated: true )
29+ }
30+ } ) {
31+ Text ( " Login " )
32+ }
33+ }
34+ Spacer ( )
35+ }
36+ . padding ( )
1037 }
1138}
Original file line number Diff line number Diff line change @@ -4,8 +4,44 @@ import LinkNavigator
44struct NewGameView : View {
55
66 let navigator : RootNavigatorType
7+ @State var gameTitle : String = " "
78
89 var body : some View {
9- Text ( " NewGameView " )
10+ VStack ( spacing: 30 ) {
11+ PathIndicator ( currentPath: navigator. getCurrentPaths ( ) . joined ( separator: " -> " ) )
12+ . padding ( . top, 32 )
13+
14+
15+ VStack ( spacing: 16 ) {
16+ Text ( " ์๋ก์ด ๊ฒ์ ์์ฑ " )
17+ TextField ( " Type message here " , text: $gameTitle)
18+ . textFieldStyle ( . roundedBorder)
19+ . padding ( . horizontal)
20+
21+ Button ( action: {
22+ navigator. next (
23+ linkItem: . init(
24+ path: " game " ,
25+ items: GameInjectionData ( gameTitle: gameTitle) . encoded ( )
26+ ) ,
27+ isAnimated: true )
28+ } ) {
29+ Text ( " ๊ฒ์ ์์ " )
30+ }
31+ }
32+
33+ Spacer ( )
34+
35+ Button ( action: {
36+ UserDefaults . standard. setValue ( false , forKey: " isLogin " )
37+ navigator. replace ( linkItem: . init( path: " home " ) , isAnimated: true )
38+ } ) {
39+ Text ( " logout " )
40+ }
41+
42+ Spacer ( )
43+ }
44+ . padding ( )
1045 }
1146}
47+
You canโt perform that action at this time.
0 commit comments