···11-import React, {forwardRef, useCallback, useContext} from 'react'
11+import React, {Children, forwardRef, useCallback, useContext} from 'react'
22import {View} from 'react-native'
33import {DrawerGestureContext} from 'react-native-drawer-layout'
44import {Gesture, GestureDetector} from 'react-native-gesture-handler'
···1717} from 'react-native-reanimated'
1818import {useFocusEffect} from '@react-navigation/native'
19192020+import {isAndroid} from '#/platform/detection'
2021import {useSetDrawerSwipeDisabled} from '#/state/shell'
2122import {atoms as a, native} from '#/alf'
2223···148149 style={[a.flex_1]}
149150 initialPage={initialPage}
150151 onPageScroll={handlePageScroll}>
151151- {children}
152152+ {isAndroid
153153+ ? Children.map(children, child => (
154154+ <CaptureSwipesAndroid>{child}</CaptureSwipesAndroid>
155155+ ))
156156+ : children}
152157 </AnimatedPagerView>
153158 </GestureDetector>
154159 </View>
155160 )
156161 },
157162)
163163+164164+// HACK.
165165+// This works around https://github.com/callstack/react-native-pager-view/issues/960.
166166+// It appears that the Pressables inside the pager get confused if there's enough work
167167+// happening on the JS thread, and mistakingly interpret a pager swipe as a tap.
168168+// We can prevent this by stealing all horizontal movements from the tree inside.
169169+function CaptureSwipesAndroid({children}: {children: React.ReactNode}) {
170170+ const lastTouchStart = React.useRef<{x: number; y: number} | null>(null)
171171+ return (
172172+ <View
173173+ onTouchStart={e => {
174174+ lastTouchStart.current = {
175175+ x: e.nativeEvent.pageX,
176176+ y: e.nativeEvent.pageY,
177177+ }
178178+ }}
179179+ onMoveShouldSetResponderCapture={e => {
180180+ const coords = lastTouchStart.current
181181+ if (!coords) {
182182+ return false
183183+ }
184184+ const dx = Math.abs(e.nativeEvent.pageX - coords.x)
185185+ if (dx > 0) {
186186+ // This is a horizontal movement and will result in a swipe.
187187+ // Prevent pager children from receiving this touch.
188188+ return true
189189+ }
190190+ return false
191191+ }}>
192192+ {children}
193193+ </View>
194194+ )
195195+}
158196159197function usePagerHandlers(
160198 handlers: {