File tree Expand file tree Collapse file tree 2 files changed +46
-16
lines changed Expand file tree Collapse file tree 2 files changed +46
-16
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,16 @@ extension View {
97
97
introspect ( selector: TargetViewSelector . ancestorOrSiblingContaining, customize: customize)
98
98
}
99
99
100
+ /// Finds a `UICollectionView` from a `SwiftUI.List`, or `SwiftUI.List` child.
101
+ public func introspectCollectionView( customize: @escaping ( UICollectionView ) -> ( ) ) -> some View {
102
+ introspect ( selector: TargetViewSelector . ancestorOrSiblingContaining, customize: customize)
103
+ }
104
+
105
+ /// Finds a `UICollectionView` from a `SwiftUI.List`, or `SwiftUI.List` child. You can attach this directly to the element inside the list.
106
+ public func introspectCollectionViewCell( customize: @escaping ( UICollectionViewCell ) -> ( ) ) -> some View {
107
+ introspect ( selector: TargetViewSelector . ancestorOrSiblingContaining, customize: customize)
108
+ }
109
+
100
110
/// Finds a `UIScrollView` from a `SwiftUI.ScrollView`, or `SwiftUI.ScrollView` child.
101
111
public func introspectScrollView( customize: @escaping ( UIScrollView ) -> ( ) ) -> some View {
102
112
if #available( iOS 14 . 0 , tvOS 14 . 0 , macOS 11 . 0 , * ) {
Original file line number Diff line number Diff line change @@ -152,22 +152,42 @@ private struct ListTestView: View {
152
152
let spyCell2 : ( ) -> Void
153
153
154
154
var body : some View {
155
- List {
156
- Text ( " Item 1 " )
157
- Text ( " Item 2 " )
158
- . introspectTableView { tableView in
159
- self . spy2 ( )
160
- }
161
- . introspectTableViewCell { cell in
162
- self . spyCell2 ( )
163
- }
164
-
165
- }
166
- . introspectTableView { tableView in
167
- self . spy1 ( )
168
- }
169
- . introspectTableViewCell { cell in
170
- self . spyCell1 ( )
155
+ if #available( iOS 16 , tvOS 16 , macOS 13 , * ) {
156
+ List {
157
+ Text ( " Item 1 " )
158
+ Text ( " Item 2 " )
159
+ . introspectCollectionView { tableView in
160
+ self . spy2 ( )
161
+ }
162
+ . introspectCollectionViewCell { cell in
163
+ self . spyCell2 ( )
164
+ }
165
+
166
+ }
167
+ . introspectCollectionView { tableView in
168
+ self . spy1 ( )
169
+ }
170
+ . introspectCollectionViewCell { cell in
171
+ self . spyCell1 ( )
172
+ }
173
+ } else {
174
+ List {
175
+ Text ( " Item 1 " )
176
+ Text ( " Item 2 " )
177
+ . introspectTableView { tableView in
178
+ self . spy2 ( )
179
+ }
180
+ . introspectTableViewCell { cell in
181
+ self . spyCell2 ( )
182
+ }
183
+
184
+ }
185
+ . introspectTableView { tableView in
186
+ self . spy1 ( )
187
+ }
188
+ . introspectTableViewCell { cell in
189
+ self . spyCell1 ( )
190
+ }
171
191
}
172
192
}
173
193
}
You can’t perform that action at this time.
0 commit comments