Skip to content

Commit 7d67288

Browse files
authored
Merge pull request #12 from ra1028/refactor/update-examples
refactor: Improve example apps
2 parents bc6728a + 8f8f3ac commit 7d67288

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1066
-478
lines changed

.github/workflows/test.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ jobs:
2929
swift --version
3030
xcodebuild -version
3131
- name: Test for macOS
32-
run: xcodebuild test -scheme Hooks-Package -destination "platform=macOS"
32+
run: xcodebuild test -scheme Hooks -destination "platform=macOS"
3333
- name: Test for iOS
34-
run: xcodebuild test -scheme Hooks-Package -destination "platform=iOS Simulator,name=iPhone 12 Pro"
34+
run: xcodebuild test -scheme Hooks -destination "platform=iOS Simulator,name=iPhone 12 Pro"
3535
- name: Test for tvOS
36-
run: xcodebuild test -scheme Hooks-Package -destination "platform=tvOS Simulator,name=Apple TV"
36+
run: xcodebuild test -scheme Hooks -destination "platform=tvOS Simulator,name=Apple TV"
3737
- name: Build for watchOS
38-
run: WATCHOS=true xcodebuild build -scheme Hooks-Package -destination "platform=watchOS Simulator,name=Apple Watch Series 6 - 44mm"
38+
run: WATCHOS=true xcodebuild build -scheme Hooks -destination "platform=watchOS Simulator,name=Apple Watch Series 6 - 44mm"
3939

4040
build-examples:
4141
name: Build examples
@@ -61,10 +61,12 @@ jobs:
6161
xcrun simctl list runtimes
6262
xcrun simctl list devices $OLD_TARGET_OS
6363
- name: Build TheMovieDB
64-
run: xcodebuild build -scheme TheMovieDB -destination "platform=iOS Simulator,name=iPhone 12 Pro"
64+
run: xcodebuild build -scheme TheMovieDB-MVVM -destination "platform=iOS Simulator,name=iPhone 12 Pro"
65+
- name: Test TheMovieDB
66+
run: xcodebuild test -scheme TheMovieDB-MVVM-Tests -destination "platform=iOS Simulator,name=iPhone 12 Pro"
6567
- name: Build Basic
66-
run: xcodebuild build -scheme Basic -destination "platform=iOS Simulator,name=iPhone 12 Pro"
68+
run: xcodebuild build -scheme BasicUsage -destination "platform=iOS Simulator,name=iPhone 12 Pro"
6769
- name: Build Legacy
68-
run: xcodebuild build -scheme Legacy -destination "platform=iOS Simulator,name=iPhone 12 Pro"
70+
run: xcodebuild build -scheme Todo -destination "platform=iOS Simulator,name=iPhone 12 Pro"
6971
- name: Build Legacy with iOS13
70-
run: xcodebuild build -scheme Legacy -destination "platform=iOS Simulator,name=iPhone 11 Pro,OS=$OLD_TARGET_OS"
72+
run: xcodebuild build -scheme Todo -destination "platform=iOS Simulator,name=iPhone 11 Pro,OS=$OLD_TARGET_OS"

Examples/Basic/APIRequestPage.swift Examples/BasicUsage/APIRequestPage.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct APIRequestPage: HookView {
2323
var hookBody: some View {
2424
let (phase, fetch) = useFetchPosts()
2525

26-
return ScrollView {
26+
ScrollView {
2727
VStack {
2828
switch phase {
2929
case .running:
File renamed without changes.

Examples/Basic/CounterPage.swift Examples/BasicUsage/CounterPage.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ struct CounterPage: HookView {
2020
Text(String(format: "%02d", count.wrappedValue))
2121
.lineLimit(1)
2222
.minimumScaleFactor(0.1)
23-
.font(.system(size: 100, weight: .heavy, design: .rounded))
23+
.font(.system(size: 100, weight: .heavy, design: .monospaced))
2424
.padding(30)
2525
.frame(width: 200, height: 200)
2626
.background(Color(.secondarySystemBackground))
27-
.shadow(color: Color(.sRGBLinear, white: 0, opacity: 0.2), radius: 3, y: 3)
27+
.clipShape(Circle())
2828

29-
Stepper(value: count, in: 0...(.max)) { EmptyView() }.fixedSize()
29+
Stepper(value: count, in: 0...(.max), label: EmptyView.init).fixedSize()
3030

3131
Toggle("Auto +", isOn: isAutoIncrement).fixedSize()
3232
}

Examples/Basic/HookListPage.swift Examples/BasicUsage/HookListPage.swift

+14-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct HookListPage: HookView {
88
var hookBody: some View {
99
let colorScheme = useState(useEnvironment(\.colorScheme))
1010

11-
return ColorSchemeContext.Provider(value: colorScheme) {
11+
ColorSchemeContext.Provider(value: colorScheme) {
1212
ScrollView {
1313
VStack {
1414
useStateRow
@@ -54,7 +54,12 @@ struct HookListPage: HookView {
5454
let (count, dispatch) = useReducer(reducer, initialState: 0)
5555

5656
return Row("useReducer") {
57-
Stepper(count.description, onIncrement: { dispatch(.plus) }, onDecrement: { dispatch(.minus) })
57+
Stepper(
58+
count.description,
59+
onIncrement: { dispatch(.plus) },
60+
onDecrement: { dispatch(.minus) }
61+
)
62+
5863
Button("Reset") { dispatch(.reset) }
5964
}
6065
}
@@ -108,7 +113,9 @@ struct HookListPage: HookView {
108113
return Row("useMemo") {
109114
Circle().fill(randomColor).frame(width: 30, height: 30)
110115
Spacer()
111-
Button("Random", action: { flag.wrappedValue.toggle() })
116+
Button("Random") {
117+
flag.wrappedValue.toggle()
118+
}
112119
}
113120
}
114121

@@ -128,7 +135,9 @@ struct HookListPage: HookView {
128135
return Row("useRef") {
129136
Text("Fibonacci = \(fibonacci.wrappedValue)")
130137
Spacer()
131-
Button("Next", action: { flag.wrappedValue.toggle() })
138+
Button("Next") {
139+
flag.wrappedValue.toggle()
140+
}
132141
}
133142
}
134143

@@ -162,7 +171,7 @@ struct HookListPage: HookView {
162171
}
163172

164173
return Row("usePublisherSubscribe") {
165-
Group {
174+
HStack {
166175
switch phase {
167176
case .running:
168177
ProgressView()
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)