Skip to content

Commit

Permalink
Merge pull request #12 from ra1028/refactor/update-examples
Browse files Browse the repository at this point in the history
refactor: Improve example apps
  • Loading branch information
ra1028 authored Aug 8, 2021
2 parents bc6728a + 8f8f3ac commit 7d67288
Show file tree
Hide file tree
Showing 56 changed files with 1,066 additions and 478 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
swift --version
xcodebuild -version
- name: Test for macOS
run: xcodebuild test -scheme Hooks-Package -destination "platform=macOS"
run: xcodebuild test -scheme Hooks -destination "platform=macOS"
- name: Test for iOS
run: xcodebuild test -scheme Hooks-Package -destination "platform=iOS Simulator,name=iPhone 12 Pro"
run: xcodebuild test -scheme Hooks -destination "platform=iOS Simulator,name=iPhone 12 Pro"
- name: Test for tvOS
run: xcodebuild test -scheme Hooks-Package -destination "platform=tvOS Simulator,name=Apple TV"
run: xcodebuild test -scheme Hooks -destination "platform=tvOS Simulator,name=Apple TV"
- name: Build for watchOS
run: WATCHOS=true xcodebuild build -scheme Hooks-Package -destination "platform=watchOS Simulator,name=Apple Watch Series 6 - 44mm"
run: WATCHOS=true xcodebuild build -scheme Hooks -destination "platform=watchOS Simulator,name=Apple Watch Series 6 - 44mm"

build-examples:
name: Build examples
Expand All @@ -61,10 +61,12 @@ jobs:
xcrun simctl list runtimes
xcrun simctl list devices $OLD_TARGET_OS
- name: Build TheMovieDB
run: xcodebuild build -scheme TheMovieDB -destination "platform=iOS Simulator,name=iPhone 12 Pro"
run: xcodebuild build -scheme TheMovieDB-MVVM -destination "platform=iOS Simulator,name=iPhone 12 Pro"
- name: Test TheMovieDB
run: xcodebuild test -scheme TheMovieDB-MVVM-Tests -destination "platform=iOS Simulator,name=iPhone 12 Pro"
- name: Build Basic
run: xcodebuild build -scheme Basic -destination "platform=iOS Simulator,name=iPhone 12 Pro"
run: xcodebuild build -scheme BasicUsage -destination "platform=iOS Simulator,name=iPhone 12 Pro"
- name: Build Legacy
run: xcodebuild build -scheme Legacy -destination "platform=iOS Simulator,name=iPhone 12 Pro"
run: xcodebuild build -scheme Todo -destination "platform=iOS Simulator,name=iPhone 12 Pro"
- name: Build Legacy with iOS13
run: xcodebuild build -scheme Legacy -destination "platform=iOS Simulator,name=iPhone 11 Pro,OS=$OLD_TARGET_OS"
run: xcodebuild build -scheme Todo -destination "platform=iOS Simulator,name=iPhone 11 Pro,OS=$OLD_TARGET_OS"
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct APIRequestPage: HookView {
var hookBody: some View {
let (phase, fetch) = useFetchPosts()

return ScrollView {
ScrollView {
VStack {
switch phase {
case .running:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ struct CounterPage: HookView {
Text(String(format: "%02d", count.wrappedValue))
.lineLimit(1)
.minimumScaleFactor(0.1)
.font(.system(size: 100, weight: .heavy, design: .rounded))
.font(.system(size: 100, weight: .heavy, design: .monospaced))
.padding(30)
.frame(width: 200, height: 200)
.background(Color(.secondarySystemBackground))
.shadow(color: Color(.sRGBLinear, white: 0, opacity: 0.2), radius: 3, y: 3)
.clipShape(Circle())

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

Toggle("Auto +", isOn: isAutoIncrement).fixedSize()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct HookListPage: HookView {
var hookBody: some View {
let colorScheme = useState(useEnvironment(\.colorScheme))

return ColorSchemeContext.Provider(value: colorScheme) {
ColorSchemeContext.Provider(value: colorScheme) {
ScrollView {
VStack {
useStateRow
Expand Down Expand Up @@ -54,7 +54,12 @@ struct HookListPage: HookView {
let (count, dispatch) = useReducer(reducer, initialState: 0)

return Row("useReducer") {
Stepper(count.description, onIncrement: { dispatch(.plus) }, onDecrement: { dispatch(.minus) })
Stepper(
count.description,
onIncrement: { dispatch(.plus) },
onDecrement: { dispatch(.minus) }
)

Button("Reset") { dispatch(.reset) }
}
}
Expand Down Expand Up @@ -108,7 +113,9 @@ struct HookListPage: HookView {
return Row("useMemo") {
Circle().fill(randomColor).frame(width: 30, height: 30)
Spacer()
Button("Random", action: { flag.wrappedValue.toggle() })
Button("Random") {
flag.wrappedValue.toggle()
}
}
}

Expand All @@ -128,7 +135,9 @@ struct HookListPage: HookView {
return Row("useRef") {
Text("Fibonacci = \(fibonacci.wrappedValue)")
Spacer()
Button("Next", action: { flag.wrappedValue.toggle() })
Button("Next") {
flag.wrappedValue.toggle()
}
}
}

Expand Down Expand Up @@ -162,7 +171,7 @@ struct HookListPage: HookView {
}

return Row("usePublisherSubscribe") {
Group {
HStack {
switch phase {
case .running:
ProgressView()
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 7d67288

Please sign in to comment.