diff --git a/android/src/main/java/com/horcrux/svg/RectShadowNode.java b/android/src/main/java/com/horcrux/svg/RectShadowNode.java index 35a7a1e4..503db229 100644 --- a/android/src/main/java/com/horcrux/svg/RectShadowNode.java +++ b/android/src/main/java/com/horcrux/svg/RectShadowNode.java @@ -13,6 +13,9 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.graphics.RectF; + +import com.facebook.react.bridge.Dynamic; +import com.facebook.react.bridge.ReadableType; import com.facebook.react.uimanager.annotations.ReactProp; /** @@ -41,15 +44,22 @@ class RectShadowNode extends RenderableShadowNode { } @ReactProp(name = "rectwidth") - public void setWidth(String width) { - mW = width; + public void setWidth(Dynamic width) { + if (width.getType() == ReadableType.String) { + mW = width.asString(); + } else { + mW = String.valueOf(width.asDouble()); + } markUpdated(); } - @ReactProp(name = "rectheight") - public void setHeight(String height) { - mH = height; + public void setHeight(Dynamic height) { + if (height.getType() == ReadableType.String) { + mH = height.asString(); + } else { + mH = String.valueOf(height.asDouble()); + } markUpdated(); } diff --git a/android/src/main/java/com/horcrux/svg/RenderableViewManager.java b/android/src/main/java/com/horcrux/svg/RenderableViewManager.java index 3b8b07b6..bee3e761 100644 --- a/android/src/main/java/com/horcrux/svg/RenderableViewManager.java +++ b/android/src/main/java/com/horcrux/svg/RenderableViewManager.java @@ -304,13 +304,13 @@ class RenderableViewManager extends ViewGroupManager node, String width) { + public void setWidth(RenderableView node, Dynamic width) { node.shadowNode.setWidth(width); } @ReactProp(name = "rectheight") - public void setHeight(RenderableView node, String height) { + public void setHeight(RenderableView node, Dynamic height) { node.shadowNode.setHeight(height); } diff --git a/elements/Image.js b/elements/Image.js index 59157c6f..767d9dc8 100644 --- a/elements/Image.js +++ b/elements/Image.js @@ -31,8 +31,14 @@ export default class extends Shape { preserveAspectRatio: "xMidYMid meet", }; - setNativeProps = (...args) => { - this.root.setNativeProps(...args); + setNativeProps = (props) => { + if (props.width) { + props.imagewidth = `${props.width}`; + } + if (props.height) { + props.imageheight = `${props.height}`; + } + this.root.setNativeProps(props); }; render() { diff --git a/elements/Mask.js b/elements/Mask.js index 2f98a021..6ac63a4b 100644 --- a/elements/Mask.js +++ b/elements/Mask.js @@ -22,6 +22,16 @@ export default class extends Component { ]), }; + setNativeProps = (props) => { + if (props.width) { + props.maskwidth = `${props.width}`; + } + if (props.height) { + props.maskheight = `${props.height}`; + } + this.root.setNativeProps(props); + }; + render() { const { props } = this; const { @@ -48,6 +58,9 @@ export default class extends Component { return ( { + this.root = ele; + }} name={id} x={`${x}`} y={`${y}`} diff --git a/elements/Pattern.js b/elements/Pattern.js index 42fa58b2..8ad40101 100644 --- a/elements/Pattern.js +++ b/elements/Pattern.js @@ -25,6 +25,16 @@ export default class extends Component { preserveAspectRatio: PropTypes.string, }; + setNativeProps = (props) => { + if (props.width) { + props.patternwidth = `${props.width}`; + } + if (props.height) { + props.patternheight = `${props.height}`; + } + this.root.setNativeProps(props); + }; + render() { const { props } = this; const { @@ -53,6 +63,9 @@ export default class extends Component { return ( { + this.root = ele; + }} name={id} x={`${x}`} y={`${y}`} diff --git a/elements/Rect.js b/elements/Rect.js index 3d92fc76..770ae8d4 100644 --- a/elements/Rect.js +++ b/elements/Rect.js @@ -28,8 +28,14 @@ export default class extends Shape { ry: 0 }; - setNativeProps = (...args) => { - this.root.setNativeProps(...args); + setNativeProps = (props) => { + if (props.width) { + props.rectwidth = `${props.width}`; + } + if (props.height) { + props.rectheight = `${props.height}`; + } + this.root.setNativeProps(props); }; render() { diff --git a/elements/Svg.js b/elements/Svg.js index 912fe1de..a75f0e56 100644 --- a/elements/Svg.js +++ b/elements/Svg.js @@ -62,8 +62,14 @@ class Svg extends Shape { this.root.measureLayout(...args); }; - setNativeProps = (...args) => { - this.root.setNativeProps(...args); + setNativeProps = (props) => { + if (props.width) { + props.bbWidth = `${props.width}`; + } + if (props.height) { + props.bbHeight = `${props.height}`; + } + this.root.setNativeProps(props); }; toDataURL = callback => { diff --git a/elements/Use.js b/elements/Use.js index 694a2fa1..0b1a8fc0 100644 --- a/elements/Use.js +++ b/elements/Use.js @@ -22,8 +22,14 @@ export default class extends Shape { height: 0 }; - setNativeProps = (...args) => { - this.root.setNativeProps(...args); + setNativeProps = (props) => { + if (props.width) { + props.usewidth = `${props.width}`; + } + if (props.height) { + props.useheight = `${props.height}`; + } + this.root.setNativeProps(props); }; render() {