react-native-swipeable-actions 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -235,12 +235,20 @@ class SwipeableView(context: Context, appContext: AppContext) : ExpoView(context
235
235
  // Auto-close runnable for tracking and cancellation
236
236
  private var autoCloseRunnable: Runnable? = null
237
237
 
238
+ // Track when a child (e.g. RNGH gesture handler) claims the touch
239
+ private var childRequestedDisallowIntercept: Boolean = false
240
+
238
241
  init {
239
242
  clipChildren = false
240
243
  clipToPadding = false
241
244
  setWillNotDraw(false)
242
245
  }
243
246
 
247
+ override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {
248
+ childRequestedDisallowIntercept = disallowIntercept
249
+ super.requestDisallowInterceptTouchEvent(disallowIntercept)
250
+ }
251
+
244
252
  override fun setClipChildren(clipChildren: Boolean) {
245
253
  super.setClipChildren(false)
246
254
  }
@@ -350,6 +358,7 @@ class SwipeableView(context: Context, appContext: AppContext) : ExpoView(context
350
358
  dispatchTouchStartX = event.rawX
351
359
  dispatchTouchStartY = event.rawY
352
360
  isBlockingChildEvents = false
361
+ childRequestedDisallowIntercept = false
353
362
 
354
363
  // Initialize tracking
355
364
  touchStartX = event.rawX
@@ -379,6 +388,11 @@ class SwipeableView(context: Context, appContext: AppContext) : ExpoView(context
379
388
 
380
389
  // Detect horizontal swipe
381
390
  if (dx > touchSlop && dx > dy) {
391
+ // If a child gesture handler (e.g. RNGH) claimed the touch, yield to it
392
+ if (childRequestedDisallowIntercept) {
393
+ return super.dispatchTouchEvent(event)
394
+ }
395
+
382
396
  val horizontalDelta = event.rawX - dispatchTouchStartX
383
397
  val isCorrectDirection = if (isOpen) {
384
398
  true
@@ -31,6 +31,19 @@ public class SwipeableView: ExpoView {
31
31
  return typeName.contains("SurfaceTouchHandler") || typeName.contains("RCTTouchHandler")
32
32
  }
33
33
 
34
+ /// Walk from a hit-tested view up to (but not including) self, checking for gesture recognizers.
35
+ /// Any child view with a gesture recognizer (RNGH, custom, etc.) takes priority over our pan.
36
+ private func hasChildGesture(from view: UIView) -> Bool {
37
+ var current: UIView? = view
38
+ while let v = current, v !== self {
39
+ if !(v.gestureRecognizers ?? []).isEmpty {
40
+ return true
41
+ }
42
+ current = v.superview
43
+ }
44
+ return false
45
+ }
46
+
34
47
  // MARK: - Thread-Safe Static Registry
35
48
 
36
49
  private static let registryQueue = DispatchQueue(label: "com.swipeable.registry", qos: .userInteractive)
@@ -862,6 +875,13 @@ extension SwipeableView: UIGestureRecognizerDelegate {
862
875
  let shouldBegin = isOpen || (isLeading ? velocity.x > 0 : velocity.x < 0)
863
876
 
864
877
  if shouldBegin {
878
+ // Prevent our pan from starting when the touch is on a child view that has
879
+ // its own gesture recognizers (e.g. RNGH). Delegate-based conflict resolution
880
+ // doesn't work with RNGH (it overrides delegates), so we yield via hit-test.
881
+ let touchPoint = pan.location(in: self)
882
+ if let hitView = super.hitTest(touchPoint, with: nil), hasChildGesture(from: hitView) {
883
+ return false
884
+ }
865
885
  cancelFabricTouches()
866
886
  }
867
887
 
@@ -892,11 +912,4 @@ extension SwipeableView: UIGestureRecognizerDelegate {
892
912
 
893
913
  return false
894
914
  }
895
-
896
- public func gestureRecognizer(
897
- _ gestureRecognizer: UIGestureRecognizer,
898
- shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer
899
- ) -> Bool {
900
- false
901
- }
902
915
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-swipeable-actions",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "High-performance native swipeable row component for React Native using Expo Modules",
5
5
  "main": "src/index.ts",
6
6
  "types": "build/index.d.ts",