Skip to content

Implement base for a native detector component#3599

Merged
j-piasecki merged 45 commits into
nextfrom
@jpiasecki/native-detector
Jul 11, 2025
Merged

Implement base for a native detector component#3599
j-piasecki merged 45 commits into
nextfrom
@jpiasecki/native-detector

Conversation

@j-piasecki
Copy link
Copy Markdown
Member

@j-piasecki j-piasecki commented Jul 4, 2025

Description

Implements a native RNGestureHandlerDetector component based on display: contents:

  • The view will match the layout of its child
  • The lifecycle of gestures is moved to hooks instead of being managed by the detector
  • Detector should attach and detach native gesture handlers to itself as it's mounted or unmounted
  • Implements sending native events to the detector component
  • It's able to work with RN's Animated events

TODO:

  • Validate that gestures are correctly attached/detached in all cases (suspense, display: none, navigation)
  • Validate that the gesture lifecycle is correctly managed in StrictMode
  • Correctly handle NativeViewGestureHandler, which should be attached to the child (I think)
  • Correctly handle the Text component
  • Integration with Reanimated

Test plan

Updated basic example

Copy link
Copy Markdown
Member

@WoLewicki WoLewicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments

Comment thread packages/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm Outdated
Comment thread packages/react-native-gesture-handler/apple/RNGestureHandlerModule.mm Outdated
Comment thread packages/react-native-gesture-handler/src/NativeDetector.tsx
j-piasecki added 29 commits July 7, 2025 11:44
Update ios

Renames:
- `setGestureState` -> `setGestureState_DEPRECATED` (JSI injected name stays the same for compatibility)
- `_setGestureStateNew` -> `_setGestureStateModern`

Decorate UI runtime lazily

Extract runtime decoration to shared code

Prefix with underscore

Expose `_setGestureStateAsync` to JS runtime

Format c++

Fix header

Don't try to decorate UI runtime without Reanimated and throw on failure

iOS changes after review

Changes to shared

Continuously check whether ui runtime was decorated

Make `createGestureHandler` synchronous and run on the JS thread

Bump Reanimated

Use Reanimated 4 beta

Extract runtime decoration to shared code

Bump reanimated to beta 5
@j-piasecki j-piasecki force-pushed the @jpiasecki/native-detector branch from e3164c4 to 7e73369 Compare July 7, 2025 09:48
Comment thread apps/basic-example/src/App.tsx Outdated
Comment thread packages/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm Outdated
Comment thread packages/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm Outdated
Comment thread packages/react-native-gesture-handler/apple/RNGestureHandlerEvents.mm Outdated
Comment thread packages/react-native-gesture-handler/src/specs/NativeRNGestureHandlerModule.ts Outdated
@j-piasecki j-piasecki marked this pull request as ready for review July 9, 2025 14:06
Comment thread apps/basic-example/src/App.tsx Outdated
private var animatedEvents: Boolean = false

fun setHandlerTags(handlerTags: ReadableArray?) {
val newHandlers = handlerTags?.toArrayList()?.map { (it as Double).toInt() } ?: emptyList()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that we cannot make it Int in other way?

(it as Double).toInt()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could cast the entire ArrayList, but I don't think it's much better.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think it changes that much 😅

Comment thread packages/react-native-gesture-handler/apple/RNGestureHandler.mm Outdated
Comment thread packages/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm Outdated
Copy link
Copy Markdown
Collaborator

@m-bert m-bert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this bad boy 🚀 :shipit:

This PR got pretty big and given that it targets next I think we can merge it and then continue with development 😅

@j-piasecki j-piasecki merged commit fa6a818 into next Jul 11, 2025
7 of 8 checks passed
@j-piasecki j-piasecki deleted the @jpiasecki/native-detector branch July 11, 2025 10:37
)

target_include_directories(react_codegen_rngesturehandler_codegen PUBLIC ../shared/shadowNodes)
target_include_directories(react_codegen_rngesturehandler_codegen PUBLIC ./build/generated/source/codegen/jni)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you link codegen files explicitly?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay, you use them in your shared folder, got it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants