Skip to content

Commit f220051

Browse files
Remove a few dependencies to UIKit in SwiftUI's CaseStudies (#1492)
* Remove a few dependencies to UIKit in SwiftUI's CaseStudies * Update Examples/CaseStudies/SwiftUICaseStudies/02-Effects-Basics.swift * Update Examples/CaseStudies/SwiftUICaseStudies/02-Effects-Cancellation.swift Co-authored-by: Brandon Williams <[email protected]>
1 parent c5508de commit f220051

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

Examples/CaseStudies/SwiftUICaseStudies/00-Core.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Combine
22
import ComposableArchitecture
3-
import UIKit
43
import XCTestDynamicOverlay
54

65
struct Root: ReducerProtocol {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct EffectsBasics: ReducerProtocol {
9393

9494
struct EffectsBasicsView: View {
9595
let store: StoreOf<EffectsBasics>
96+
@Environment(\.openURL) var openURL
9697

9798
var body: some View {
9899
WithViewStore(self.store, observe: { $0 }) { viewStore in
@@ -138,7 +139,7 @@ struct EffectsBasicsView: View {
138139

139140
Section {
140141
Button("Number facts provided by numbersapi.com") {
141-
UIApplication.shared.open(URL(string: "http://numbersapi.com")!)
142+
self.openURL(URL(string: "http://numbersapi.com")!)
142143
}
143144
.foregroundStyle(.secondary)
144145
.frame(maxWidth: .infinity)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ struct EffectsCancellation: ReducerProtocol {
6969

7070
struct EffectsCancellationView: View {
7171
let store: StoreOf<EffectsCancellation>
72-
72+
@Environment(\.openURL) var openURL
73+
7374
var body: some View {
7475
WithViewStore(self.store, observe: { $0 }) { viewStore in
7576
Form {
@@ -104,7 +105,7 @@ struct EffectsCancellationView: View {
104105

105106
Section {
106107
Button("Number facts provided by numbersapi.com") {
107-
UIApplication.shared.open(URL(string: "http://numbersapi.com")!)
108+
self.openURL(URL(string: "http://numbersapi.com")!)
108109
}
109110
.foregroundStyle(.secondary)
110111
.frame(maxWidth: .infinity)

Examples/CaseStudies/SwiftUICaseStudies/03-Navigation-NavigateAndLoad.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Combine
22
import ComposableArchitecture
33
import SwiftUI
4-
import UIKit
54

65
private let readMe = """
76
This screen demonstrates navigation that depends on loading optional state.

0 commit comments

Comments
 (0)