mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-06 00:12:21 +00:00
Rename java file names
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGPath view
|
||||
*/
|
||||
public class RNSVGCircleShadowNode extends RNSVGPathShadowNode {
|
||||
public class CircleShadowNode extends PathShadowNode {
|
||||
|
||||
private String mCx;
|
||||
private String mCy;
|
||||
+3
-3
@@ -21,7 +21,7 @@ import com.facebook.react.common.ReactConstants;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGClipPath view
|
||||
*/
|
||||
public class RNSVGClipPathShadowNode extends RNSVGGroupShadowNode {
|
||||
public class ClipPathShadowNode extends GroupShadowNode {
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas, Paint paint, float opacity) {
|
||||
@@ -44,10 +44,10 @@ public class RNSVGClipPathShadowNode extends RNSVGGroupShadowNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeProperties(RNSVGVirtualNode target, ReadableArray mergeList, boolean inherited) {}
|
||||
public void mergeProperties(VirtualNode target, ReadableArray mergeList, boolean inherited) {}
|
||||
|
||||
@Override
|
||||
public void mergeProperties(RNSVGVirtualNode target, ReadableArray mergeList) {}
|
||||
public void mergeProperties(VirtualNode target, ReadableArray mergeList) {}
|
||||
|
||||
@Override
|
||||
public void resetProperties() {}
|
||||
+3
-3
@@ -20,7 +20,7 @@ import com.facebook.react.bridge.ReadableArray;
|
||||
/**
|
||||
* Shadow node for virtual Definition type views
|
||||
*/
|
||||
public class RNSVGDefinitionShadowNode extends RNSVGVirtualNode {
|
||||
public class DefinitionShadowNode extends VirtualNode {
|
||||
|
||||
public void draw(Canvas canvas, Paint paint, float opacity) {}
|
||||
|
||||
@@ -40,10 +40,10 @@ public class RNSVGDefinitionShadowNode extends RNSVGVirtualNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeProperties(RNSVGVirtualNode target, ReadableArray mergeList, boolean inherited) {}
|
||||
public void mergeProperties(VirtualNode target, ReadableArray mergeList, boolean inherited) {}
|
||||
|
||||
@Override
|
||||
public void mergeProperties(RNSVGVirtualNode target, ReadableArray mergeList) {}
|
||||
public void mergeProperties(VirtualNode target, ReadableArray mergeList) {}
|
||||
|
||||
@Override
|
||||
public void resetProperties() {}
|
||||
+3
-3
@@ -15,18 +15,18 @@ import android.graphics.Paint;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGPath view
|
||||
*/
|
||||
public class RNSVGDefsShadowNode extends RNSVGDefinitionShadowNode {
|
||||
public class DefsShadowNode extends DefinitionShadowNode {
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas, Paint paint, float opacity) {
|
||||
traverseChildren(new NodeRunnable() {
|
||||
public boolean run(RNSVGVirtualNode node) {
|
||||
public boolean run(VirtualNode node) {
|
||||
node.saveDefinition();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
NodeRunnable markUpdateSeenRecursive = new NodeRunnable() {
|
||||
public boolean run(RNSVGVirtualNode node) {
|
||||
public boolean run(VirtualNode node) {
|
||||
node.markUpdateSeen();
|
||||
node.traverseChildren(this);
|
||||
return true;
|
||||
+1
-1
@@ -19,7 +19,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGPath view
|
||||
*/
|
||||
public class RNSVGEllipseShadowNode extends RNSVGPathShadowNode {
|
||||
public class EllipseShadowNode extends PathShadowNode {
|
||||
|
||||
private String mCx;
|
||||
private String mCy;
|
||||
+11
-11
@@ -24,18 +24,18 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGGroup view
|
||||
*/
|
||||
public class RNSVGGroupShadowNode extends RNSVGPathShadowNode {
|
||||
public class GroupShadowNode extends PathShadowNode {
|
||||
|
||||
public void draw(final Canvas canvas, final Paint paint, final float opacity) {
|
||||
final RNSVGSvgViewShadowNode svg = getSvgShadowNode();
|
||||
final RNSVGVirtualNode self = this;
|
||||
final SvgViewShadowNode svg = getSvgShadowNode();
|
||||
final VirtualNode self = this;
|
||||
|
||||
if (opacity > MIN_OPACITY_FOR_DRAW) {
|
||||
int count = saveAndSetupCanvas(canvas);
|
||||
clip(canvas, paint);
|
||||
|
||||
traverseChildren(new NodeRunnable() {
|
||||
public boolean run(RNSVGVirtualNode node) {
|
||||
public boolean run(VirtualNode node) {
|
||||
node.setupDimensions(canvas);
|
||||
|
||||
node.mergeProperties(self, mOwnedPropList, true);
|
||||
@@ -58,7 +58,7 @@ public class RNSVGGroupShadowNode extends RNSVGPathShadowNode {
|
||||
final Path path = new Path();
|
||||
|
||||
traverseChildren(new NodeRunnable() {
|
||||
public boolean run(RNSVGVirtualNode node) {
|
||||
public boolean run(VirtualNode node) {
|
||||
node.setupDimensions(canvas);
|
||||
path.addPath(node.getPath(canvas, paint));
|
||||
return true;
|
||||
@@ -80,11 +80,11 @@ public class RNSVGGroupShadowNode extends RNSVGPathShadowNode {
|
||||
|
||||
for (int i = getChildCount() - 1; i >= 0; i--) {
|
||||
ReactShadowNode child = getChildAt(i);
|
||||
if (!(child instanceof RNSVGVirtualNode)) {
|
||||
if (!(child instanceof VirtualNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RNSVGVirtualNode node = (RNSVGVirtualNode) child;
|
||||
VirtualNode node = (VirtualNode) child;
|
||||
|
||||
int viewTag = node.hitTest(point, combinedMatrix);
|
||||
if (viewTag != -1) {
|
||||
@@ -101,7 +101,7 @@ public class RNSVGGroupShadowNode extends RNSVGPathShadowNode {
|
||||
}
|
||||
|
||||
traverseChildren(new NodeRunnable() {
|
||||
public boolean run(RNSVGVirtualNode node) {
|
||||
public boolean run(VirtualNode node) {
|
||||
node.saveDefinition();
|
||||
return true;
|
||||
}
|
||||
@@ -109,9 +109,9 @@ public class RNSVGGroupShadowNode extends RNSVGPathShadowNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeProperties(final RNSVGVirtualNode target, final ReadableArray mergeList) {
|
||||
public void mergeProperties(final VirtualNode target, final ReadableArray mergeList) {
|
||||
traverseChildren(new NodeRunnable() {
|
||||
public boolean run(RNSVGVirtualNode node) {
|
||||
public boolean run(VirtualNode node) {
|
||||
node.mergeProperties(target, mergeList);
|
||||
return true;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class RNSVGGroupShadowNode extends RNSVGPathShadowNode {
|
||||
@Override
|
||||
public void resetProperties() {
|
||||
traverseChildren(new NodeRunnable() {
|
||||
public boolean run(RNSVGVirtualNode node) {
|
||||
public boolean run(VirtualNode node) {
|
||||
node.resetProperties();
|
||||
return true;
|
||||
}
|
||||
+2
-2
@@ -41,7 +41,7 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGPath view
|
||||
*/
|
||||
public class RNSVGImageShadowNode extends RNSVGPathShadowNode {
|
||||
public class ImageShadowNode extends PathShadowNode {
|
||||
|
||||
private String mX;
|
||||
private String mY;
|
||||
@@ -178,7 +178,7 @@ public class RNSVGImageShadowNode extends RNSVGPathShadowNode {
|
||||
renderRect = new RectF(0, 0, (int)rectWidth, (int)(rectWidth / mImageRatio));
|
||||
}
|
||||
|
||||
RNSVGViewBoxShadowNode viewBox = new RNSVGViewBoxShadowNode();
|
||||
ViewBoxShadowNode viewBox = new ViewBoxShadowNode();
|
||||
viewBox.setMinX("0");
|
||||
viewBox.setMinY("0");
|
||||
viewBox.setVbWidth(renderRect.width() / mScale + "");
|
||||
+1
-1
@@ -17,7 +17,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGPath view
|
||||
*/
|
||||
public class RNSVGLineShadowNode extends RNSVGPathShadowNode {
|
||||
public class LineShadowNode extends PathShadowNode {
|
||||
|
||||
private String mX1;
|
||||
private String mY1;
|
||||
+1
-1
@@ -17,7 +17,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
/**
|
||||
* Shadow node for virtual LinearGradient definition view
|
||||
*/
|
||||
public class RNSVGLinearGradientShadowNode extends RNSVGDefinitionShadowNode {
|
||||
public class LinearGradientShadowNode extends DefinitionShadowNode {
|
||||
|
||||
private String mX1;
|
||||
private String mY1;
|
||||
+3
-3
@@ -38,7 +38,7 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGPath view
|
||||
*/
|
||||
public class RNSVGPathShadowNode extends RNSVGVirtualNode {
|
||||
public class PathShadowNode extends VirtualNode {
|
||||
|
||||
private static final int CAP_BUTT = 0;
|
||||
private static final int CAP_ROUND = 1;
|
||||
@@ -389,7 +389,7 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeProperties(RNSVGVirtualNode target, ReadableArray mergeList, boolean inherited) {
|
||||
public void mergeProperties(VirtualNode target, ReadableArray mergeList, boolean inherited) {
|
||||
if (mergeList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -428,7 +428,7 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeProperties(RNSVGVirtualNode target, ReadableArray mergeList) {
|
||||
public void mergeProperties(VirtualNode target, ReadableArray mergeList) {
|
||||
mergeProperties(target, mergeList, false);
|
||||
}
|
||||
|
||||
@@ -1,189 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Horcrux.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT-style license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
|
||||
package com.horcrux.svg;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.facebook.react.uimanager.LayoutShadowNode;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
|
||||
/**
|
||||
* ViewManager for all shadowed RNSVG views: Group, Path and Text. Since these never get rendered
|
||||
* into native views and don't need any logic (all the logic is in {@link RNSVGSvgView}), this
|
||||
* "stubbed" ViewManager is used for all of them.
|
||||
*/
|
||||
public class RNSVGRenderableViewManager extends ViewManager<View, LayoutShadowNode> {
|
||||
|
||||
/* package */ static final String CLASS_GROUP = "RNSVGGroup";
|
||||
/* package */ static final String CLASS_PATH = "RNSVGPath";
|
||||
/* package */ static final String CLASS_TEXT = "RNSVGText";
|
||||
/* package */ static final String CLASS_IMAGE = "RNSVGImage";
|
||||
/* package */ static final String CLASS_CIRCLE = "RNSVGCircle";
|
||||
/* package */ static final String CLASS_ELLIPSE = "RNSVGEllipse";
|
||||
/* package */ static final String CLASS_LINE = "RNSVGLine";
|
||||
/* package */ static final String CLASS_RECT = "RNSVGRect";
|
||||
/* package */ static final String CLASS_CLIP_PATH = "RNSVGClipPath";
|
||||
/* package */ static final String CLASS_DEFS = "RNSVGDefs";
|
||||
/* package */ static final String CLASS_USE = "RNSVGUse";
|
||||
/* package */ static final String CLASS_VIEW_BOX = "RNSVGViewBox";
|
||||
/* package */ static final String CLASS_LINEAR_GRADIENT = "RNSVGLinearGradient";
|
||||
/* package */ static final String CLASS_RADIAL_GRADIENT = "RNSVGRadialGradient";
|
||||
|
||||
private final String mClassName;
|
||||
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGGroupViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_GROUP);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGPathViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_PATH);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGTextViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_TEXT);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGImageViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_IMAGE);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGCircleViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_CIRCLE);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGEllipseViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_ELLIPSE);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGLineViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_LINE);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGRectViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_RECT);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGClipPathViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_CLIP_PATH);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGDefsViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_DEFS);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGUseViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_USE);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGViewBoxViewManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_VIEW_BOX);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGLinearGradientManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_LINEAR_GRADIENT);
|
||||
}
|
||||
|
||||
public static RNSVGRenderableViewManager createRNSVGRadialGradientManager() {
|
||||
return new RNSVGRenderableViewManager(CLASS_RADIAL_GRADIENT);
|
||||
}
|
||||
|
||||
private RNSVGRenderableViewManager(String className) {
|
||||
mClassName = className;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return mClassName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LayoutShadowNode createShadowNodeInstance() {
|
||||
switch (mClassName) {
|
||||
case CLASS_GROUP:
|
||||
return new RNSVGGroupShadowNode();
|
||||
case CLASS_PATH:
|
||||
return new RNSVGPathShadowNode();
|
||||
case CLASS_CIRCLE:
|
||||
return new RNSVGCircleShadowNode();
|
||||
case CLASS_ELLIPSE:
|
||||
return new RNSVGEllipseShadowNode();
|
||||
case CLASS_LINE:
|
||||
return new RNSVGLineShadowNode();
|
||||
case CLASS_RECT:
|
||||
return new RNSVGRectShadowNode();
|
||||
case CLASS_TEXT:
|
||||
return new RNSVGTextShadowNode();
|
||||
case CLASS_IMAGE:
|
||||
return new RNSVGImageShadowNode();
|
||||
case CLASS_CLIP_PATH:
|
||||
return new RNSVGClipPathShadowNode();
|
||||
case CLASS_DEFS:
|
||||
return new RNSVGDefsShadowNode();
|
||||
case CLASS_USE:
|
||||
return new RNSVGUseShadowNode();
|
||||
case CLASS_VIEW_BOX:
|
||||
return new RNSVGViewBoxShadowNode();
|
||||
case CLASS_LINEAR_GRADIENT:
|
||||
return new RNSVGLinearGradientShadowNode();
|
||||
case CLASS_RADIAL_GRADIENT:
|
||||
return new RNSVGRadialGradientShadowNode();
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected type " + mClassName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends LayoutShadowNode> getShadowNodeClass() {
|
||||
switch (mClassName) {
|
||||
case CLASS_GROUP:
|
||||
return RNSVGGroupShadowNode.class;
|
||||
case CLASS_PATH:
|
||||
return RNSVGPathShadowNode.class;
|
||||
case CLASS_CIRCLE:
|
||||
return RNSVGCircleShadowNode.class;
|
||||
case CLASS_ELLIPSE:
|
||||
return RNSVGEllipseShadowNode.class;
|
||||
case CLASS_LINE:
|
||||
return RNSVGLineShadowNode.class;
|
||||
case CLASS_RECT:
|
||||
return RNSVGRectShadowNode.class;
|
||||
case CLASS_TEXT:
|
||||
return RNSVGTextShadowNode.class;
|
||||
case CLASS_IMAGE:
|
||||
return RNSVGImageShadowNode.class;
|
||||
case CLASS_CLIP_PATH:
|
||||
return RNSVGClipPathShadowNode.class;
|
||||
case CLASS_DEFS:
|
||||
return RNSVGDefsShadowNode.class;
|
||||
case CLASS_USE:
|
||||
return RNSVGUseShadowNode.class;
|
||||
case CLASS_VIEW_BOX:
|
||||
return RNSVGViewBoxShadowNode.class;
|
||||
case CLASS_LINEAR_GRADIENT:
|
||||
return RNSVGLinearGradientShadowNode.class;
|
||||
case CLASS_RADIAL_GRADIENT:
|
||||
return RNSVGRadialGradientShadowNode.class;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected type " + mClassName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View createViewInstance(ThemedReactContext reactContext) {
|
||||
throw new IllegalStateException("SVG elements does not map into a native view");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExtraData(View root, Object extraData) {
|
||||
throw new IllegalStateException("SVG elements does not map into a native view");
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Horcrux.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT-style license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
|
||||
package com.horcrux.svg;
|
||||
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.bridge.JavaScriptModule;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class RNSvgPackage implements ReactPackage {
|
||||
|
||||
@Override
|
||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||
return Arrays.<ViewManager>asList(
|
||||
RNSVGRenderableViewManager.createRNSVGGroupViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGPathViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGCircleViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGEllipseViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGLineViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGRectViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGTextViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGImageViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGClipPathViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGDefsViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGUseViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGViewBoxViewManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGLinearGradientManager(),
|
||||
RNSVGRenderableViewManager.createRNSVGRadialGradientManager(),
|
||||
new RNSVGSvgViewManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
/**
|
||||
* Shadow node for virtual LinearGradient definition view
|
||||
*/
|
||||
public class RNSVGRadialGradientShadowNode extends RNSVGDefinitionShadowNode {
|
||||
public class RadialGradientShadowNode extends DefinitionShadowNode {
|
||||
private String mFx;
|
||||
private String mFy;
|
||||
private String mRx;
|
||||
+1
-1
@@ -18,7 +18,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGPath view
|
||||
*/
|
||||
public class RNSVGRectShadowNode extends RNSVGPathShadowNode {
|
||||
public class RectShadowNode extends PathShadowNode {
|
||||
|
||||
private String mX;
|
||||
private String mY;
|
||||
@@ -0,0 +1,189 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Horcrux.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT-style license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
|
||||
package com.horcrux.svg;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.facebook.react.uimanager.LayoutShadowNode;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
|
||||
/**
|
||||
* ViewManager for all shadowed RNSVG views: Group, Path and Text. Since these never get rendered
|
||||
* into native views and don't need any logic (all the logic is in {@link SvgView}), this
|
||||
* "stubbed" ViewManager is used for all of them.
|
||||
*/
|
||||
public class RenderableViewManager extends ViewManager<View, LayoutShadowNode> {
|
||||
|
||||
/* package */ static final String CLASS_GROUP = "RNSVGGroup";
|
||||
/* package */ static final String CLASS_PATH = "RNSVGPath";
|
||||
/* package */ static final String CLASS_TEXT = "RNSVGText";
|
||||
/* package */ static final String CLASS_IMAGE = "RNSVGImage";
|
||||
/* package */ static final String CLASS_CIRCLE = "RNSVGCircle";
|
||||
/* package */ static final String CLASS_ELLIPSE = "RNSVGEllipse";
|
||||
/* package */ static final String CLASS_LINE = "RNSVGLine";
|
||||
/* package */ static final String CLASS_RECT = "RNSVGRect";
|
||||
/* package */ static final String CLASS_CLIP_PATH = "RNSVGClipPath";
|
||||
/* package */ static final String CLASS_DEFS = "RNSVGDefs";
|
||||
/* package */ static final String CLASS_USE = "RNSVGUse";
|
||||
/* package */ static final String CLASS_VIEW_BOX = "RNSVGViewBox";
|
||||
/* package */ static final String CLASS_LINEAR_GRADIENT = "RNSVGLinearGradient";
|
||||
/* package */ static final String CLASS_RADIAL_GRADIENT = "RNSVGRadialGradient";
|
||||
|
||||
private final String mClassName;
|
||||
|
||||
|
||||
public static RenderableViewManager createRNSVGGroupViewManager() {
|
||||
return new RenderableViewManager(CLASS_GROUP);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGPathViewManager() {
|
||||
return new RenderableViewManager(CLASS_PATH);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGTextViewManager() {
|
||||
return new RenderableViewManager(CLASS_TEXT);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGImageViewManager() {
|
||||
return new RenderableViewManager(CLASS_IMAGE);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGCircleViewManager() {
|
||||
return new RenderableViewManager(CLASS_CIRCLE);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGEllipseViewManager() {
|
||||
return new RenderableViewManager(CLASS_ELLIPSE);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGLineViewManager() {
|
||||
return new RenderableViewManager(CLASS_LINE);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGRectViewManager() {
|
||||
return new RenderableViewManager(CLASS_RECT);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGClipPathViewManager() {
|
||||
return new RenderableViewManager(CLASS_CLIP_PATH);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGDefsViewManager() {
|
||||
return new RenderableViewManager(CLASS_DEFS);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGUseViewManager() {
|
||||
return new RenderableViewManager(CLASS_USE);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGViewBoxViewManager() {
|
||||
return new RenderableViewManager(CLASS_VIEW_BOX);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGLinearGradientManager() {
|
||||
return new RenderableViewManager(CLASS_LINEAR_GRADIENT);
|
||||
}
|
||||
|
||||
public static RenderableViewManager createRNSVGRadialGradientManager() {
|
||||
return new RenderableViewManager(CLASS_RADIAL_GRADIENT);
|
||||
}
|
||||
|
||||
private RenderableViewManager(String className) {
|
||||
mClassName = className;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return mClassName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LayoutShadowNode createShadowNodeInstance() {
|
||||
switch (mClassName) {
|
||||
case CLASS_GROUP:
|
||||
return new GroupShadowNode();
|
||||
case CLASS_PATH:
|
||||
return new PathShadowNode();
|
||||
case CLASS_CIRCLE:
|
||||
return new CircleShadowNode();
|
||||
case CLASS_ELLIPSE:
|
||||
return new EllipseShadowNode();
|
||||
case CLASS_LINE:
|
||||
return new LineShadowNode();
|
||||
case CLASS_RECT:
|
||||
return new RectShadowNode();
|
||||
case CLASS_TEXT:
|
||||
return new TextShadowNode();
|
||||
case CLASS_IMAGE:
|
||||
return new ImageShadowNode();
|
||||
case CLASS_CLIP_PATH:
|
||||
return new ClipPathShadowNode();
|
||||
case CLASS_DEFS:
|
||||
return new DefsShadowNode();
|
||||
case CLASS_USE:
|
||||
return new UseShadowNode();
|
||||
case CLASS_VIEW_BOX:
|
||||
return new ViewBoxShadowNode();
|
||||
case CLASS_LINEAR_GRADIENT:
|
||||
return new LinearGradientShadowNode();
|
||||
case CLASS_RADIAL_GRADIENT:
|
||||
return new RadialGradientShadowNode();
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected type " + mClassName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends LayoutShadowNode> getShadowNodeClass() {
|
||||
switch (mClassName) {
|
||||
case CLASS_GROUP:
|
||||
return GroupShadowNode.class;
|
||||
case CLASS_PATH:
|
||||
return PathShadowNode.class;
|
||||
case CLASS_CIRCLE:
|
||||
return CircleShadowNode.class;
|
||||
case CLASS_ELLIPSE:
|
||||
return EllipseShadowNode.class;
|
||||
case CLASS_LINE:
|
||||
return LineShadowNode.class;
|
||||
case CLASS_RECT:
|
||||
return RectShadowNode.class;
|
||||
case CLASS_TEXT:
|
||||
return TextShadowNode.class;
|
||||
case CLASS_IMAGE:
|
||||
return ImageShadowNode.class;
|
||||
case CLASS_CLIP_PATH:
|
||||
return ClipPathShadowNode.class;
|
||||
case CLASS_DEFS:
|
||||
return DefsShadowNode.class;
|
||||
case CLASS_USE:
|
||||
return UseShadowNode.class;
|
||||
case CLASS_VIEW_BOX:
|
||||
return ViewBoxShadowNode.class;
|
||||
case CLASS_LINEAR_GRADIENT:
|
||||
return LinearGradientShadowNode.class;
|
||||
case CLASS_RADIAL_GRADIENT:
|
||||
return RadialGradientShadowNode.class;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected type " + mClassName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View createViewInstance(ThemedReactContext reactContext) {
|
||||
throw new IllegalStateException("SVG elements does not map into a native view");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExtraData(View root, Object extraData) {
|
||||
throw new IllegalStateException("SVG elements does not map into a native view");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Horcrux.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT-style license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
|
||||
package com.horcrux.svg;
|
||||
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.bridge.JavaScriptModule;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class SvgPackage implements ReactPackage {
|
||||
|
||||
@Override
|
||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||
return Arrays.<ViewManager>asList(
|
||||
RenderableViewManager.createRNSVGGroupViewManager(),
|
||||
RenderableViewManager.createRNSVGPathViewManager(),
|
||||
RenderableViewManager.createRNSVGCircleViewManager(),
|
||||
RenderableViewManager.createRNSVGEllipseViewManager(),
|
||||
RenderableViewManager.createRNSVGLineViewManager(),
|
||||
RenderableViewManager.createRNSVGRectViewManager(),
|
||||
RenderableViewManager.createRNSVGTextViewManager(),
|
||||
RenderableViewManager.createRNSVGImageViewManager(),
|
||||
RenderableViewManager.createRNSVGClipPathViewManager(),
|
||||
RenderableViewManager.createRNSVGDefsViewManager(),
|
||||
RenderableViewManager.createRNSVGUseViewManager(),
|
||||
RenderableViewManager.createRNSVGViewBoxViewManager(),
|
||||
RenderableViewManager.createRNSVGLinearGradientManager(),
|
||||
RenderableViewManager.createRNSVGRadialGradientManager(),
|
||||
new SvgViewManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -32,7 +32,7 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* Custom {@link View} implementation that draws an RNSVGSvg React view and its \children.
|
||||
*/
|
||||
public class RNSVGSvgView extends View {
|
||||
public class SvgView extends View {
|
||||
public enum Events {
|
||||
EVENT_DATA_URL("onDataURL");
|
||||
|
||||
@@ -56,14 +56,14 @@ public class RNSVGSvgView extends View {
|
||||
private final TouchEventCoalescingKeyHelper mTouchEventCoalescingKeyHelper =
|
||||
new TouchEventCoalescingKeyHelper();
|
||||
|
||||
public RNSVGSvgView(ReactContext reactContext) {
|
||||
public SvgView(ReactContext reactContext) {
|
||||
super(reactContext);
|
||||
mEventEmitter = reactContext.getJSModule(RCTEventEmitter.class);
|
||||
mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
|
||||
}
|
||||
|
||||
private RNSVGSvgViewShadowNode getShadowNode() {
|
||||
return RNSVGSvgViewShadowNode.getShadowNodeByTag(getId());
|
||||
private SvgViewShadowNode getShadowNode() {
|
||||
return SvgViewShadowNode.getShadowNodeByTag(getId());
|
||||
}
|
||||
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
@@ -84,7 +84,7 @@ public class RNSVGSvgView extends View {
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
RNSVGSvgViewShadowNode svg = getShadowNode();
|
||||
SvgViewShadowNode svg = getShadowNode();
|
||||
if (svg != null) {
|
||||
mTargetTag = getShadowNode().hitTest(new Point((int) ev.getX(), (int) ev.getY()));
|
||||
|
||||
+11
-11
@@ -25,10 +25,10 @@ import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* ViewManager for RNSVGSvgView React views. Renders as a {@link RNSVGSvgView} and handles
|
||||
* ViewManager for RNSVGSvgView React views. Renders as a {@link SvgView} and handles
|
||||
* invalidating the native view on shadow view updates happening in the underlying tree.
|
||||
*/
|
||||
public class RNSVGSvgViewManager extends BaseViewManager<RNSVGSvgView, RNSVGSvgViewShadowNode> {
|
||||
public class SvgViewManager extends BaseViewManager<SvgView, SvgViewShadowNode> {
|
||||
|
||||
private static final String REACT_CLASS = "RNSVGSvgView";
|
||||
private static final int COMMAND_TO_DATA_URL = 100;
|
||||
@@ -50,24 +50,24 @@ public class RNSVGSvgViewManager extends BaseViewManager<RNSVGSvgView, RNSVGSvgV
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<RNSVGSvgViewShadowNode> getShadowNodeClass() {
|
||||
return RNSVGSvgViewShadowNode.class;
|
||||
public Class<SvgViewShadowNode> getShadowNodeClass() {
|
||||
return SvgViewShadowNode.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RNSVGSvgViewShadowNode createShadowNodeInstance() {
|
||||
RNSVGSvgViewShadowNode node = new RNSVGSvgViewShadowNode();
|
||||
public SvgViewShadowNode createShadowNodeInstance() {
|
||||
SvgViewShadowNode node = new SvgViewShadowNode();
|
||||
node.setMeasureFunction(MEASURE_FUNCTION);
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RNSVGSvgView createViewInstance(ThemedReactContext reactContext) {
|
||||
return new RNSVGSvgView(reactContext);
|
||||
protected SvgView createViewInstance(ThemedReactContext reactContext) {
|
||||
return new SvgView(reactContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExtraData(RNSVGSvgView root, Object extraData) {
|
||||
public void updateExtraData(SvgView root, Object extraData) {
|
||||
root.setBitmap((Bitmap) extraData);
|
||||
}
|
||||
|
||||
@@ -87,14 +87,14 @@ public class RNSVGSvgViewManager extends BaseViewManager<RNSVGSvgView, RNSVGSvgV
|
||||
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
||||
MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
|
||||
|
||||
for (RNSVGSvgView.Events event : RNSVGSvgView.Events.values()) {
|
||||
for (SvgView.Events event : SvgView.Events.values()) {
|
||||
builder.put(event.toString(), MapBuilder.of("registrationName", event.toString()));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveCommand(RNSVGSvgView root, int commandId, @Nullable ReadableArray args) {
|
||||
public void receiveCommand(SvgView root, int commandId, @Nullable ReadableArray args) {
|
||||
super.receiveCommand(root, commandId, args);
|
||||
|
||||
switch (commandId) {
|
||||
+13
-15
@@ -16,12 +16,10 @@ import android.graphics.Point;
|
||||
import android.util.Base64;
|
||||
import android.util.SparseArray;
|
||||
import android.graphics.Color;
|
||||
import android.view.Surface;
|
||||
import android.graphics.PorterDuff;
|
||||
import com.facebook.react.uimanager.LayoutShadowNode;
|
||||
import com.facebook.react.uimanager.UIViewOperationQueue;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -29,17 +27,17 @@ import java.util.Map;
|
||||
/**
|
||||
* Shadow node for RNSVG virtual tree root - RNSVGSvgView
|
||||
*/
|
||||
public class RNSVGSvgViewShadowNode extends LayoutShadowNode {
|
||||
public class SvgViewShadowNode extends LayoutShadowNode {
|
||||
|
||||
private static final SparseArray<RNSVGSvgViewShadowNode> mTagToShadowNode = new SparseArray<>();
|
||||
private static final SparseArray<SvgViewShadowNode> mTagToShadowNode = new SparseArray<>();
|
||||
|
||||
public static RNSVGSvgViewShadowNode getShadowNodeByTag(int tag) {
|
||||
public static SvgViewShadowNode getShadowNodeByTag(int tag) {
|
||||
return mTagToShadowNode.get(tag);
|
||||
}
|
||||
|
||||
private boolean mResponsible = false;
|
||||
private static final Map<String, RNSVGVirtualNode> mDefinedClipPaths = new HashMap<>();
|
||||
private static final Map<String, RNSVGVirtualNode> mDefinedTemplates = new HashMap<>();
|
||||
private static final Map<String, VirtualNode> mDefinedClipPaths = new HashMap<>();
|
||||
private static final Map<String, VirtualNode> mDefinedTemplates = new HashMap<>();
|
||||
private static final Map<String, PropHelper.RNSVGBrush> mDefinedBrushes = new HashMap<>();
|
||||
|
||||
@Override
|
||||
@@ -81,11 +79,11 @@ public class RNSVGSvgViewShadowNode extends LayoutShadowNode {
|
||||
Paint paint = new Paint();
|
||||
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
if (!(getChildAt(i) instanceof RNSVGVirtualNode)) {
|
||||
if (!(getChildAt(i) instanceof VirtualNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RNSVGVirtualNode child = (RNSVGVirtualNode) getChildAt(i);
|
||||
VirtualNode child = (VirtualNode) getChildAt(i);
|
||||
child.setupDimensions(canvas);
|
||||
child.saveDefinition();
|
||||
child.draw(canvas, paint, 1f);
|
||||
@@ -125,11 +123,11 @@ public class RNSVGSvgViewShadowNode extends LayoutShadowNode {
|
||||
int count = getChildCount();
|
||||
int viewTag = -1;
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
if (!(getChildAt(i) instanceof RNSVGVirtualNode)) {
|
||||
if (!(getChildAt(i) instanceof VirtualNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
viewTag = ((RNSVGVirtualNode) getChildAt(i)).hitTest(point);
|
||||
viewTag = ((VirtualNode) getChildAt(i)).hitTest(point);
|
||||
if (viewTag != -1) {
|
||||
break;
|
||||
}
|
||||
@@ -138,19 +136,19 @@ public class RNSVGSvgViewShadowNode extends LayoutShadowNode {
|
||||
return viewTag;
|
||||
}
|
||||
|
||||
public void defineClipPath(RNSVGVirtualNode clipPath, String clipPathRef) {
|
||||
public void defineClipPath(VirtualNode clipPath, String clipPathRef) {
|
||||
mDefinedClipPaths.put(clipPathRef, clipPath);
|
||||
}
|
||||
|
||||
public RNSVGVirtualNode getDefinedClipPath(String clipPathRef) {
|
||||
public VirtualNode getDefinedClipPath(String clipPathRef) {
|
||||
return mDefinedClipPaths.get(clipPathRef);
|
||||
}
|
||||
|
||||
public void defineTemplate(RNSVGVirtualNode template, String templateRef) {
|
||||
public void defineTemplate(VirtualNode template, String templateRef) {
|
||||
mDefinedTemplates.put(templateRef, template);
|
||||
}
|
||||
|
||||
public RNSVGVirtualNode getDefinedTemplate(String templateRef) {
|
||||
public VirtualNode getDefinedTemplate(String templateRef) {
|
||||
return mDefinedTemplates.get(templateRef);
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGText view
|
||||
*/
|
||||
public class RNSVGTextShadowNode extends RNSVGPathShadowNode {
|
||||
public class TextShadowNode extends PathShadowNode {
|
||||
|
||||
private static final String PROP_LINES = "lines";
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGPath view
|
||||
*/
|
||||
public class RNSVGUseShadowNode extends RNSVGPathShadowNode {
|
||||
public class UseShadowNode extends PathShadowNode {
|
||||
|
||||
private String mHref;
|
||||
private String mWidth;
|
||||
@@ -53,7 +53,7 @@ public class RNSVGUseShadowNode extends RNSVGPathShadowNode {
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas, Paint paint, float opacity) {
|
||||
RNSVGVirtualNode template = getSvgShadowNode().getDefinedTemplate(mHref);
|
||||
VirtualNode template = getSvgShadowNode().getDefinedTemplate(mHref);
|
||||
|
||||
if (template != null) {
|
||||
int count = saveAndSetupCanvas(canvas);
|
||||
+5
-5
@@ -19,7 +19,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
/**
|
||||
* Shadow node for virtual RNSVGPath view
|
||||
*/
|
||||
public class RNSVGViewBoxShadowNode extends RNSVGGroupShadowNode {
|
||||
public class ViewBoxShadowNode extends GroupShadowNode {
|
||||
|
||||
private static final int MOS_MEET = 0;
|
||||
private static final int MOS_SLICE = 1;
|
||||
@@ -174,11 +174,11 @@ public class RNSVGViewBoxShadowNode extends RNSVGGroupShadowNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeProperties(RNSVGVirtualNode target, ReadableArray mergeList) {
|
||||
if (target instanceof RNSVGUseShadowNode) {
|
||||
public void mergeProperties(VirtualNode target, ReadableArray mergeList) {
|
||||
if (target instanceof UseShadowNode) {
|
||||
mFromSymbol = true;
|
||||
mBoxWidth = ((RNSVGUseShadowNode)target).getWidth();
|
||||
mBoxHeight = ((RNSVGUseShadowNode)target).getHeight();
|
||||
mBoxWidth = ((UseShadowNode)target).getWidth();
|
||||
mBoxHeight = ((UseShadowNode)target).getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -26,7 +26,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class RNSVGVirtualNode extends LayoutShadowNode {
|
||||
public abstract class VirtualNode extends LayoutShadowNode {
|
||||
|
||||
protected static final float MIN_OPACITY_FOR_DRAW = 0.01f;
|
||||
|
||||
@@ -58,9 +58,9 @@ public abstract class RNSVGVirtualNode extends LayoutShadowNode {
|
||||
protected int mCanvasHeight;
|
||||
protected String mName;
|
||||
|
||||
private RNSVGSvgViewShadowNode mSvgShadowNode;
|
||||
private SvgViewShadowNode mSvgShadowNode;
|
||||
|
||||
public RNSVGVirtualNode() {
|
||||
public VirtualNode() {
|
||||
mScale = DisplayMetricsHolder.getScreenDisplayMetrics().density;
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public abstract class RNSVGVirtualNode extends LayoutShadowNode {
|
||||
protected @Nullable Path getClipPath(Canvas canvas, Paint paint) {
|
||||
Path clip = mClipPath;
|
||||
if (clip == null && mClipPathRef != null) {
|
||||
RNSVGVirtualNode node = getSvgShadowNode().getDefinedClipPath(mClipPathRef);
|
||||
VirtualNode node = getSvgShadowNode().getDefinedClipPath(mClipPathRef);
|
||||
clip = node.getPath(canvas, paint);
|
||||
}
|
||||
|
||||
@@ -255,21 +255,21 @@ public abstract class RNSVGVirtualNode extends LayoutShadowNode {
|
||||
|
||||
abstract protected Path getPath(Canvas canvas, Paint paint);
|
||||
|
||||
protected RNSVGSvgViewShadowNode getSvgShadowNode() {
|
||||
protected SvgViewShadowNode getSvgShadowNode() {
|
||||
if (mSvgShadowNode != null) {
|
||||
return mSvgShadowNode;
|
||||
}
|
||||
|
||||
ReactShadowNode parent = getParent();
|
||||
|
||||
while (!(parent instanceof RNSVGSvgViewShadowNode)) {
|
||||
while (!(parent instanceof SvgViewShadowNode)) {
|
||||
if (parent == null) {
|
||||
return null;
|
||||
} else {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
}
|
||||
mSvgShadowNode = (RNSVGSvgViewShadowNode) parent;
|
||||
mSvgShadowNode = (SvgViewShadowNode) parent;
|
||||
return mSvgShadowNode;
|
||||
}
|
||||
|
||||
@@ -290,24 +290,24 @@ public abstract class RNSVGVirtualNode extends LayoutShadowNode {
|
||||
}
|
||||
}
|
||||
|
||||
abstract public void mergeProperties(RNSVGVirtualNode target, ReadableArray mergeList, boolean inherited);
|
||||
abstract public void mergeProperties(VirtualNode target, ReadableArray mergeList, boolean inherited);
|
||||
|
||||
abstract public void mergeProperties(RNSVGVirtualNode target, ReadableArray mergeList);
|
||||
abstract public void mergeProperties(VirtualNode target, ReadableArray mergeList);
|
||||
|
||||
abstract public void resetProperties();
|
||||
|
||||
protected interface NodeRunnable {
|
||||
boolean run(RNSVGVirtualNode node);
|
||||
boolean run(VirtualNode node);
|
||||
}
|
||||
|
||||
protected void traverseChildren(NodeRunnable runner) {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
ReactShadowNode child = getChildAt(i);
|
||||
if (!(child instanceof RNSVGVirtualNode)) {
|
||||
if (!(child instanceof VirtualNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!runner.run((RNSVGVirtualNode) child)) {
|
||||
if (!runner.run((VirtualNode) child)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user