Skip to content

Commit 10e8492

Browse files
authored
Simplify case studies. (#2526)
1 parent a611f14 commit 10e8492

28 files changed

+98
-277
lines changed

Examples/CaseStudies/CaseStudies.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
CABC4F3926AEE00C00D5FA2C /* 02-Effects-Refreshable.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABC4F3826AEE00C00D5FA2C /* 02-Effects-Refreshable.swift */; };
3333
CABC4F3B26AEE20200D5FA2C /* 02-Effects-RefreshableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABC4F3A26AEE20200D5FA2C /* 02-Effects-RefreshableTests.swift */; };
3434
CAE962FD24A7F7BE00EFC025 /* 01-GettingStarted-AlertsAndConfirmationDialogs.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAE962FC24A7F7BE00EFC025 /* 01-GettingStarted-AlertsAndConfirmationDialogs.swift */; };
35-
CAF069D024ACC5AF00A1AAEF /* 00-Core.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF069CF24ACC5AF00A1AAEF /* 00-Core.swift */; };
3635
CAF88E7324B8E26D00539345 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF88E7224B8E26D00539345 /* AppDelegate.swift */; };
3736
CAF88E7524B8E26D00539345 /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF88E7424B8E26D00539345 /* RootView.swift */; };
3837
CAF88E7724B8E26E00539345 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CAF88E7624B8E26E00539345 /* Assets.xcassets */; };
@@ -173,7 +172,6 @@
173172
CABC4F3826AEE00C00D5FA2C /* 02-Effects-Refreshable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "02-Effects-Refreshable.swift"; sourceTree = "<group>"; };
174173
CABC4F3A26AEE20200D5FA2C /* 02-Effects-RefreshableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "02-Effects-RefreshableTests.swift"; sourceTree = "<group>"; };
175174
CAE962FC24A7F7BE00EFC025 /* 01-GettingStarted-AlertsAndConfirmationDialogs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "01-GettingStarted-AlertsAndConfirmationDialogs.swift"; sourceTree = "<group>"; };
176-
CAF069CF24ACC5AF00A1AAEF /* 00-Core.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "00-Core.swift"; sourceTree = "<group>"; };
177175
CAF88E7024B8E26D00539345 /* tvOSCaseStudies.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = tvOSCaseStudies.app; sourceTree = BUILT_PRODUCTS_DIR; };
178176
CAF88E7224B8E26D00539345 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
179177
CAF88E7424B8E26D00539345 /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = "<group>"; };
@@ -387,7 +385,6 @@
387385
isa = PBXGroup;
388386
children = (
389387
DC89C42424460F96006900B9 /* Info.plist */,
390-
CAF069CF24ACC5AF00A1AAEF /* 00-Core.swift */,
391388
DC89C41A24460F95006900B9 /* 00-RootView.swift */,
392389
CAE962FC24A7F7BE00EFC025 /* 01-GettingStarted-AlertsAndConfirmationDialogs.swift */,
393390
DC88D8A5245341EC0077F427 /* 01-GettingStarted-Animations.swift */,
@@ -737,7 +734,6 @@
737734
DCC68EE12447C4630037F998 /* 01-GettingStarted-Composition-TwoCounters.swift in Sources */,
738735
DC072322244663B1003A8B65 /* 03-Navigation-Sheet-LoadThenPresent.swift in Sources */,
739736
DC89C45324465452006900B9 /* 03-Navigation-Lists-NavigateAndLoad.swift in Sources */,
740-
CAF069D024ACC5AF00A1AAEF /* 00-Core.swift in Sources */,
741737
DCC68EE32447C8540037F998 /* 04-HigherOrderReducers-ReusableFavoriting.swift in Sources */,
742738
CA3E421F26B8337500581ABC /* 01-GettingStarted-FocusState.swift in Sources */,
743739
DCC68EDF2447BC810037F998 /* TemplateText.swift in Sources */,

Examples/CaseStudies/SwiftUICaseStudies/00-Core.swift

Lines changed: 0 additions & 146 deletions
This file was deleted.

Examples/CaseStudies/SwiftUICaseStudies/00-RootView.swift

Lines changed: 25 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -3,100 +3,60 @@ import SwiftUI
33

44
struct 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

182115
struct 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
}

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-AlertsAndConfirmationDialogs.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ struct AlertAndConfirmationDialog: Reducer {
105105
// MARK: - Feature view
106106

107107
struct AlertAndConfirmationDialogView: View {
108-
let store: StoreOf<AlertAndConfirmationDialog>
108+
@State var store = Store(initialState: AlertAndConfirmationDialog.State()) {
109+
AlertAndConfirmationDialog()
110+
}
109111

110112
var body: some View {
111113
WithViewStore(self.store, observe: { $0 }) { viewStore in

0 commit comments

Comments
 (0)