mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-04 15:44:24 +00:00
[android] Fix Use element spec conformance (x and y interpretation)
This commit is contained in:
@@ -644,6 +644,16 @@ class RenderableViewManager extends ViewGroupManager<VirtualView> {
|
||||
node.setHref(href);
|
||||
}
|
||||
|
||||
@ReactProp(name = "x")
|
||||
public void setX(UseView node, Dynamic x) {
|
||||
node.setX(x);
|
||||
}
|
||||
|
||||
@ReactProp(name = "y")
|
||||
public void setY(UseView node, Dynamic y) {
|
||||
node.setY(y);
|
||||
}
|
||||
|
||||
@ReactProp(name = "width")
|
||||
public void setWidth(UseView node, Dynamic width) {
|
||||
node.setWidth(width);
|
||||
|
||||
@@ -23,6 +23,8 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
@SuppressLint("ViewConstructor")
|
||||
class UseView extends RenderableView {
|
||||
private String mHref;
|
||||
private SVGLength mX;
|
||||
private SVGLength mY;
|
||||
private SVGLength mW;
|
||||
private SVGLength mH;
|
||||
|
||||
@@ -36,6 +38,18 @@ class UseView extends RenderableView {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@ReactProp(name = "x")
|
||||
public void setX(Dynamic x) {
|
||||
mX = getLengthFromDynamic(x);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@ReactProp(name = "y")
|
||||
public void setY(Dynamic y) {
|
||||
mY = getLengthFromDynamic(y);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@ReactProp(name = "width")
|
||||
public void setWidth(Dynamic width) {
|
||||
mW = getLengthFromDynamic(width);
|
||||
@@ -53,6 +67,7 @@ class UseView extends RenderableView {
|
||||
VirtualView template = getSvgView().getDefinedTemplate(mHref);
|
||||
|
||||
if (template != null) {
|
||||
canvas.translate((float) relativeOnWidth(mX), (float) relativeOnHeight(mY));
|
||||
if (template instanceof RenderableView) {
|
||||
((RenderableView)template).mergeProperties(this);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ export default class Use extends Shape {
|
||||
static displayName = "Use";
|
||||
|
||||
static defaultProps = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
};
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
- (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect
|
||||
{
|
||||
CGContextTranslateCTM(context, [self relativeOnWidth:self.x], [self relativeOnWidth:self.y]);
|
||||
CGContextTranslateCTM(context, [self relativeOnWidth:self.x], [self relativeOnHeight:self.y]);
|
||||
RNSVGNode* template = [self.svgView getDefinedTemplate:self.href];
|
||||
if (template) {
|
||||
[self beginTransparencyLayer:context];
|
||||
|
||||
Reference in New Issue
Block a user