feat: make svgView getter public (#2583)

<!-- 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](https://github.com/software-mansion/react-native-gesture-handler/pull/3242/).

## Test Plan

Run the example from the RNGH - RNSVG [integration
PR](https://github.com/software-mansion/react-native-gesture-handler/pull/3242/).

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| Android |          |
This commit is contained in:
Ignacy Łątka
2025-01-15 11:27:35 +01:00
committed by GitHub
parent 9ed8eb1587
commit 3bf4298ae0
6 changed files with 6 additions and 6 deletions

View File

@@ -40,7 +40,7 @@ class ClipPathView extends GroupView {
}
@Override
public int hitTest(float[] src) {
int hitTest(float[] src) {
return -1;
}

View File

@@ -254,7 +254,7 @@ class GroupView extends RenderableView {
}
@Override
public int hitTest(final float[] src) {
int hitTest(final float[] src) {
if (!mInvertible) {
return -1;
}

View File

@@ -676,7 +676,7 @@ public abstract class RenderableView extends VirtualView implements ReactHitSlop
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;
}

View File

@@ -1208,7 +1208,7 @@ class TSpanView extends TextView {
}
@Override
public int hitTest(final float[] src) {
int hitTest(final float[] src) {
if (mContent == null) {
return super.hitTest(src);
}

View File

@@ -100,7 +100,7 @@ class UseView extends RenderableView {
}
@Override
public int hitTest(float[] src) {
int hitTest(float[] src) {
if (!mInvertible) {
return -1;
}

View File

@@ -393,7 +393,7 @@ public abstract class VirtualView extends ReactViewGroup {
abstract Path getPath(Canvas canvas, Paint paint);
@Nullable
SvgView getSvgView() {
public SvgView getSvgView() {
if (svgView != null) {
return svgView;
}