Skip to content

Commit

Permalink
feat: make RenderableView.hitTest public to create a cross-library …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
latekvo authored Nov 28, 2024
1 parent 2dcc832 commit 01db444
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion android/src/main/java/com/horcrux/svg/ClipPathView.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ boolean isResponsible() {
}

@Override
int hitTest(float[] src) {
public int hitTest(float[] src) {
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/horcrux/svg/GroupView.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ Path getPath(final Canvas canvas, final Paint paint, final Region.Op op) {
}

@Override
int hitTest(final float[] src) {
public int hitTest(final float[] src) {
if (!mInvertible) {
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/horcrux/svg/RenderableView.java
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ private void setupPaint(Paint paint, float opacity, ReadableArray colors) {
abstract Path getPath(Canvas canvas, Paint paint);

@Override
int hitTest(final float[] src) {
public int hitTest(final float[] src) {
if (mPath == null || !mInvertible) {
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/horcrux/svg/TSpanView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ private void setupTextPath() {
}

@Override
int hitTest(final float[] src) {
public int hitTest(final float[] src) {
if (mContent == null) {
return super.hitTest(src);
}
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/horcrux/svg/UseView.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void draw(Canvas canvas, Paint paint, float opacity) {
}

@Override
int hitTest(float[] src) {
public int hitTest(float[] src) {
if (!mInvertible) {
return -1;
}
Expand Down

0 comments on commit 01db444

Please sign in to comment.