Skip to content

Commit 507f0e6

Browse files
committed
Switch to SwiftUIIntrospect (#75)
1 parent 306b53f commit 507f0e6

File tree

4 files changed

+50
-102
lines changed

4 files changed

+50
-102
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,26 @@ jobs:
2626
- mac-catalyst
2727
- tvOS
2828
swift:
29-
- 5.5
30-
- 5.6
3129
- 5.7
3230
- 5.8
3331
include:
34-
- swift: 5.5
35-
os: macos-12
36-
- swift: 5.6
37-
os: macos-12
3832
- swift: 5.7
3933
os: macos-13
4034
- swift: 5.8
4135
os: macos-13
4236
steps:
43-
- uses: actions/checkout@v3
37+
- name: Git Checkout
38+
uses: actions/checkout@v3
39+
4440
- name: Test Library
4541
uses: mxcl/xcodebuild@v2
4642
with:
4743
platform: ${{ matrix.platform }}
4844
swift: ~${{ matrix.swift }}
4945
action: test
5046
scheme: NavigationTransitions
51-
- if: ${{ matrix.swift >= 5.7 }}
52-
name: Build Examples/Demo
47+
48+
- name: Build Examples/Demo
5349
uses: mxcl/xcodebuild@v2
5450
with:
5551
platform: ${{ matrix.platform }}

Package.resolved

Lines changed: 29 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.5
1+
// swift-tools-version: 5.7
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
@@ -15,14 +15,14 @@ let package = Package(
1515
// MARK: Dependencies
1616

1717
package.dependencies = [
18-
.package(url: "https://github.com/siteline/SwiftUI-Introspect", from: "0.1.4"),
19-
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "0.6.0"), // dev
20-
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "0.5.0"), // dev
18+
.package(url: "https://github.com/siteline/swiftui-introspect", from: "0.6.0"),
19+
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "0.10.3"), // dev
20+
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "0.8.5"), // dev
2121
]
2222

23-
let Introspect: Target.Dependency = .product(
24-
name: "Introspect",
25-
package: "SwiftUI-Introspect"
23+
let SwiftUIIntrospect: Target.Dependency = .product(
24+
name: "SwiftUIIntrospect",
25+
package: "swiftui-introspect"
2626
)
2727

2828
let CustomDump: Target.Dependency = .product(
@@ -57,7 +57,7 @@ package.targets += [
5757
.target(name: "NavigationTransition", dependencies: [
5858
"Animation",
5959
"AtomicTransition",
60-
Introspect,
60+
SwiftUIIntrospect,
6161
]),
6262

6363
.target(name: "NavigationTransitions", dependencies: [

Sources/NavigationTransitions/NavigationTransition+SwiftUI.swift

Lines changed: 8 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@_implementationOnly import Introspect
1+
@_implementationOnly import SwiftUIIntrospect
22
import SwiftUI
33

44
// MARK: iOS 16
@@ -51,59 +51,13 @@ extension View {
5151
_ transition: AnyNavigationTransition,
5252
interactivity: AnyNavigationTransition.Interactivity = .default
5353
) -> some View {
54-
self.modifier(
55-
NavigationTransitionModifier(
56-
transition: transition,
57-
interactivity: interactivity
58-
)
59-
)
60-
}
61-
}
62-
63-
struct NavigationTransitionModifier: ViewModifier {
64-
let transition: AnyNavigationTransition
65-
let interactivity: AnyNavigationTransition.Interactivity
66-
67-
func body(content: Content) -> some View {
68-
content.inject(
69-
UIKitIntrospectionViewController { spy -> UINavigationController? in
70-
guard spy.parent != nil else {
71-
return nil // don't evaluate view until it's on screen
72-
}
73-
if let controller = Introspect.previousSibling(ofType: UINavigationController.self, from: spy) {
74-
return controller
75-
} else if let controller = spy.navigationController {
76-
return controller
77-
} else {
78-
runtimeWarn(
79-
"""
80-
Modifier "navigationTransition" was applied to a view other than NavigationStack OR NavigationView with .navigationViewStyle(.stack). This has no effect.
81-
82-
Please make sure you're applying the modifier correctly:
83-
84-
NavigationStack {
85-
...
86-
}
87-
.navigationTransition(...)
88-
89-
OR
90-
91-
NavigationView {
92-
...
93-
}
94-
.navigationViewStyle(.stack)
95-
.navigationTransition(...)
96-
97-
If you're attempting to apply the modifier to NavigationSplitView OR NavigationView with .navigationViewStyle(.columns), this has no effect either. Instead, you should apply the modifier to the child stack navigation component within it (if any).
98-
"""
99-
)
100-
return nil
101-
}
102-
}
103-
customize: { (controller: UINavigationController) in
104-
controller.setNavigationTransition(transition, interactivity: interactivity)
105-
}
106-
)
54+
self.introspect(
55+
.navigationView(style: .stack),
56+
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17),
57+
scope: [.receiver, .ancestor]
58+
) { controller in
59+
controller.setNavigationTransition(transition, interactivity: interactivity)
60+
}
10761
}
10862
}
10963

0 commit comments

Comments
 (0)