Skip to content

Commit d0ee871

Browse files
committed
Collapse case study readmes behind disclosure groups (#1171)
* Collapse case study readmes behind disclosure groups * wip
1 parent fb38395 commit d0ee871

24 files changed

+332
-288
lines changed

Examples/CaseStudies/CaseStudies.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
DCC68EDF2447BC810037F998 /* TemplateText.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC68EDE2447BC810037F998 /* TemplateText.swift */; };
7979
DCC68EE12447C4630037F998 /* 01-GettingStarted-Composition-TwoCounters.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC68EE02447C4630037F998 /* 01-GettingStarted-Composition-TwoCounters.swift */; };
8080
DCC68EE32447C8540037F998 /* 04-HigherOrderReducers-ReusableFavoriting.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC68EE22447C8540037F998 /* 04-HigherOrderReducers-ReusableFavoriting.swift */; };
81+
DCD442C6286CA91F008B4EA7 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCD442C5286CA91F008B4EA7 /* AboutView.swift */; };
8182
DCE63B71245CC0B90080A23D /* 04-HigherOrderReducers-Recursion.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE63B70245CC0B90080A23D /* 04-HigherOrderReducers-Recursion.swift */; };
8283
DCFE1960278DBF0600C14CCF /* CaseStudiesApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFE195F278DBF0600C14CCF /* CaseStudiesApp.swift */; };
8384
/* End PBXBuildFile section */
@@ -230,6 +231,7 @@
230231
DCC68EDE2447BC810037F998 /* TemplateText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateText.swift; sourceTree = "<group>"; };
231232
DCC68EE02447C4630037F998 /* 01-GettingStarted-Composition-TwoCounters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "01-GettingStarted-Composition-TwoCounters.swift"; sourceTree = "<group>"; };
232233
DCC68EE22447C8540037F998 /* 04-HigherOrderReducers-ReusableFavoriting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "04-HigherOrderReducers-ReusableFavoriting.swift"; sourceTree = "<group>"; };
234+
DCD442C5286CA91F008B4EA7 /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; };
233235
DCE63B70245CC0B90080A23D /* 04-HigherOrderReducers-Recursion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "04-HigherOrderReducers-Recursion.swift"; sourceTree = "<group>"; };
234236
DCFE195F278DBF0600C14CCF /* CaseStudiesApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaseStudiesApp.swift; sourceTree = "<group>"; };
235237
/* End PBXFileReference section */
@@ -455,6 +457,7 @@
455457
DC85EBC2285A731E00431CF3 /* ResignFirstResponder.swift */,
456458
DCC68EDE2447BC810037F998 /* TemplateText.swift */,
457459
DC9EB4162450CBD2005F413B /* UIViewRepresented.swift */,
460+
DCD442C5286CA91F008B4EA7 /* AboutView.swift */,
458461
);
459462
path = Internal;
460463
sourceTree = "<group>";
@@ -754,6 +757,7 @@
754757
CA6AC2652451135C00C71CB3 /* CircularProgressView.swift in Sources */,
755758
CA6AC2642451135C00C71CB3 /* ReusableComponents-Download.swift in Sources */,
756759
DCFE1960278DBF0600C14CCF /* CaseStudiesApp.swift in Sources */,
760+
DCD442C6286CA91F008B4EA7 /* AboutView.swift in Sources */,
757761
CA6AC2662451135C00C71CB3 /* DownloadComponent.swift in Sources */,
758762
CA3E4C5B24B4FA0E00447C0B /* 04-HigherOrderReducers-Lifecycle.swift in Sources */,
759763
DC5B505125C86EBC000D8DFD /* 01-GettingStarted-Bindings-Forms.swift in Sources */,

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@ struct AlertAndConfirmationDialogView: View {
9090
var body: some View {
9191
WithViewStore(self.store) { viewStore in
9292
Form {
93-
Section(header: Text(template: readMe, .caption)) {
94-
Text("Count: \(viewStore.count)")
95-
Button("Alert") { viewStore.send(.alertButtonTapped) }
96-
Button("Confirmation Dialog") { viewStore.send(.confirmationDialogButtonTapped) }
93+
Section {
94+
AboutView(readMe: readMe)
9795
}
96+
97+
Text("Count: \(viewStore.count)")
98+
Button("Alert") { viewStore.send(.alertButtonTapped) }
99+
Button("Confirmation Dialog") { viewStore.send(.confirmationDialogButtonTapped) }
98100
}
99101
}
100-
.navigationBarTitle("Alerts & Confirmation Dialogs")
102+
.navigationBarTitle("Alerts & Dialogs")
101103
.alert(
102104
self.store.scope(state: \.alert),
103105
dismiss: .alertDismissed

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Basics.swift

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -65,48 +65,50 @@ struct BindingBasicsView: View {
6565
var body: some View {
6666
WithViewStore(self.store) { viewStore in
6767
Form {
68-
Section(header: Text(template: readMe, .caption)) {
69-
HStack {
70-
TextField(
71-
"Type here",
72-
text: viewStore.binding(get: \.text, send: BindingBasicsAction.textChanged)
73-
)
74-
.disableAutocorrection(true)
75-
.foregroundColor(viewStore.toggleIsOn ? .gray : .primary)
76-
Text(alternate(viewStore.text))
77-
}
78-
.disabled(viewStore.toggleIsOn)
79-
80-
Toggle(
81-
isOn: viewStore.binding(get: \.toggleIsOn, send: BindingBasicsAction.toggleChanged)
82-
.resignFirstResponder()
83-
) {
84-
Text("Disable other controls")
85-
}
86-
87-
Stepper(
68+
Section {
69+
AboutView(readMe: readMe)
70+
}
71+
72+
HStack {
73+
TextField(
74+
"Type here",
75+
text: viewStore.binding(get: \.text, send: BindingBasicsAction.textChanged)
76+
)
77+
.disableAutocorrection(true)
78+
.foregroundColor(viewStore.toggleIsOn ? .gray : .primary)
79+
Text(alternate(viewStore.text))
80+
}
81+
.disabled(viewStore.toggleIsOn)
82+
83+
Toggle(
84+
isOn: viewStore.binding(get: \.toggleIsOn, send: BindingBasicsAction.toggleChanged)
85+
.resignFirstResponder()
86+
) {
87+
Text("Disable other controls")
88+
}
89+
90+
Stepper(
91+
value: viewStore.binding(
92+
get: \.stepCount, send: BindingBasicsAction.stepCountChanged),
93+
in: 0...100
94+
) {
95+
Text("Max slider value: \(viewStore.stepCount)")
96+
.font(.body.monospacedDigit())
97+
}
98+
.disabled(viewStore.toggleIsOn)
99+
100+
HStack {
101+
Text("Slider value: \(Int(viewStore.sliderValue))")
102+
.font(.body.monospacedDigit())
103+
Slider(
88104
value: viewStore.binding(
89-
get: \.stepCount, send: BindingBasicsAction.stepCountChanged),
90-
in: 0...100
91-
) {
92-
Text("Max slider value: \(viewStore.stepCount)")
93-
.font(.body.monospacedDigit())
94-
}
95-
.disabled(viewStore.toggleIsOn)
96-
97-
HStack {
98-
Text("Slider value: \(Int(viewStore.sliderValue))")
99-
.font(.body.monospacedDigit())
100-
Slider(
101-
value: viewStore.binding(
102-
get: \.sliderValue,
103-
send: BindingBasicsAction.sliderValueChanged
104-
),
105-
in: 0...Double(viewStore.stepCount)
106-
)
107-
}
108-
.disabled(viewStore.toggleIsOn)
105+
get: \.sliderValue,
106+
send: BindingBasicsAction.sliderValueChanged
107+
),
108+
in: 0...Double(viewStore.stepCount)
109+
)
109110
}
111+
.disabled(viewStore.toggleIsOn)
110112
}
111113
}
112114
.navigationBarTitle("Bindings basics")

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Forms.swift

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -53,41 +53,43 @@ struct BindingFormView: View {
5353
var body: some View {
5454
WithViewStore(self.store) { viewStore in
5555
Form {
56-
Section(header: Text(template: readMe, .caption)) {
57-
HStack {
58-
TextField("Type here", text: viewStore.binding(\.$text))
59-
.disableAutocorrection(true)
60-
.foregroundColor(viewStore.toggleIsOn ? .gray : .primary)
61-
62-
Text(alternate(viewStore.text))
63-
}
64-
.disabled(viewStore.toggleIsOn)
65-
66-
Toggle(
67-
"Disable other controls",
68-
isOn: viewStore.binding(\.$toggleIsOn)
69-
.resignFirstResponder()
70-
)
71-
72-
Stepper(value: viewStore.binding(\.$stepCount), in: 0...100) {
73-
Text("Max slider value: \(viewStore.stepCount)")
74-
.font(.body.monospacedDigit())
75-
}
76-
.disabled(viewStore.toggleIsOn)
77-
78-
HStack {
79-
Text("Slider value: \(Int(viewStore.sliderValue))")
80-
.font(.body.monospacedDigit())
81-
82-
Slider(value: viewStore.binding(\.$sliderValue), in: 0...Double(viewStore.stepCount))
83-
}
84-
.disabled(viewStore.toggleIsOn)
85-
86-
Button("Reset") {
87-
viewStore.send(.resetButtonTapped)
88-
}
89-
.foregroundColor(.red)
56+
Section {
57+
AboutView(readMe: readMe)
9058
}
59+
60+
HStack {
61+
TextField("Type here", text: viewStore.binding(\.$text))
62+
.disableAutocorrection(true)
63+
.foregroundColor(viewStore.toggleIsOn ? .gray : .primary)
64+
65+
Text(alternate(viewStore.text))
66+
}
67+
.disabled(viewStore.toggleIsOn)
68+
69+
Toggle(
70+
"Disable other controls",
71+
isOn: viewStore.binding(\.$toggleIsOn)
72+
.resignFirstResponder()
73+
)
74+
75+
Stepper(value: viewStore.binding(\.$stepCount), in: 0...100) {
76+
Text("Max slider value: \(viewStore.stepCount)")
77+
.font(.body.monospacedDigit())
78+
}
79+
.disabled(viewStore.toggleIsOn)
80+
81+
HStack {
82+
Text("Slider value: \(Int(viewStore.sliderValue))")
83+
.font(.body.monospacedDigit())
84+
85+
Slider(value: viewStore.binding(\.$sliderValue), in: 0...Double(viewStore.stepCount))
86+
}
87+
.disabled(viewStore.toggleIsOn)
88+
89+
Button("Reset") {
90+
viewStore.send(.resetButtonTapped)
91+
}
92+
.foregroundColor(.red)
9193
}
9294
}
9395
.navigationBarTitle("Bindings form")

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Composition-TwoCounters.swift

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,27 @@ struct TwoCountersView: View {
3939

4040
var body: some View {
4141
Form {
42-
Section(header: Text(template: readMe, .caption)) {
43-
HStack {
44-
Text("Counter 1")
42+
Section {
43+
AboutView(readMe: readMe)
44+
}
45+
HStack {
46+
Text("Counter 1")
4547

46-
CounterView(
47-
store: self.store.scope(state: \.counter1, action: TwoCountersAction.counter1)
48-
)
49-
.buttonStyle(.borderless)
50-
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .trailing)
51-
}
52-
HStack {
53-
Text("Counter 2")
48+
CounterView(
49+
store: self.store.scope(state: \.counter1, action: TwoCountersAction.counter1)
50+
)
51+
.buttonStyle(.borderless)
52+
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .trailing)
53+
}
54+
HStack {
55+
Text("Counter 2")
56+
57+
CounterView(
58+
store: self.store.scope(state: \.counter2, action: TwoCountersAction.counter2)
59+
)
60+
.buttonStyle(.borderless)
61+
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .trailing)
5462

55-
CounterView(
56-
store: self.store.scope(state: \.counter2, action: TwoCountersAction.counter2)
57-
)
58-
.buttonStyle(.borderless)
59-
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .trailing)
60-
}
6163
}
6264
}
6365
.navigationBarTitle("Two counter demo")

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ struct CounterDemoView: View {
5151

5252
var body: some View {
5353
Form {
54-
Section(header: Text(readMe)) {
54+
Section {
55+
AboutView(readMe: readMe)
56+
}
57+
58+
Section {
5559
CounterView(store: self.store)
5660
.buttonStyle(.borderless)
5761
.frame(maxWidth: .infinity, maxHeight: .infinity)

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

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,30 @@ struct OptionalBasicsView: View {
5454
var body: some View {
5555
WithViewStore(self.store) { viewStore in
5656
Form {
57-
Section(header: Text(template: readMe, .caption)) {
58-
Button("Toggle counter state") {
59-
viewStore.send(.toggleCounterButtonTapped)
60-
}
57+
Section {
58+
AboutView(readMe: readMe)
59+
}
6160

62-
IfLetStore(
63-
self.store.scope(
64-
state: \.optionalCounter,
65-
action: OptionalBasicsAction.optionalCounter
66-
),
67-
then: { store in
68-
VStack(alignment: .leading, spacing: 16) {
69-
Text(template: "`CounterState` is non-`nil`", .body)
70-
CounterView(store: store)
71-
.buttonStyle(.borderless)
72-
}
73-
},
74-
else: {
75-
Text(template: "`CounterState` is `nil`", .body)
76-
}
77-
)
61+
Button("Toggle counter state") {
62+
viewStore.send(.toggleCounterButtonTapped)
7863
}
64+
65+
IfLetStore(
66+
self.store.scope(
67+
state: \.optionalCounter,
68+
action: OptionalBasicsAction.optionalCounter
69+
),
70+
then: { store in
71+
VStack(alignment: .leading, spacing: 16) {
72+
Text(template: "`CounterState` is non-`nil`")
73+
CounterView(store: store)
74+
.buttonStyle(.borderless)
75+
}
76+
},
77+
else: {
78+
Text(template: "`CounterState` is `nil`")
79+
}
80+
)
7981
}
8082
}
8183
.navigationBarTitle("Optional state")

Examples/CaseStudies/SwiftUICaseStudies/02-Effects-Basics.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct EffectsBasicsView: View {
8888
WithViewStore(self.store) { viewStore in
8989
Form {
9090
Section {
91-
Text(readMe)
91+
AboutView(readMe: readMe)
9292
}
9393

9494
Section {
@@ -123,6 +123,7 @@ struct EffectsBasicsView: View {
123123
UIApplication.shared.open(URL(string: "http://numbersapi.com")!)
124124
}
125125
.foregroundColor(.gray)
126+
.frame(maxWidth: .infinity)
126127
}
127128
}
128129
.buttonStyle(.borderless)

Examples/CaseStudies/SwiftUICaseStudies/02-Effects-Cancellation.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct EffectsCancellationView: View {
8282
WithViewStore(self.store) { viewStore in
8383
Form {
8484
Section {
85-
Text(readMe)
85+
AboutView(readMe: readMe)
8686
}
8787

8888
Section {
@@ -117,6 +117,7 @@ struct EffectsCancellationView: View {
117117
UIApplication.shared.open(URL(string: "http://numbersapi.com")!)
118118
}
119119
.foregroundColor(.gray)
120+
.frame(maxWidth: .infinity)
120121
}
121122
}
122123
.buttonStyle(.borderless)

Examples/CaseStudies/SwiftUICaseStudies/02-Effects-LongLiving.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ struct LongLivingEffectsView: View {
6565
var body: some View {
6666
WithViewStore(self.store) { viewStore in
6767
Form {
68-
Section(header: Text(template: readMe, .body)) {
69-
Text("A screenshot of this screen has been taken \(viewStore.screenshotCount) times.")
70-
.font(.headline)
68+
Section {
69+
AboutView(readMe: readMe)
7170
}
7271

72+
Text("A screenshot of this screen has been taken \(viewStore.screenshotCount) times.")
73+
.font(.headline)
74+
7375
Section {
7476
NavigationLink(destination: self.detailView) {
7577
Text("Navigate to another screen")

0 commit comments

Comments
 (0)