-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for UICollectionView introspection #169
Conversation
Add support for UICollectionView
Adding some tests. Will merge shortly. |
oh, amazing! 🥳 glad to be of help... and thrilled to be back on |
if my app support ios15 and ios16 |
@X901 yes, you will need to introspect them both separatedly. For this particular case, I don't think you'll need to add an // add this to your codebase
extension View {
func availability<Transformed: View>(
@ViewBuilder _ transform: (Self) -> Transformed
) -> Transformed {
transform(self)
}
}
[...]
struct YourView {
var body: some View {
List {
[...]
}
.availability {
if #available(iOS 16, *) {
$0.introspectCollectionView { collectionView in
[...]
}
} else {
$0.introspectTableView { tableView in
[...]
}
}
}
}
} I have some ideas on how to improve the ergonomics of introspecting the same SwiftUI component in different OS versions, but I'm yet to explore them when I get some spare time. |
Thank you, you give me A great idea 👍 |
thanks for sharing this snippet, really helped me get this working with Lists in 15 and 16. <3 |
iOS 16 has migrated
List
to useUICollectionView
under the hood (at least in some cases.)This is a very simple addition to add support for
UICollectionView
introspection.