Repository navigation
Conversation
|
Thanks @d-mato, great fix and a really clear write-up! 🙏 One request: please move all the iOS 15 code into its own file and leave PagerScrollDelegate.swift unchanged. Why: React Native still supports iOS 15.1 as its minimum (https://github.com/react/react-native/blob/7fc911afd9d4ee46bdeaf9a9ddd29a8366060d8a/packages/react-native/scripts/cocoapods/helpers.rb#L84), so we need this fix for now. But iOS 27 is coming, and we plan to drop these iOS 15 workarounds later. When that happens, removing them should take a couple of minutes: delete the iOS 15 files and update one or two call sites in PagerView.swift, with no hunting through shared code. What to move: right now these iOS 15 changes are in the delegate that every iOS version uses:
Suggestion (just a sketch): // ios/PagerScrollDelegateIOS15.swift PagerView.swift then chooses this delegate on iOS 15. If the embedded scroll view needs a plain UIScrollViewDelegate to forward to, please handle that in the iOS 15 file as well. Everything else looks great. Thanks again! 🚀 |
f1a42fc to
0f76ed7
Compare
|
Thanks, done. I also rebased onto main to resolve the conflict with #1195. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Summary
Fixes #1080.
On iOS 15,
onPageScrollandonPageScrollStateChangedare never emitted, so the tab indicator of react-native-tab-view / material-top-tabs doesn't follow the page.onPageSelectedstill works.Same root cause as #1148: on iOS 15 the paging is done by a scroll view SwiftUI embeds in the collection view (
_UICollectionViewOrthogonalScrollerEmbeddedScrollView), andPagerScrollDelegateis only set on the collection view, so it never sees the scroll.This attaches a
PagerScrollDelegateto the embedded scroll view too, fromcollectionView(_:willDisplay:forItemAt:)since it doesn't exist yet when introspect runs. The iOS 15 code is inPagerScrollDelegateIOS15.swiftandPagerViewIOS15Compat.swift, andPagerScrollDelegate.swiftis unchanged.Before:
ios15-material-top-tabs-before.mp4
After:
ios15-material-top-tabs-after.mp4
Test Plan
Example app on an iOS 15.5 simulator (iPad Air 2):
State: dragging,scrollandState: idle. Still works after "Add new page".react-native-screensv4.19.0 breaks the global back swipe gesture on pager views #1050 Back Gesture Repro: paging works as on main. I couldn't test the back swipe itself, since synthesized edge swipes don't trigger it on the simulator.e2e on iOS 26.5 passes, apart from flaky tests that pass on re-run. On iOS 17.5 it fails the same tests as main. The SwiftPM example builds too.
We also applied this as a patch to 8.0.5 in our app, and the tabs of both react-native-tab-view and react-native-collapsible-tab-view work again on iOS 15.5.
Compatibility
Checklist
README.md