Skip to content

Commit

Permalink
feat: make svgView getter public (#2583)
Browse files Browse the repository at this point in the history
<!-- 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 |    ✅      |
  • Loading branch information
latekvo authored Jan 15, 2025
1 parent 9ed8eb1 commit 3bf4298
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 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
public int hitTest(float[] src) {
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
public int hitTest(final float[] src) {
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
public int hitTest(final float[] src) {
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
public int hitTest(final float[] src) {
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
public int hitTest(float[] src) {
int hitTest(float[] src) {
if (!mInvertible) {
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/horcrux/svg/VirtualView.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ boolean isResponsible() {
abstract Path getPath(Canvas canvas, Paint paint);

@Nullable
SvgView getSvgView() {
public SvgView getSvgView() {
if (svgView != null) {
return svgView;
}
Expand Down

0 comments on commit 3bf4298

Please sign in to comment.