mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-05 07:59:28 +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);
|
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")
|
@ReactProp(name = "width")
|
||||||
public void setWidth(UseView node, Dynamic width) {
|
public void setWidth(UseView node, Dynamic width) {
|
||||||
node.setWidth(width);
|
node.setWidth(width);
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
|||||||
@SuppressLint("ViewConstructor")
|
@SuppressLint("ViewConstructor")
|
||||||
class UseView extends RenderableView {
|
class UseView extends RenderableView {
|
||||||
private String mHref;
|
private String mHref;
|
||||||
|
private SVGLength mX;
|
||||||
|
private SVGLength mY;
|
||||||
private SVGLength mW;
|
private SVGLength mW;
|
||||||
private SVGLength mH;
|
private SVGLength mH;
|
||||||
|
|
||||||
@@ -36,6 +38,18 @@ class UseView extends RenderableView {
|
|||||||
invalidate();
|
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")
|
@ReactProp(name = "width")
|
||||||
public void setWidth(Dynamic width) {
|
public void setWidth(Dynamic width) {
|
||||||
mW = getLengthFromDynamic(width);
|
mW = getLengthFromDynamic(width);
|
||||||
@@ -53,6 +67,7 @@ class UseView extends RenderableView {
|
|||||||
VirtualView template = getSvgView().getDefinedTemplate(mHref);
|
VirtualView template = getSvgView().getDefinedTemplate(mHref);
|
||||||
|
|
||||||
if (template != null) {
|
if (template != null) {
|
||||||
|
canvas.translate((float) relativeOnWidth(mX), (float) relativeOnHeight(mY));
|
||||||
if (template instanceof RenderableView) {
|
if (template instanceof RenderableView) {
|
||||||
((RenderableView)template).mergeProperties(this);
|
((RenderableView)template).mergeProperties(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ export default class Use extends Shape {
|
|||||||
static displayName = "Use";
|
static displayName = "Use";
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
|
|
||||||
- (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect
|
- (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];
|
RNSVGNode* template = [self.svgView getDefinedTemplate:self.href];
|
||||||
if (template) {
|
if (template) {
|
||||||
[self beginTransparencyLayer:context];
|
[self beginTransparencyLayer:context];
|
||||||
|
|||||||
Reference in New Issue
Block a user