diff options
author | gpp <52042597+gpp-0@users.noreply.github.com> | 2025-01-17 04:02:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-17 02:02:59 +0000 |
commit | 5130d19ebdb3267f58e2b6407eb5c4f95107887c (patch) | |
tree | 9be2247941dfee1cd7a3b9a8f935103a0e73a699 /patches | |
parent | 9e3f2f43745eed9c71cb985e48135b7363d91aa9 (diff) | |
download | voidsky-5130d19ebdb3267f58e2b6407eb5c4f95107887c.tar.zst |
[Android] Fix taps triggering while swiping (#7459)
* [Android] Fix taps triggering while swiping * Revert "[Android] Try to disambiguate taps from swipes (#7448)" This reverts commit 96054f4addb63994b3d2f5fe1d288f4dd3c246c2. * Update patch to match callstack/react-native-pager-view#961 * Make it symmetrical --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'patches')
-rw-r--r-- | patches/react-native-pager-view+6.6.1.patch | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/patches/react-native-pager-view+6.6.1.patch b/patches/react-native-pager-view+6.6.1.patch new file mode 100644 index 000000000..8e94570cf --- /dev/null +++ b/patches/react-native-pager-view+6.6.1.patch @@ -0,0 +1,72 @@ +diff --git a/node_modules/react-native-pager-view/android/build/tmp/kotlin-classes/debug/com/reactnativepagerview/NestedScrollableHost.class b/node_modules/react-native-pager-view/android/build/tmp/kotlin-classes/debug/com/reactnativepagerview/NestedScrollableHost.class +new file mode 100644 +index 0000000..b64fccc +Binary files /dev/null and b/node_modules/react-native-pager-view/android/build/tmp/kotlin-classes/debug/com/reactnativepagerview/NestedScrollableHost.class differ +diff --git a/node_modules/react-native-pager-view/android/src/main/java/com/reactnativepagerview/NestedScrollableHost.kt b/node_modules/react-native-pager-view/android/src/main/java/com/reactnativepagerview/NestedScrollableHost.kt +index 91d9946..87b58d0 100644 +--- a/node_modules/react-native-pager-view/android/src/main/java/com/reactnativepagerview/NestedScrollableHost.kt ++++ b/node_modules/react-native-pager-view/android/src/main/java/com/reactnativepagerview/NestedScrollableHost.kt +@@ -8,6 +8,7 @@ import android.view.ViewConfiguration + import android.widget.FrameLayout + import androidx.viewpager2.widget.ViewPager2 + import androidx.viewpager2.widget.ViewPager2.ORIENTATION_HORIZONTAL ++import com.facebook.react.uimanager.events.NativeGestureUtil + import kotlin.math.absoluteValue + import kotlin.math.sign + +@@ -27,6 +28,7 @@ class NestedScrollableHost : FrameLayout { + private var touchSlop = 0 + private var initialX = 0f + private var initialY = 0f ++ private var nativeGestureStarted: Boolean = false + private val parentViewPager: ViewPager2? + get() { + var v: View? = parent as? View +@@ -57,17 +59,14 @@ class NestedScrollableHost : FrameLayout { + } + + private fun handleInterceptTouchEvent(e: MotionEvent) { +- val orientation = parentViewPager?.orientation ?: return +- +- // Early return if child can't scroll in same direction as parent +- if (!canChildScroll(orientation, -1f) && !canChildScroll(orientation, 1f)) { +- return +- } ++ val orientation = parentViewPager?.orientation + + if (e.action == MotionEvent.ACTION_DOWN) { + initialX = e.x + initialY = e.y +- parent.requestDisallowInterceptTouchEvent(true) ++ if (orientation != null) { ++ parent.requestDisallowInterceptTouchEvent(true) ++ } + } else if (e.action == MotionEvent.ACTION_MOVE) { + val dx = e.x - initialX + val dy = e.y - initialY +@@ -78,6 +77,10 @@ class NestedScrollableHost : FrameLayout { + val scaledDy = dy.absoluteValue * if (isVpHorizontal) 1f else .5f + + if (scaledDx > touchSlop || scaledDy > touchSlop) { ++ NativeGestureUtil.notifyNativeGestureStarted(this, e) ++ nativeGestureStarted = true ++ ++ if (orientation == null) return + if (isVpHorizontal == (scaledDy > scaledDx)) { + // Gesture is perpendicular, allow all parents to intercept + parent.requestDisallowInterceptTouchEvent(false) +@@ -94,4 +97,14 @@ class NestedScrollableHost : FrameLayout { + } + } + } ++ ++ override fun onTouchEvent(e: MotionEvent): Boolean { ++ if (e.actionMasked == MotionEvent.ACTION_UP) { ++ if (nativeGestureStarted) { ++ NativeGestureUtil.notifyNativeGestureEnded(this, e) ++ nativeGestureStarted = false ++ } ++ } ++ return super.onTouchEvent(e) ++ } + } |