[android] Fix Use element spec conformance (x and y interpretation)

This commit is contained in:
Mikael Sand
2019-01-14 15:44:00 +02:00
parent ccb615dbca
commit 3dc6b80953
4 changed files with 28 additions and 1 deletions
@@ -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);
}