@@ -3,100 +3,60 @@ import SwiftUI
33
44struct RootView : View {
55 @State var isNavigationStackCaseStudyPresented = false
6- let store : StoreOf < Root >
76
87 var body : some View {
98 NavigationStack {
109 Form {
1110 Section {
1211 NavigationLink ( " Basics " ) {
13- CounterDemoView (
14- store: self . store. scope ( state: \. counter, action: { . counter( $0) } )
15- )
12+ CounterDemoView ( )
1613 }
1714 NavigationLink ( " Combining reducers " ) {
18- TwoCountersView (
19- store: self . store. scope ( state: \. twoCounters, action: { . twoCounters( $0) } )
20- )
15+ TwoCountersView ( )
2116 }
2217 NavigationLink ( " Bindings " ) {
23- BindingBasicsView (
24- store: self . store. scope ( state: \. bindingBasics, action: { . bindingBasics( $0) } )
25- )
18+ BindingBasicsView ( )
2619 }
2720 NavigationLink ( " Form bindings " ) {
28- BindingFormView (
29- store: self . store. scope ( state: \. bindingForm, action: { . bindingForm( $0) } )
30- )
21+ BindingFormView ( )
3122 }
3223 NavigationLink ( " Optional state " ) {
33- OptionalBasicsView (
34- store: self . store. scope ( state: \. optionalBasics, action: { . optionalBasics( $0) } )
35- )
24+ OptionalBasicsView ( )
3625 }
3726 NavigationLink ( " Shared state " ) {
38- SharedStateView (
39- store: self . store. scope ( state: \. shared, action: { . shared( $0) } )
40- )
27+ SharedStateView ( )
4128 }
4229 NavigationLink ( " Alerts and Confirmation Dialogs " ) {
43- AlertAndConfirmationDialogView (
44- store: self . store. scope (
45- state: \. alertAndConfirmationDialog,
46- action: { . alertAndConfirmationDialog( $0) }
47- )
48- )
30+ AlertAndConfirmationDialogView ( )
4931 }
5032 NavigationLink ( " Focus State " ) {
51- FocusDemoView (
52- store: self . store. scope ( state: \. focusDemo, action: { . focusDemo( $0) } )
53- )
33+ FocusDemoView ( )
5434 }
5535 NavigationLink ( " Animations " ) {
56- AnimationsView (
57- store: self . store. scope ( state: \. animation, action: { . animation( $0) } )
58- )
36+ AnimationsView ( )
5937 }
6038 } header: {
6139 Text ( " Getting started " )
6240 }
6341
6442 Section {
6543 NavigationLink ( " Basics " ) {
66- EffectsBasicsView (
67- store: self . store. scope ( state: \. effectsBasics, action: { . effectsBasics( $0) } )
68- )
44+ EffectsBasicsView ( )
6945 }
7046 NavigationLink ( " Cancellation " ) {
71- EffectsCancellationView (
72- store: self . store. scope (
73- state: \. effectsCancellation,
74- action: { . effectsCancellation( $0) }
75- )
76- )
47+ EffectsCancellationView ( )
7748 }
7849 NavigationLink ( " Long-living effects " ) {
79- LongLivingEffectsView (
80- store: self . store. scope (
81- state: \. longLivingEffects,
82- action: { . longLivingEffects( $0) }
83- )
84- )
50+ LongLivingEffectsView ( )
8551 }
8652 NavigationLink ( " Refreshable " ) {
87- RefreshableView (
88- store: self . store. scope ( state: \. refreshable, action: { . refreshable( $0) } )
89- )
53+ RefreshableView ( )
9054 }
9155 NavigationLink ( " Timers " ) {
92- TimersView (
93- store: self . store. scope ( state: \. timers, action: { . timers( $0) } )
94- )
56+ TimersView ( )
9557 }
9658 NavigationLink ( " Web socket " ) {
97- WebSocketView (
98- store: self . store. scope ( state: \. webSocket, action: { . webSocket( $0) } )
99- )
59+ WebSocketView ( )
10060 }
10161 } header: {
10262 Text ( " Effects " )
@@ -109,69 +69,42 @@ struct RootView: View {
10969 . buttonStyle ( . plain)
11070
11171 NavigationLink ( " Navigate and load data " ) {
112- NavigateAndLoadView (
113- store: self . store. scope ( state: \. navigateAndLoad, action: { . navigateAndLoad( $0) } )
114- )
72+ NavigateAndLoadView ( )
11573 }
11674
11775 NavigationLink ( " Lists: Navigate and load data " ) {
118- NavigateAndLoadListView (
119- store: self . store. scope (
120- state: \. navigateAndLoadList, action: { . navigateAndLoadList( $0) }
121- )
122- )
76+ NavigateAndLoadListView ( )
12377 }
12478 NavigationLink ( " Sheets: Present and load data " ) {
125- PresentAndLoadView (
126- store: self . store. scope ( state: \. presentAndLoad, action: { . presentAndLoad( $0) } )
127- )
79+ PresentAndLoadView ( )
12880 }
12981 NavigationLink ( " Sheets: Load data then present " ) {
130- LoadThenPresentView (
131- store: self . store. scope ( state: \. loadThenPresent, action: { . loadThenPresent( $0) } )
132- )
82+ LoadThenPresentView ( )
13383 }
13484 NavigationLink ( " Multiple destinations " ) {
135- MultipleDestinationsView (
136- store: self . store. scope (
137- state: \. multipleDestinations,
138- action: { . multipleDestinations( $0) }
139- )
140- )
85+ MultipleDestinationsView ( )
14186 }
14287 } header: {
14388 Text ( " Navigation " )
14489 }
14590
14691 Section {
14792 NavigationLink ( " Reusable favoriting component " ) {
148- EpisodesView (
149- store: self . store. scope ( state: \. episodes, action: { . episodes( $0) } )
150- )
93+ EpisodesView ( )
15194 }
15295 NavigationLink ( " Reusable offline download component " ) {
153- CitiesView (
154- store: self . store. scope ( state: \. map, action: { . map( $0) } )
155- )
96+ CitiesView ( )
15697 }
15798 NavigationLink ( " Recursive state and actions " ) {
158- NestedView (
159- store: self . store. scope ( state: \. nested, action: { . nested( $0) } )
160- )
99+ NestedView ( )
161100 }
162101 } header: {
163102 Text ( " Higher-order reducers " )
164103 }
165104 }
166105 . navigationTitle ( " Case Studies " )
167- . onAppear { self . store. send ( . onAppear) }
168106 . sheet ( isPresented: self . $isNavigationStackCaseStudyPresented) {
169- NavigationDemoView (
170- store: self . store. scope (
171- state: \. navigationStack,
172- action: { . navigationStack( $0) }
173- )
174- )
107+ NavigationDemoView ( )
175108 }
176109 }
177110 }
@@ -181,10 +114,6 @@ struct RootView: View {
181114
182115struct RootView_Previews : PreviewProvider {
183116 static var previews : some View {
184- RootView (
185- store: Store ( initialState: Root . State ( ) ) {
186- Root ( )
187- }
188- )
117+ RootView ( )
189118 }
190119}
0 commit comments