Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -6025,6 +6025,7 @@ public abstract interface class com/facebook/react/views/scroll/VirtualView {
public final class com/facebook/react/views/swiperefresh/ReactSwipeRefreshLayout : androidx/swiperefreshlayout/widget/SwipeRefreshLayout {
public fun <init> (Lcom/facebook/react/bridge/ReactContext;)V
public fun canChildScrollUp ()Z
public fun dispatchGenericMotionEvent (Landroid/view/MotionEvent;)Z
public fun onInterceptTouchEvent (Landroid/view/MotionEvent;)Z
public fun onLayout (ZIIII)V
public fun onTouchEvent (Landroid/view/MotionEvent;)Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ import com.facebook.react.uimanager.PixelUtil
import com.facebook.react.uimanager.events.NativeGestureUtil
import kotlin.math.abs

/** Basic extension of [SwipeRefreshLayout] with ReactNative-specific functionality. */
/**
* Basic extension of [SwipeRefreshLayout] with ReactNative-specific functionality.
*
* This component wraps a scrollable child (typically a ScrollView or RecyclerView) and provides
* pull-to-refresh functionality. It handles touch event interception for the refresh gesture while
* properly forwarding other events to its children.
*/
public class ReactSwipeRefreshLayout(reactContext: ReactContext) :
SwipeRefreshLayout(reactContext) {

Expand Down Expand Up @@ -127,6 +133,28 @@ public class ReactSwipeRefreshLayout(reactContext: ReactContext) :
return true
}

/**
* Dispatches generic motion events to children.
*
* This override ensures that [MotionEvent.ACTION_SCROLL] events (from joystick, scrollwheel, or
* other pointing devices) are properly forwarded to child views.
*/
public override fun dispatchGenericMotionEvent(ev: MotionEvent): Boolean {
// For ACTION_SCROLL events, dispatch to child for handling
// The child ScrollView will use nested scrolling APIs to communicate with this
// SwipeRefreshLayout
if (ev.actionMasked == MotionEvent.ACTION_SCROLL) {
val child = getChildAt(0)
if (child != null) {
val handled = child.dispatchGenericMotionEvent(ev)
if (handled) {
return true
}
}
}
return super.dispatchGenericMotionEvent(ev)
}

private companion object {
private const val DEFAULT_CIRCLE_TARGET = 64f
}
Expand Down
Loading