Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add react-native-svg interface #3242

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open

Conversation

latekvo
Copy link
Contributor

@latekvo latekvo commented Nov 27, 2024

Description

This PR adds integration with the react-native-svg (RNSVG) to improve hitbox detection of the SVG elements they provide.

blocked by software-mansion/react-native-svg#2583
blocked by nested SvgViews with viewBox prop have invalid hit detection - No issue opened yet

Test plan

  • use the newly added SVG integration example for testing this feature

@latekvo latekvo changed the title Integrate with react-native-svg for improved hit detection of svg elements Add interaction with react-native-svg to improve hit-boxes of svg elements Nov 27, 2024
@latekvo latekvo changed the title Add interaction with react-native-svg to improve hit-boxes of svg elements Add react-native-svg interface Nov 27, 2024
@latekvo
Copy link
Contributor Author

latekvo commented Nov 28, 2024

Integration works as of bd51ac7, but I have to test it a bit more before it's ready.

jakex7 pushed a commit to software-mansion/react-native-svg that referenced this pull request Nov 28, 2024
…interface (#2555)

<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect -->

# Summary

Adding an `RNGH <-> RNSVG` interface requires usage of
`RenderableView.hitTest` to work.
([link](software-mansion/react-native-gesture-handler#3242))
Currently, `RenderableView.hitTest` is `package-private`, meaning it
cannot be accessed by other packages.
This change does not change any functionality of the library, it only
exposes existing functions to other libraries.

I only made public those `hitTest` implementation which are strictly
necessary for this interface, this is why multiple, if not most
`hitTest` implementations remain `package-private` despite the changes
made in the PR.

## Test Plan

- open the example app, see how the app builds successfully

### What's required for testing (prerequisites)?

- `RNSVG`'s `paper-example` app

### What are the steps to reproduce (after prerequisites)?

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ❌      |
| MacOS   |    ❌      |
| Android |    ✅      |
| Web     |    ❌      |

## Checklist

<!-- Check completed item, when applicable, via: [X] -->

- [X] I have tested this on a device and a simulator
- [ ] I added documentation in `README.md`
- [ ] ~~I updated the typed files (typescript)~~
- [ ] I added a test for the API in the `__tests__` folder
@latekvo latekvo changed the base branch from main to next December 5, 2024 15:17
@latekvo latekvo changed the base branch from next to main December 18, 2024 14:31
@latekvo latekvo requested review from m-bert and jakex7 January 8, 2025 13:53
@latekvo latekvo marked this pull request as ready for review January 8, 2025 13:53
@latekvo
Copy link
Contributor Author

latekvo commented Jan 8, 2025

// Using the latest version for now, todo: find the oldest working version

Will remove this comment, and replace the minimal version check with the latest version, as soon as this PR is released.

@latekvo latekvo requested a review from j-piasecki January 8, 2025 14:06
Copy link
Contributor

@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.

Overall looks ok, left some comments

jakex7 pushed a commit to software-mansion/react-native-svg that referenced this pull request Jan 15, 2025
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect -->

# Summary

This PR reverts #2555, as `RenderableView.hitTest()` can be replaced by
`SvgView.reactTagForTouch()`, which is already `public`.

This PR also changes the `package-private` `getSvgView()` method of
`VirtualView` to `public`.
This change has been made to handle hit detection of transformed
`VirtualView`s, as `RenderableView`'s `hitTest()` doesn't take
transformations into account, while `SvgView`'s `reactTagForTouch()`
does.

Making `getSvgView()` public is necessary for integrating RNSVG support
into RNGH. More details
[here](software-mansion/react-native-gesture-handler#3242).

## Test Plan

Run the example from the RNGH - RNSVG [integration
PR](software-mansion/react-native-gesture-handler#3242).

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| Android |    ✅      |
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.

4 participants