From 50c2289a2cec4795d3c62d455507c02a42ff97f1 Mon Sep 17 00:00:00 2001 From: Wojciech Lewicki Date: Tue, 5 Mar 2024 11:36:17 +0100 Subject: [PATCH] feat: use dynamics instead of strings for props that can be either string or number (#2238) # Summary PR bringing proper support for react-native-reanimated in the library by using dynamics instead of strings for props that can be either string or number. --- FabricExample/ios/Podfile.lock | 8 +- FabricExample/package.json | 1 - .../main/java/com/horcrux/svg/CircleView.java | 30 - .../java/com/horcrux/svg/EllipseView.java | 40 -- .../com/horcrux/svg/ForeignObjectView.java | 40 -- .../main/java/com/horcrux/svg/GroupView.java | 11 + .../main/java/com/horcrux/svg/ImageView.java | 40 -- .../main/java/com/horcrux/svg/LineView.java | 40 -- .../com/horcrux/svg/LinearGradientView.java | 40 -- .../main/java/com/horcrux/svg/MarkerView.java | 40 -- .../main/java/com/horcrux/svg/MaskView.java | 40 -- .../java/com/horcrux/svg/PatternView.java | 40 -- .../com/horcrux/svg/RadialGradientView.java | 60 -- .../main/java/com/horcrux/svg/RectView.java | 60 -- .../java/com/horcrux/svg/RenderableView.java | 37 +- .../horcrux/svg/RenderableViewManager.java | 561 +----------------- .../main/java/com/horcrux/svg/SvgView.java | 24 - .../java/com/horcrux/svg/SvgViewManager.java | 18 - .../java/com/horcrux/svg/TextPathView.java | 10 - .../main/java/com/horcrux/svg/TextView.java | 58 +- .../main/java/com/horcrux/svg/UseView.java | 40 -- .../RNSVGCircleManagerDelegate.java | 39 +- .../RNSVGCircleManagerInterface.java | 16 +- .../RNSVGClipPathManagerDelegate.java | 33 +- .../RNSVGClipPathManagerInterface.java | 15 +- .../RNSVGEllipseManagerDelegate.java | 47 +- .../RNSVGEllipseManagerInterface.java | 19 +- .../RNSVGForeignObjectManagerDelegate.java | 65 +- .../RNSVGForeignObjectManagerInterface.java | 27 +- .../RNSVGGroupManagerDelegate.java | 33 +- .../RNSVGGroupManagerInterface.java | 15 +- .../RNSVGImageManagerDelegate.java | 51 +- .../RNSVGImageManagerInterface.java | 19 +- .../RNSVGLineManagerDelegate.java | 47 +- .../RNSVGLineManagerInterface.java | 19 +- .../RNSVGLinearGradientManagerDelegate.java | 33 +- .../RNSVGLinearGradientManagerInterface.java | 13 +- .../RNSVGMarkerManagerDelegate.java | 65 +- .../RNSVGMarkerManagerInterface.java | 27 +- .../RNSVGMaskManagerDelegate.java | 65 +- .../RNSVGMaskManagerInterface.java | 27 +- .../RNSVGPathManagerDelegate.java | 15 +- .../RNSVGPathManagerInterface.java | 7 +- .../RNSVGPatternManagerDelegate.java | 65 +- .../RNSVGPatternManagerInterface.java | 27 +- .../RNSVGRadialGradientManagerDelegate.java | 49 +- .../RNSVGRadialGradientManagerInterface.java | 19 +- .../RNSVGRectManagerDelegate.java | 63 +- .../RNSVGRectManagerInterface.java | 25 +- .../RNSVGSvgViewAndroidManagerDelegate.java | 25 +- .../RNSVGSvgViewAndroidManagerInterface.java | 7 +- .../RNSVGSymbolManagerDelegate.java | 33 +- .../RNSVGSymbolManagerInterface.java | 15 +- .../RNSVGTSpanManagerDelegate.java | 69 +-- .../RNSVGTSpanManagerInterface.java | 36 +- .../RNSVGTextManagerDelegate.java | 69 +-- .../RNSVGTextManagerInterface.java | 36 +- .../RNSVGTextPathManagerDelegate.java | 77 +-- .../RNSVGTextPathManagerInterface.java | 39 +- .../viewmanagers/RNSVGUseManagerDelegate.java | 47 +- .../RNSVGUseManagerInterface.java | 19 +- apple/Elements/RNSVGForeignObject.mm | 24 +- apple/Elements/RNSVGImage.mm | 20 +- apple/Elements/RNSVGLinearGradient.mm | 20 +- apple/Elements/RNSVGMarker.mm | 20 +- apple/Elements/RNSVGMask.mm | 21 +- apple/Elements/RNSVGPattern.mm | 20 +- apple/Elements/RNSVGRadialGradient.mm | 30 +- apple/Elements/RNSVGSvgView.mm | 10 +- apple/Elements/RNSVGUse.mm | 20 +- apple/Shapes/RNSVGCircle.mm | 15 +- apple/Shapes/RNSVGEllipse.mm | 20 +- apple/Shapes/RNSVGLine.mm | 20 +- apple/Shapes/RNSVGRect.mm | 30 +- apple/Text/RNSVGTextPath.mm | 5 +- apple/Utils/RNSVGFabricConversions.h | 166 ++++-- src/css/css.tsx | 4 +- src/elements/Circle.tsx | 7 +- src/elements/Ellipse.tsx | 7 +- src/elements/ForeignObject.tsx | 7 +- src/elements/Image.tsx | 10 +- src/elements/Line.tsx | 7 +- src/elements/LinearGradient.tsx | 3 +- src/elements/Marker.tsx | 5 +- src/elements/Mask.tsx | 10 +- src/elements/Pattern.tsx | 6 +- src/elements/RadialGradient.tsx | 5 +- src/elements/Rect.tsx | 7 +- src/elements/Svg.tsx | 11 +- src/elements/TextPath.tsx | 2 +- src/elements/Use.tsx | 11 +- src/fabric/AndroidSvgViewNativeComponent.ts | 7 +- src/fabric/CircleNativeComponent.ts | 13 +- src/fabric/ClipPathNativeComponent.ts | 30 +- src/fabric/EllipseNativeComponent.ts | 15 +- src/fabric/ForeignObjectNativeComponent.ts | 38 +- src/fabric/GroupNativeComponent.ts | 30 +- src/fabric/IOSSvgViewNativeComponent.ts | 7 +- src/fabric/ImageNativeComponent.ts | 15 +- src/fabric/LineNativeComponent.ts | 15 +- src/fabric/LinearGradientNativeComponent.ts | 11 +- src/fabric/MarkerNativeComponent.ts | 38 +- src/fabric/MaskNativeComponent.ts | 38 +- src/fabric/PathNativeComponent.ts | 7 +- src/fabric/PatternNativeComponent.ts | 38 +- src/fabric/RadialGradientNativeComponent.ts | 15 +- src/fabric/RectNativeComponent.ts | 19 +- src/fabric/SymbolNativeComponent.ts | 30 +- src/fabric/TSpanNativeComponent.ts | 48 +- src/fabric/TextNativeComponent.ts | 48 +- src/fabric/TextPathNativeComponent.ts | 50 +- src/fabric/UseNativeComponent.ts | 15 +- src/fabric/codegenUtils.ts | 8 + src/lib/extract/extractLengthList.ts | 8 +- src/lib/extract/extractProps.ts | 13 - src/lib/extract/extractProps.windows.ts | 17 - src/lib/extract/extractStroke.ts | 4 +- src/lib/extract/extractText.tsx | 24 +- 118 files changed, 931 insertions(+), 2868 deletions(-) create mode 100644 src/fabric/codegenUtils.ts diff --git a/FabricExample/ios/Podfile.lock b/FabricExample/ios/Podfile.lock index 5c51eb97..fc8557c5 100644 --- a/FabricExample/ios/Podfile.lock +++ b/FabricExample/ios/Podfile.lock @@ -1171,7 +1171,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNSVG (14.1.0): + - RNSVG (15.0.0): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -1189,9 +1189,9 @@ PODS: - React-utils - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNSVG/common (= 14.1.0) + - RNSVG/common (= 15.0.0) - Yoga - - RNSVG/common (14.1.0): + - RNSVG/common (15.0.0): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -1482,7 +1482,7 @@ SPEC CHECKSUMS: React-utils: debda2c206770ee2785bdebb7f16d8db9f18838a ReactCommon: ddb128564dcbfa0287d3d1a2d10f8c7457c971f6 RNReanimated: 71030d84b41327898b22cab449eb5379baf8725e - RNSVG: 95341a1f9dc5b08bfbb4312cc20e321063f17883 + RNSVG: da171fbe23686685cce6bf80f6ecca07108cbd79 SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: 4f53dc50008d626fa679c7a1cb4bed898f8c0bde diff --git a/FabricExample/package.json b/FabricExample/package.json index dd5224a6..c52d971b 100644 --- a/FabricExample/package.json +++ b/FabricExample/package.json @@ -12,7 +12,6 @@ "dependencies": { "react": "18.2.0", "react-native": "0.73.1", - "react-native-reanimated": "^3.6.1", "react-native-svg": "link:../" }, diff --git a/android/src/main/java/com/horcrux/svg/CircleView.java b/android/src/main/java/com/horcrux/svg/CircleView.java index 3caccec6..6d04ec9f 100644 --- a/android/src/main/java/com/horcrux/svg/CircleView.java +++ b/android/src/main/java/com/horcrux/svg/CircleView.java @@ -31,46 +31,16 @@ class CircleView extends RenderableView { invalidate(); } - public void setCx(String cx) { - mCx = SVGLength.from(cx); - invalidate(); - } - - public void setCx(Double cx) { - mCx = SVGLength.from(cx); - invalidate(); - } - public void setCy(Dynamic cy) { mCy = SVGLength.from(cy); invalidate(); } - public void setCy(String cy) { - mCy = SVGLength.from(cy); - invalidate(); - } - - public void setCy(Double cy) { - mCy = SVGLength.from(cy); - invalidate(); - } - public void setR(Dynamic r) { mR = SVGLength.from(r); invalidate(); } - public void setR(String r) { - mR = SVGLength.from(r); - invalidate(); - } - - public void setR(Double r) { - mR = SVGLength.from(r); - invalidate(); - } - @Override Path getPath(Canvas canvas, Paint paint) { Path path = new Path(); diff --git a/android/src/main/java/com/horcrux/svg/EllipseView.java b/android/src/main/java/com/horcrux/svg/EllipseView.java index 73b5df8c..c9955daf 100644 --- a/android/src/main/java/com/horcrux/svg/EllipseView.java +++ b/android/src/main/java/com/horcrux/svg/EllipseView.java @@ -33,61 +33,21 @@ class EllipseView extends RenderableView { invalidate(); } - public void setCx(String cx) { - mCx = SVGLength.from(cx); - invalidate(); - } - - public void setCx(Double cx) { - mCx = SVGLength.from(cx); - invalidate(); - } - public void setCy(Dynamic cy) { mCy = SVGLength.from(cy); invalidate(); } - public void setCy(String cy) { - mCy = SVGLength.from(cy); - invalidate(); - } - - public void setCy(Double cy) { - mCy = SVGLength.from(cy); - invalidate(); - } - public void setRx(Dynamic rx) { mRx = SVGLength.from(rx); invalidate(); } - public void setRx(String rx) { - mRx = SVGLength.from(rx); - invalidate(); - } - - public void setRx(Double rx) { - mRx = SVGLength.from(rx); - invalidate(); - } - public void setRy(Dynamic ry) { mRy = SVGLength.from(ry); invalidate(); } - public void setRy(String ry) { - mRy = SVGLength.from(ry); - invalidate(); - } - - public void setRy(Double ry) { - mRy = SVGLength.from(ry); - invalidate(); - } - @Override Path getPath(Canvas canvas, Paint paint) { Path path = new Path(); diff --git a/android/src/main/java/com/horcrux/svg/ForeignObjectView.java b/android/src/main/java/com/horcrux/svg/ForeignObjectView.java index 80217d03..7ca324ef 100644 --- a/android/src/main/java/com/horcrux/svg/ForeignObjectView.java +++ b/android/src/main/java/com/horcrux/svg/ForeignObjectView.java @@ -52,61 +52,21 @@ class ForeignObjectView extends GroupView { invalidate(); } - public void setX(String x) { - mX = SVGLength.from(x); - invalidate(); - } - - public void setX(Double x) { - mX = SVGLength.from(x); - invalidate(); - } - public void setY(Dynamic y) { mY = SVGLength.from(y); invalidate(); } - public void setY(String y) { - mY = SVGLength.from(y); - invalidate(); - } - - public void setY(Double y) { - mY = SVGLength.from(y); - invalidate(); - } - public void setWidth(Dynamic width) { mW = SVGLength.from(width); invalidate(); } - public void setWidth(String width) { - mW = SVGLength.from(width); - invalidate(); - } - - public void setWidth(Double width) { - mW = SVGLength.from(width); - invalidate(); - } - public void setHeight(Dynamic height) { mH = SVGLength.from(height); invalidate(); } - public void setHeight(String height) { - mH = SVGLength.from(height); - invalidate(); - } - - public void setHeight(Double height) { - mH = SVGLength.from(height); - invalidate(); - } - void drawGroup(final Canvas canvas, final Paint paint, final float opacity) { pushGlyphContext(); final SvgView svg = getSvgView(); diff --git a/android/src/main/java/com/horcrux/svg/GroupView.java b/android/src/main/java/com/horcrux/svg/GroupView.java index a17c1bdf..44089d55 100644 --- a/android/src/main/java/com/horcrux/svg/GroupView.java +++ b/android/src/main/java/com/horcrux/svg/GroupView.java @@ -18,8 +18,10 @@ import android.graphics.RectF; import android.graphics.Region; import android.os.Build; import android.view.View; +import com.facebook.react.bridge.Dynamic; import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.bridge.ReadableType; import java.util.ArrayList; import javax.annotation.Nullable; @@ -32,6 +34,15 @@ class GroupView extends RenderableView { super(reactContext); } + public void setFont(Dynamic dynamic) { + if (dynamic.getType() == ReadableType.Map) { + mFont = dynamic.asMap(); + } else { + mFont = null; + } + invalidate(); + } + public void setFont(@Nullable ReadableMap font) { mFont = font; invalidate(); diff --git a/android/src/main/java/com/horcrux/svg/ImageView.java b/android/src/main/java/com/horcrux/svg/ImageView.java index 07a2f89f..f8ed04b6 100644 --- a/android/src/main/java/com/horcrux/svg/ImageView.java +++ b/android/src/main/java/com/horcrux/svg/ImageView.java @@ -58,61 +58,21 @@ class ImageView extends RenderableView { invalidate(); } - public void setX(String x) { - mX = SVGLength.from(x); - invalidate(); - } - - public void setX(Double x) { - mX = SVGLength.from(x); - invalidate(); - } - public void setY(Dynamic y) { mY = SVGLength.from(y); invalidate(); } - public void setY(String y) { - mY = SVGLength.from(y); - invalidate(); - } - - public void setY(Double y) { - mY = SVGLength.from(y); - invalidate(); - } - public void setWidth(Dynamic width) { mW = SVGLength.from(width); invalidate(); } - public void setWidth(String width) { - mW = SVGLength.from(width); - invalidate(); - } - - public void setWidth(Double width) { - mW = SVGLength.from(width); - invalidate(); - } - public void setHeight(Dynamic height) { mH = SVGLength.from(height); invalidate(); } - public void setHeight(String height) { - mH = SVGLength.from(height); - invalidate(); - } - - public void setHeight(Double height) { - mH = SVGLength.from(height); - invalidate(); - } - public void setSrc(@Nullable ReadableMap src) { if (src != null) { uriString = src.getString("uri"); diff --git a/android/src/main/java/com/horcrux/svg/LineView.java b/android/src/main/java/com/horcrux/svg/LineView.java index 4832443f..459bfaa2 100644 --- a/android/src/main/java/com/horcrux/svg/LineView.java +++ b/android/src/main/java/com/horcrux/svg/LineView.java @@ -32,61 +32,21 @@ class LineView extends RenderableView { invalidate(); } - public void setX1(String x1) { - mX1 = SVGLength.from(x1); - invalidate(); - } - - public void setX1(Double x1) { - mX1 = SVGLength.from(x1); - invalidate(); - } - public void setY1(Dynamic y1) { mY1 = SVGLength.from(y1); invalidate(); } - public void setY1(String y1) { - mY1 = SVGLength.from(y1); - invalidate(); - } - - public void setY1(Double y1) { - mY1 = SVGLength.from(y1); - invalidate(); - } - public void setX2(Dynamic x2) { mX2 = SVGLength.from(x2); invalidate(); } - public void setX2(String x2) { - mX2 = SVGLength.from(x2); - invalidate(); - } - - public void setX2(Double x2) { - mX2 = SVGLength.from(x2); - invalidate(); - } - public void setY2(Dynamic y2) { mY2 = SVGLength.from(y2); invalidate(); } - public void setY2(String y2) { - mY2 = SVGLength.from(y2); - invalidate(); - } - - public void setY2(Double y2) { - mY2 = SVGLength.from(y2); - invalidate(); - } - @Override Path getPath(Canvas canvas, Paint paint) { Path path = new Path(); diff --git a/android/src/main/java/com/horcrux/svg/LinearGradientView.java b/android/src/main/java/com/horcrux/svg/LinearGradientView.java index 891d8473..1039fcf4 100644 --- a/android/src/main/java/com/horcrux/svg/LinearGradientView.java +++ b/android/src/main/java/com/horcrux/svg/LinearGradientView.java @@ -44,61 +44,21 @@ class LinearGradientView extends DefinitionView { invalidate(); } - public void setX1(String x1) { - mX1 = SVGLength.from(x1); - invalidate(); - } - - public void setX1(Double x1) { - mX1 = SVGLength.from(x1); - invalidate(); - } - public void setY1(Dynamic y1) { mY1 = SVGLength.from(y1); invalidate(); } - public void setY1(String y1) { - mY1 = SVGLength.from(y1); - invalidate(); - } - - public void setY1(Double y1) { - mY1 = SVGLength.from(y1); - invalidate(); - } - public void setX2(Dynamic x2) { mX2 = SVGLength.from(x2); invalidate(); } - public void setX2(String x2) { - mX2 = SVGLength.from(x2); - invalidate(); - } - - public void setX2(Double x2) { - mX2 = SVGLength.from(x2); - invalidate(); - } - public void setY2(Dynamic y2) { mY2 = SVGLength.from(y2); invalidate(); } - public void setY2(String y2) { - mY2 = SVGLength.from(y2); - invalidate(); - } - - public void setY2(Double y2) { - mY2 = SVGLength.from(y2); - invalidate(); - } - public void setGradient(ReadableArray gradient) { mGradient = gradient; invalidate(); diff --git a/android/src/main/java/com/horcrux/svg/MarkerView.java b/android/src/main/java/com/horcrux/svg/MarkerView.java index a78949ac..b9ebb2c5 100644 --- a/android/src/main/java/com/horcrux/svg/MarkerView.java +++ b/android/src/main/java/com/horcrux/svg/MarkerView.java @@ -45,61 +45,21 @@ class MarkerView extends GroupView { invalidate(); } - public void setRefX(String refX) { - mRefX = SVGLength.from(refX); - invalidate(); - } - - public void setRefX(Double refX) { - mRefX = SVGLength.from(refX); - invalidate(); - } - public void setRefY(Dynamic refY) { mRefY = SVGLength.from(refY); invalidate(); } - public void setRefY(String refY) { - mRefY = SVGLength.from(refY); - invalidate(); - } - - public void setRefY(Double refY) { - mRefY = SVGLength.from(refY); - invalidate(); - } - public void setMarkerWidth(Dynamic markerWidth) { mMarkerWidth = SVGLength.from(markerWidth); invalidate(); } - public void setMarkerWidth(String markerWidth) { - mMarkerWidth = SVGLength.from(markerWidth); - invalidate(); - } - - public void setMarkerWidth(Double markerWidth) { - mMarkerWidth = SVGLength.from(markerWidth); - invalidate(); - } - public void setMarkerHeight(Dynamic markerHeight) { mMarkerHeight = SVGLength.from(markerHeight); invalidate(); } - public void setMarkerHeight(String markerHeight) { - mMarkerHeight = SVGLength.from(markerHeight); - invalidate(); - } - - public void setMarkerHeight(Double markerHeight) { - mMarkerHeight = SVGLength.from(markerHeight); - invalidate(); - } - public void setMarkerUnits(String markerUnits) { mMarkerUnits = markerUnits; invalidate(); diff --git a/android/src/main/java/com/horcrux/svg/MaskView.java b/android/src/main/java/com/horcrux/svg/MaskView.java index c91503aa..91369673 100644 --- a/android/src/main/java/com/horcrux/svg/MaskView.java +++ b/android/src/main/java/com/horcrux/svg/MaskView.java @@ -36,61 +36,21 @@ class MaskView extends GroupView { invalidate(); } - public void setX(String x) { - mX = SVGLength.from(x); - invalidate(); - } - - public void setX(Double x) { - mX = SVGLength.from(x); - invalidate(); - } - public void setY(Dynamic y) { mY = SVGLength.from(y); invalidate(); } - public void setY(String y) { - mY = SVGLength.from(y); - invalidate(); - } - - public void setY(Double y) { - mY = SVGLength.from(y); - invalidate(); - } - public void setWidth(Dynamic width) { mW = SVGLength.from(width); invalidate(); } - public void setWidth(String width) { - mW = SVGLength.from(width); - invalidate(); - } - - public void setWidth(Double width) { - mW = SVGLength.from(width); - invalidate(); - } - public void setHeight(Dynamic height) { mH = SVGLength.from(height); invalidate(); } - public void setHeight(String height) { - mH = SVGLength.from(height); - invalidate(); - } - - public void setHeight(Double height) { - mH = SVGLength.from(height); - invalidate(); - } - public void setMaskUnits(int maskUnits) { switch (maskUnits) { case 0: diff --git a/android/src/main/java/com/horcrux/svg/PatternView.java b/android/src/main/java/com/horcrux/svg/PatternView.java index aeb90c4b..31e8d2eb 100644 --- a/android/src/main/java/com/horcrux/svg/PatternView.java +++ b/android/src/main/java/com/horcrux/svg/PatternView.java @@ -52,61 +52,21 @@ class PatternView extends GroupView { invalidate(); } - public void setX(String x) { - mX = SVGLength.from(x); - invalidate(); - } - - public void setX(Double x) { - mX = SVGLength.from(x); - invalidate(); - } - public void setY(Dynamic y) { mY = SVGLength.from(y); invalidate(); } - public void setY(String y) { - mY = SVGLength.from(y); - invalidate(); - } - - public void setY(Double y) { - mY = SVGLength.from(y); - invalidate(); - } - public void setWidth(Dynamic width) { mW = SVGLength.from(width); invalidate(); } - public void setWidth(String width) { - mW = SVGLength.from(width); - invalidate(); - } - - public void setWidth(Double width) { - mW = SVGLength.from(width); - invalidate(); - } - public void setHeight(Dynamic height) { mH = SVGLength.from(height); invalidate(); } - public void setHeight(String height) { - mH = SVGLength.from(height); - invalidate(); - } - - public void setHeight(Double height) { - mH = SVGLength.from(height); - invalidate(); - } - public void setPatternUnits(int patternUnits) { switch (patternUnits) { case 0: diff --git a/android/src/main/java/com/horcrux/svg/RadialGradientView.java b/android/src/main/java/com/horcrux/svg/RadialGradientView.java index 5f1e9ea7..7083d5b3 100644 --- a/android/src/main/java/com/horcrux/svg/RadialGradientView.java +++ b/android/src/main/java/com/horcrux/svg/RadialGradientView.java @@ -45,91 +45,31 @@ class RadialGradientView extends DefinitionView { invalidate(); } - public void setFx(String fx) { - mFx = SVGLength.from(fx); - invalidate(); - } - - public void setFx(Double fx) { - mFx = SVGLength.from(fx); - invalidate(); - } - public void setFy(Dynamic fy) { mFy = SVGLength.from(fy); invalidate(); } - public void setFy(String fy) { - mFy = SVGLength.from(fy); - invalidate(); - } - - public void setFy(Double fy) { - mFy = SVGLength.from(fy); - invalidate(); - } - public void setRx(Dynamic rx) { mRx = SVGLength.from(rx); invalidate(); } - public void setRx(String rx) { - mRx = SVGLength.from(rx); - invalidate(); - } - - public void setRx(Double rx) { - mRx = SVGLength.from(rx); - invalidate(); - } - public void setRy(Dynamic ry) { mRy = SVGLength.from(ry); invalidate(); } - public void setRy(String ry) { - mRy = SVGLength.from(ry); - invalidate(); - } - - public void setRy(Double ry) { - mRy = SVGLength.from(ry); - invalidate(); - } - public void setCx(Dynamic cx) { mCx = SVGLength.from(cx); invalidate(); } - public void setCx(String cx) { - mCx = SVGLength.from(cx); - invalidate(); - } - - public void setCx(Double cx) { - mCx = SVGLength.from(cx); - invalidate(); - } - public void setCy(Dynamic cy) { mCy = SVGLength.from(cy); invalidate(); } - public void setCy(String cy) { - mCy = SVGLength.from(cy); - invalidate(); - } - - public void setCy(Double cy) { - mCy = SVGLength.from(cy); - invalidate(); - } - public void setGradient(ReadableArray gradient) { mGradient = gradient; invalidate(); diff --git a/android/src/main/java/com/horcrux/svg/RectView.java b/android/src/main/java/com/horcrux/svg/RectView.java index ec6128b0..c4fee29a 100644 --- a/android/src/main/java/com/horcrux/svg/RectView.java +++ b/android/src/main/java/com/horcrux/svg/RectView.java @@ -36,91 +36,31 @@ class RectView extends RenderableView { invalidate(); } - public void setX(String x) { - mX = SVGLength.from(x); - invalidate(); - } - - public void setX(Double x) { - mX = SVGLength.from(x); - invalidate(); - } - public void setY(Dynamic y) { mY = SVGLength.from(y); invalidate(); } - public void setY(String y) { - mY = SVGLength.from(y); - invalidate(); - } - - public void setY(Double y) { - mY = SVGLength.from(y); - invalidate(); - } - public void setWidth(Dynamic width) { mW = SVGLength.from(width); invalidate(); } - public void setWidth(String width) { - mW = SVGLength.from(width); - invalidate(); - } - - public void setWidth(Double width) { - mW = SVGLength.from(width); - invalidate(); - } - public void setHeight(Dynamic height) { mH = SVGLength.from(height); invalidate(); } - public void setHeight(String height) { - mH = SVGLength.from(height); - invalidate(); - } - - public void setHeight(Double height) { - mH = SVGLength.from(height); - invalidate(); - } - public void setRx(Dynamic rx) { mRx = SVGLength.from(rx); invalidate(); } - public void setRx(String rx) { - mRx = SVGLength.from(rx); - invalidate(); - } - - public void setRx(Double rx) { - mRx = SVGLength.from(rx); - invalidate(); - } - public void setRy(Dynamic ry) { mRy = SVGLength.from(ry); invalidate(); } - public void setRy(String ry) { - mRy = SVGLength.from(ry); - invalidate(); - } - - public void setRy(Double ry) { - mRy = SVGLength.from(ry); - invalidate(); - } - @Override Path getPath(Canvas canvas, Paint paint) { Path path = new Path(); diff --git a/android/src/main/java/com/horcrux/svg/RenderableView.java b/android/src/main/java/com/horcrux/svg/RenderableView.java index e5e485f4..dde4c744 100644 --- a/android/src/main/java/com/horcrux/svg/RenderableView.java +++ b/android/src/main/java/com/horcrux/svg/RenderableView.java @@ -253,8 +253,9 @@ public abstract class RenderableView extends VirtualView implements ReactHitSlop invalidate(); } - public void setStrokeDasharray(@Nullable ReadableArray strokeDasharray) { - if (strokeDasharray != null) { + public void setStrokeDasharray(Dynamic dynamicStrokeDasharray) { + if (!dynamicStrokeDasharray.isNull()) { + ReadableArray strokeDasharray = dynamicStrokeDasharray.asArray(); int fromSize = strokeDasharray.size(); this.strokeDasharray = new SVGLength[fromSize]; for (int i = 0; i < fromSize; i++) { @@ -266,28 +267,6 @@ public abstract class RenderableView extends VirtualView implements ReactHitSlop invalidate(); } - public void setStrokeDasharray(@Nullable String strokeDasharray) { - if (strokeDasharray != null) { - String stringValue = strokeDasharray.trim(); - stringValue = stringValue.replaceAll(",", " "); - String[] strings = stringValue.split(" "); - ArrayList list = new ArrayList<>(strings.length); - for (String length : strings) { - list.add(new SVGLength(length)); - } - this.strokeDasharray = new SVGLength[Math.max(list.size(), 2)]; - for (int i = 0; i < list.size(); i++) { - this.strokeDasharray[i] = list.get(i); - } - if (list.size() == 1) { - this.strokeDasharray[1] = this.strokeDasharray[0]; - } - } else { - this.strokeDasharray = null; - } - invalidate(); - } - public void setStrokeDashoffset(float strokeDashoffset) { this.strokeDashoffset = strokeDashoffset * mScale; invalidate(); @@ -298,16 +277,6 @@ public abstract class RenderableView extends VirtualView implements ReactHitSlop invalidate(); } - public void setStrokeWidth(String strokeWidth) { - this.strokeWidth = SVGLength.from(strokeWidth); - invalidate(); - } - - public void setStrokeWidth(Double strokeWidth) { - this.strokeWidth = SVGLength.from(strokeWidth); - invalidate(); - } - public void setStrokeMiterlimit(float strokeMiterlimit) { this.strokeMiterlimit = strokeMiterlimit; invalidate(); diff --git a/android/src/main/java/com/horcrux/svg/RenderableViewManager.java b/android/src/main/java/com/horcrux/svg/RenderableViewManager.java index 816de628..567eb6ce 100644 --- a/android/src/main/java/com/horcrux/svg/RenderableViewManager.java +++ b/android/src/main/java/com/horcrux/svg/RenderableViewManager.java @@ -666,7 +666,7 @@ class RenderableViewManager extends VirtualViewManager } @ReactProp(name = "font") - public void setFont(U node, @Nullable ReadableMap font) { + public void setFont(U node, Dynamic font) { node.setFont(font); } @@ -686,18 +686,6 @@ class RenderableViewManager extends VirtualViewManager node.setFont(map); } - public void setFontSize(U view, @Nullable String value) { - JavaOnlyMap map = new JavaOnlyMap(); - map.putString("fontSize", value); - view.setFont(map); - } - - public void setFontSize(U view, @Nullable Double value) { - JavaOnlyMap map = new JavaOnlyMap(); - map.putDouble("fontSize", value); - view.setFont(map); - } - @ReactProp(name = "fontWeight") public void setFontWeight(U node, Dynamic fontWeight) { JavaOnlyMap map = new JavaOnlyMap(); @@ -713,18 +701,6 @@ class RenderableViewManager extends VirtualViewManager } node.setFont(map); } - - public void setFontWeight(U view, @Nullable String value) { - JavaOnlyMap map = new JavaOnlyMap(); - map.putString("fontWeight", value); - view.setFont(map); - } - - public void setFontWeight(U view, @Nullable Double value) { - JavaOnlyMap map = new JavaOnlyMap(); - map.putDouble("fontWeight", value); - view.setFont(map); - } } static class GroupViewManager extends GroupViewManagerAbstract @@ -783,7 +759,7 @@ class RenderableViewManager extends VirtualViewManager } @ReactProp(name = "verticalAlign") - public void setVerticalAlign(K node, @Nullable String verticalAlign) { + public void setVerticalAlign(K node, @Nullable Dynamic verticalAlign) { node.setVerticalAlign(verticalAlign); } @@ -793,12 +769,12 @@ class RenderableViewManager extends VirtualViewManager } @ReactProp(name = "dx") - public void setDeltaX(K node, Dynamic deltaX) { + public void setDx(K node, Dynamic deltaX) { node.setDeltaX(deltaX); } @ReactProp(name = "dy") - public void setDeltaY(K node, Dynamic deltaY) { + public void setDy(K node, Dynamic deltaY) { node.setDeltaY(deltaY); } @@ -813,57 +789,13 @@ class RenderableViewManager extends VirtualViewManager } @ReactProp(name = "font") - public void setFont(K node, @Nullable ReadableMap font) { + public void setFont(K node, Dynamic font) { node.setFont(font); } public void setAlignmentBaseline(K view, @Nullable String value) { view.setMethod(value); } - - public void setDx(K view, @Nullable ReadableArray value) { - view.setDeltaX(value); - } - - public void setDy(K view, @Nullable ReadableArray value) { - view.setDeltaY(value); - } - - public void setX(K view, @Nullable ReadableArray value) { - view.setPositionX(value); - } - - public void setY(K view, @Nullable ReadableArray value) { - view.setPositionY(value); - } - - public void setRotate(K view, @Nullable ReadableArray value) { - view.setRotate(value); - } - - public void setInlineSize(K view, @Nullable String value) { - view.setInlineSize(value); - } - - public void setTextLength(K view, @Nullable String value) { - view.setTextLength(value); - } - - public void setBaselineShift(K view, @Nullable String value) { - view.setBaselineShift(value); - } - - public void setInlineSize(K view, @Nullable Double value) { - view.setInlineSize(value); - } - - public void setTextLength(K view, @Nullable Double value) { - view.setTextLength(value); - } - - public void setBaselineShift(K view, @Nullable Double value) { - view.setBaselineShift(value); - } } static class TextViewManager extends TextViewManagerAbstract @@ -940,15 +872,6 @@ class RenderableViewManager extends VirtualViewManager node.setSpacing(spacing); } - @Override - public void setStartOffset(TextPathView view, @Nullable String value) { - view.setStartOffset(value); - } - - public void setStartOffset(TextPathView view, @Nullable Double value) { - view.setStartOffset(value); - } - @ReactProp(name = "side") public void setSide(TextPathView node, @Nullable String side) { node.setSide(side); @@ -989,42 +912,6 @@ class RenderableViewManager extends VirtualViewManager node.setHeight(height); } - @Override - public void setX(ImageView view, @Nullable String value) { - view.setX(value); - } - - @Override - public void setY(ImageView view, @Nullable String value) { - view.setY(value); - } - - @Override - public void setWidth(ImageView view, @Nullable String value) { - view.setWidth(value); - } - - @Override - public void setHeight(ImageView view, @Nullable String value) { - view.setHeight(value); - } - - public void setX(ImageView view, @Nullable Double value) { - view.setX(value); - } - - public void setY(ImageView view, @Nullable Double value) { - view.setY(value); - } - - public void setWidth(ImageView view, @Nullable Double value) { - view.setWidth(value); - } - - public void setHeight(ImageView view, @Nullable Double value) { - view.setHeight(value); - } - @ReactProp(name = "src", customType = "ImageSource") public void setSrc(ImageView node, @Nullable ReadableMap src) { node.setSrc(src); @@ -1064,33 +951,6 @@ class RenderableViewManager extends VirtualViewManager public void setR(CircleView node, Dynamic r) { node.setR(r); } - - @Override - public void setCx(CircleView view, String value) { - view.setCx(value); - } - - public void setCx(CircleView view, Double value) { - view.setCx(value); - } - - @Override - public void setCy(CircleView view, String value) { - view.setCy(value); - } - - public void setCy(CircleView view, Double value) { - view.setCy(value); - } - - @Override - public void setR(CircleView view, String value) { - view.setR(value); - } - - public void setR(CircleView view, Double value) { - view.setR(value); - } } static class EllipseViewManager extends RenderableViewManager @@ -1121,42 +981,6 @@ class RenderableViewManager extends VirtualViewManager public void setRy(EllipseView node, Dynamic ry) { node.setRy(ry); } - - @Override - public void setCx(EllipseView view, @Nullable String value) { - view.setCx(value); - } - - @Override - public void setCy(EllipseView view, @Nullable String value) { - view.setCy(value); - } - - @Override - public void setRx(EllipseView view, @Nullable String value) { - view.setRx(value); - } - - @Override - public void setRy(EllipseView view, @Nullable String value) { - view.setRy(value); - } - - public void setCx(EllipseView view, @Nullable Double value) { - view.setCx(value); - } - - public void setCy(EllipseView view, @Nullable Double value) { - view.setCy(value); - } - - public void setRx(EllipseView view, @Nullable Double value) { - view.setRx(value); - } - - public void setRy(EllipseView view, @Nullable Double value) { - view.setRy(value); - } } static class LineViewManager extends RenderableViewManager @@ -1188,42 +1012,6 @@ class RenderableViewManager extends VirtualViewManager public void setY2(LineView node, Dynamic y2) { node.setY2(y2); } - - @Override - public void setX1(LineView view, @Nullable String value) { - view.setX1(value); - } - - @Override - public void setY1(LineView view, @Nullable String value) { - view.setY1(value); - } - - @Override - public void setX2(LineView view, @Nullable String value) { - view.setX2(value); - } - - @Override - public void setY2(LineView view, @Nullable String value) { - view.setY2(value); - } - - public void setX1(LineView view, @Nullable Double value) { - view.setX1(value); - } - - public void setY1(LineView view, @Nullable Double value) { - view.setY1(value); - } - - public void setX2(LineView view, @Nullable Double value) { - view.setX2(value); - } - - public void setY2(LineView view, @Nullable Double value) { - view.setY2(value); - } } static class RectViewManager extends RenderableViewManager @@ -1265,60 +1053,6 @@ class RenderableViewManager extends VirtualViewManager public void setRy(RectView node, Dynamic ry) { node.setRy(ry); } - - @Override - public void setX(RectView view, @Nullable String value) { - view.setX(value); - } - - @Override - public void setY(RectView view, @Nullable String value) { - view.setY(value); - } - - @Override - public void setHeight(RectView view, @Nullable String value) { - view.setHeight(value); - } - - @Override - public void setWidth(RectView view, @Nullable String value) { - view.setWidth(value); - } - - @Override - public void setRx(RectView view, @Nullable String value) { - view.setRx(value); - } - - @Override - public void setRy(RectView view, @Nullable String value) { - view.setRy(value); - } - - public void setX(RectView view, @Nullable Double value) { - view.setX(value); - } - - public void setY(RectView view, @Nullable Double value) { - view.setY(value); - } - - public void setHeight(RectView view, @Nullable Double value) { - view.setHeight(value); - } - - public void setWidth(RectView view, @Nullable Double value) { - view.setWidth(value); - } - - public void setRx(RectView view, @Nullable Double value) { - view.setRx(value); - } - - public void setRy(RectView view, @Nullable Double value) { - view.setRy(value); - } } static class ClipPathViewManager extends GroupViewManagerAbstract @@ -1357,42 +1091,6 @@ class RenderableViewManager extends VirtualViewManager node.setHref(href); } - @Override - public void setX(UseView view, @Nullable String value) { - view.setX(value); - } - - @Override - public void setY(UseView view, @Nullable String value) { - view.setY(value); - } - - @Override - public void setHeight(UseView view, @Nullable String value) { - view.setHeight(value); - } - - public void setWidth(UseView view, @Nullable Double value) { - view.setWidth(value); - } - - public void setX(UseView view, @Nullable Double value) { - view.setX(value); - } - - public void setY(UseView view, @Nullable Double value) { - view.setY(value); - } - - public void setHeight(UseView view, @Nullable Double value) { - view.setHeight(value); - } - - @Override - public void setWidth(UseView view, @Nullable String value) { - view.setWidth(value); - } - @ReactProp(name = "x") public void setX(UseView node, Dynamic x) { node.setX(x); @@ -1483,42 +1181,6 @@ class RenderableViewManager extends VirtualViewManager node.setHeight(height); } - @Override - public void setX(PatternView view, @Nullable String value) { - view.setX(value); - } - - @Override - public void setY(PatternView view, @Nullable String value) { - view.setY(value); - } - - @Override - public void setHeight(PatternView view, @Nullable String value) { - view.setHeight(value); - } - - @Override - public void setWidth(PatternView view, @Nullable String value) { - view.setWidth(value); - } - - public void setX(PatternView view, @Nullable Double value) { - view.setX(value); - } - - public void setY(PatternView view, @Nullable Double value) { - view.setY(value); - } - - public void setHeight(PatternView view, @Nullable Double value) { - view.setHeight(value); - } - - public void setWidth(PatternView view, @Nullable Double value) { - view.setWidth(value); - } - @ReactProp(name = "patternUnits") public void setPatternUnits(PatternView node, int patternUnits) { node.setPatternUnits(patternUnits); @@ -1594,42 +1256,6 @@ class RenderableViewManager extends VirtualViewManager node.setHeight(height); } - @Override - public void setX(MaskView view, @Nullable String value) { - view.setX(value); - } - - @Override - public void setY(MaskView view, @Nullable String value) { - view.setY(value); - } - - @Override - public void setHeight(MaskView view, @Nullable String value) { - view.setHeight(value); - } - - @Override - public void setWidth(MaskView view, @Nullable String value) { - view.setWidth(value); - } - - public void setX(MaskView view, @Nullable Double value) { - view.setX(value); - } - - public void setY(MaskView view, @Nullable Double value) { - view.setY(value); - } - - public void setHeight(MaskView view, @Nullable Double value) { - view.setHeight(value); - } - - public void setWidth(MaskView view, @Nullable Double value) { - view.setWidth(value); - } - @ReactProp(name = "maskUnits") public void setMaskUnits(MaskView node, int maskUnits) { node.setMaskUnits(maskUnits); @@ -1669,42 +1295,6 @@ class RenderableViewManager extends VirtualViewManager public void setHeight(ForeignObjectView node, Dynamic height) { node.setHeight(height); } - - @Override - public void setX(ForeignObjectView view, @Nullable String value) { - view.setX(value); - } - - @Override - public void setY(ForeignObjectView view, @Nullable String value) { - view.setY(value); - } - - @Override - public void setHeight(ForeignObjectView view, @Nullable String value) { - view.setHeight(value); - } - - @Override - public void setWidth(ForeignObjectView view, @Nullable String value) { - view.setWidth(value); - } - - public void setX(ForeignObjectView view, @Nullable Double value) { - view.setX(value); - } - - public void setY(ForeignObjectView view, @Nullable Double value) { - view.setY(value); - } - - public void setHeight(ForeignObjectView view, @Nullable Double value) { - view.setHeight(value); - } - - public void setWidth(ForeignObjectView view, @Nullable Double value) { - view.setWidth(value); - } } static class MarkerManager extends GroupViewManagerAbstract @@ -1736,42 +1326,6 @@ class RenderableViewManager extends VirtualViewManager node.setMarkerHeight(markerHeight); } - @Override - public void setRefX(MarkerView view, @Nullable String value) { - view.setRefX(value); - } - - @Override - public void setRefY(MarkerView view, @Nullable String value) { - view.setRefY(value); - } - - @Override - public void setMarkerHeight(MarkerView view, @Nullable String value) { - view.setMarkerHeight(value); - } - - @Override - public void setMarkerWidth(MarkerView view, @Nullable String value) { - view.setMarkerWidth(value); - } - - public void setRefX(MarkerView view, @Nullable Double value) { - view.setRefX(value); - } - - public void setRefY(MarkerView view, @Nullable Double value) { - view.setRefY(value); - } - - public void setMarkerHeight(MarkerView view, @Nullable Double value) { - view.setMarkerHeight(value); - } - - public void setMarkerWidth(MarkerView view, @Nullable Double value) { - view.setMarkerWidth(value); - } - @ReactProp(name = "markerUnits") public void setMarkerUnits(MarkerView node, String markerUnits) { node.setMarkerUnits(markerUnits); @@ -1843,42 +1397,6 @@ class RenderableViewManager extends VirtualViewManager node.setY2(y2); } - @Override - public void setX1(LinearGradientView view, @Nullable String value) { - view.setX1(value); - } - - @Override - public void setY1(LinearGradientView view, @Nullable String value) { - view.setY1(value); - } - - @Override - public void setX2(LinearGradientView view, @Nullable String value) { - view.setX2(value); - } - - @Override - public void setY2(LinearGradientView view, @Nullable String value) { - view.setY2(value); - } - - public void setX1(LinearGradientView view, @Nullable Double value) { - view.setX1(value); - } - - public void setY1(LinearGradientView view, @Nullable Double value) { - view.setY1(value); - } - - public void setX2(LinearGradientView view, @Nullable Double value) { - view.setX2(value); - } - - public void setY2(LinearGradientView view, @Nullable Double value) { - view.setY2(value); - } - @ReactProp(name = "gradient") public void setGradient(LinearGradientView node, ReadableArray gradient) { node.setGradient(gradient); @@ -1935,60 +1453,6 @@ class RenderableViewManager extends VirtualViewManager node.setCy(cy); } - @Override - public void setFx(RadialGradientView view, @Nullable String value) { - view.setFx(value); - } - - @Override - public void setFy(RadialGradientView view, @Nullable String value) { - view.setFy(value); - } - - @Override - public void setCx(RadialGradientView view, @Nullable String value) { - view.setCx(value); - } - - @Override - public void setCy(RadialGradientView view, @Nullable String value) { - view.setCy(value); - } - - @Override - public void setRx(RadialGradientView view, @Nullable String value) { - view.setRx(value); - } - - @Override - public void setRy(RadialGradientView view, @Nullable String value) { - view.setRy(value); - } - - public void setFx(RadialGradientView view, @Nullable Double value) { - view.setFx(value); - } - - public void setFy(RadialGradientView view, @Nullable Double value) { - view.setFy(value); - } - - public void setCx(RadialGradientView view, @Nullable Double value) { - view.setCx(value); - } - - public void setCy(RadialGradientView view, @Nullable Double value) { - view.setCy(value); - } - - public void setRx(RadialGradientView view, @Nullable Double value) { - view.setRx(value); - } - - public void setRy(RadialGradientView view, @Nullable Double value) { - view.setRy(value); - } - @ReactProp(name = "gradient") public void setGradient(RadialGradientView node, ReadableArray gradient) { node.setGradient(gradient); @@ -2039,12 +1503,7 @@ class RenderableViewManager extends VirtualViewManager } @ReactProp(name = "strokeDasharray") - public void setStrokeDasharray(T node, @Nullable ReadableArray strokeDasharray) { - node.setStrokeDasharray(strokeDasharray); - } - - @ReactProp(name = "strokeDasharray") - public void setStrokeDasharray(T node, @Nullable String strokeDasharray) { + public void setStrokeDasharray(T node, Dynamic strokeDasharray) { node.setStrokeDasharray(strokeDasharray); } @@ -2058,14 +1517,6 @@ class RenderableViewManager extends VirtualViewManager node.setStrokeWidth(strokeWidth); } - public void setStrokeWidth(T view, @Nullable String value) { - view.setStrokeWidth(value); - } - - public void setStrokeWidth(T view, @Nullable Double value) { - view.setStrokeWidth(value); - } - @ReactProp(name = "strokeMiterlimit", defaultFloat = 4f) public void setStrokeMiterlimit(T node, float strokeMiterlimit) { node.setStrokeMiterlimit(strokeMiterlimit); diff --git a/android/src/main/java/com/horcrux/svg/SvgView.java b/android/src/main/java/com/horcrux/svg/SvgView.java index b49dce2d..bfbbe332 100644 --- a/android/src/main/java/com/horcrux/svg/SvgView.java +++ b/android/src/main/java/com/horcrux/svg/SvgView.java @@ -232,36 +232,12 @@ public class SvgView extends ReactViewGroup implements ReactCompoundView, ReactC clearChildCache(); } - public void setBbWidth(String bbWidth) { - mbbWidth = SVGLength.from(bbWidth); - invalidate(); - clearChildCache(); - } - - public void setBbWidth(Double bbWidth) { - mbbWidth = SVGLength.from(bbWidth); - invalidate(); - clearChildCache(); - } - public void setBbHeight(Dynamic bbHeight) { mbbHeight = SVGLength.from(bbHeight); invalidate(); clearChildCache(); } - public void setBbHeight(String bbHeight) { - mbbHeight = SVGLength.from(bbHeight); - invalidate(); - clearChildCache(); - } - - public void setBbHeight(Double bbHeight) { - mbbHeight = SVGLength.from(bbHeight); - invalidate(); - clearChildCache(); - } - public void setAlign(String align) { mAlign = align; invalidate(); diff --git a/android/src/main/java/com/horcrux/svg/SvgViewManager.java b/android/src/main/java/com/horcrux/svg/SvgViewManager.java index cbe9a530..71a88e62 100644 --- a/android/src/main/java/com/horcrux/svg/SvgViewManager.java +++ b/android/src/main/java/com/horcrux/svg/SvgViewManager.java @@ -154,24 +154,6 @@ class SvgViewManager extends ReactViewManager node.setMeetOrSlice(meetOrSlice); } - @Override - public void setBbWidth(SvgView view, @Nullable String value) { - view.setBbWidth(value); - } - - public void setBbWidth(SvgView view, @Nullable Double value) { - view.setBbWidth(value); - } - - @Override - public void setBbHeight(SvgView view, @Nullable String value) { - view.setBbHeight(value); - } - - public void setBbHeight(SvgView view, @Nullable Double value) { - view.setBbHeight(value); - } - @ReactProp(name = ViewProps.POINTER_EVENTS) public void setPointerEvents(SvgView view, @Nullable String pointerEventsStr) { try { diff --git a/android/src/main/java/com/horcrux/svg/TextPathView.java b/android/src/main/java/com/horcrux/svg/TextPathView.java index d4eca228..22dab9a0 100644 --- a/android/src/main/java/com/horcrux/svg/TextPathView.java +++ b/android/src/main/java/com/horcrux/svg/TextPathView.java @@ -42,16 +42,6 @@ class TextPathView extends TextView { invalidate(); } - public void setStartOffset(String startOffset) { - mStartOffset = SVGLength.from(startOffset); - invalidate(); - } - - public void setStartOffset(Double startOffset) { - mStartOffset = SVGLength.from(startOffset); - invalidate(); - } - public void setMethod(@Nullable String method) { mMethod = TextPathMethod.valueOf(method); invalidate(); diff --git a/android/src/main/java/com/horcrux/svg/TextView.java b/android/src/main/java/com/horcrux/svg/TextView.java index dd73b8ee..280bda1d 100644 --- a/android/src/main/java/com/horcrux/svg/TextView.java +++ b/android/src/main/java/com/horcrux/svg/TextView.java @@ -61,31 +61,11 @@ class TextView extends GroupView { invalidate(); } - public void setInlineSize(String inlineSize) { - mInlineSize = SVGLength.from(inlineSize); - invalidate(); - } - - public void setInlineSize(Double inlineSize) { - mInlineSize = SVGLength.from(inlineSize); - invalidate(); - } - public void setTextLength(Dynamic length) { mTextLength = SVGLength.from(length); invalidate(); } - public void setTextLength(String length) { - mTextLength = SVGLength.from(length); - invalidate(); - } - - public void setTextLength(Double length) { - mTextLength = SVGLength.from(length); - invalidate(); - } - public void setLengthAdjust(@Nullable String adjustment) { mLengthAdjust = TextLengthAdjust.valueOf(adjustment); invalidate(); @@ -101,17 +81,8 @@ class TextView extends GroupView { invalidate(); } - public void setBaselineShift(String baselineShift) { - mBaselineShift = baselineShift; - invalidate(); - } - - public void setBaselineShift(Double baselineShift) { - mBaselineShift = String.valueOf(baselineShift); - invalidate(); - } - - public void setVerticalAlign(@Nullable String verticalAlign) { + public void setVerticalAlign(Dynamic dynamicVerticalAlign) { + String verticalAlign = SVGLength.toString(dynamicVerticalAlign); if (verticalAlign != null) { verticalAlign = verticalAlign.trim(); int i = verticalAlign.lastIndexOf(' '); @@ -137,51 +108,26 @@ class TextView extends GroupView { invalidate(); } - public void setRotate(ReadableArray rotate) { - mRotate = SVGLength.arrayFrom(rotate); - invalidate(); - } - public void setDeltaX(Dynamic deltaX) { mDeltaX = SVGLength.arrayFrom(deltaX); invalidate(); } - public void setDeltaX(ReadableArray deltaX) { - mDeltaX = SVGLength.arrayFrom(deltaX); - invalidate(); - } - public void setDeltaY(Dynamic deltaY) { mDeltaY = SVGLength.arrayFrom(deltaY); invalidate(); } - public void setDeltaY(ReadableArray deltaY) { - mDeltaY = SVGLength.arrayFrom(deltaY); - invalidate(); - } - public void setPositionX(Dynamic positionX) { mPositionX = SVGLength.arrayFrom(positionX); invalidate(); } - public void setPositionX(ReadableArray positionX) { - mPositionX = SVGLength.arrayFrom(positionX); - invalidate(); - } - public void setPositionY(Dynamic positionY) { mPositionY = SVGLength.arrayFrom(positionY); invalidate(); } - public void setPositionY(ReadableArray positionY) { - mPositionY = SVGLength.arrayFrom(positionY); - invalidate(); - } - @Override void draw(Canvas canvas, Paint paint, float opacity) { setupGlyphContext(canvas); diff --git a/android/src/main/java/com/horcrux/svg/UseView.java b/android/src/main/java/com/horcrux/svg/UseView.java index 83a7d36c..c3227caa 100644 --- a/android/src/main/java/com/horcrux/svg/UseView.java +++ b/android/src/main/java/com/horcrux/svg/UseView.java @@ -40,61 +40,21 @@ class UseView extends RenderableView { invalidate(); } - public void setX(String x) { - mX = SVGLength.from(x); - invalidate(); - } - - public void setX(Double x) { - mX = SVGLength.from(x); - invalidate(); - } - public void setY(Dynamic y) { mY = SVGLength.from(y); invalidate(); } - public void setY(String y) { - mY = SVGLength.from(y); - invalidate(); - } - - public void setY(Double y) { - mY = SVGLength.from(y); - invalidate(); - } - public void setWidth(Dynamic width) { mW = SVGLength.from(width); invalidate(); } - public void setWidth(String width) { - mW = SVGLength.from(width); - invalidate(); - } - - public void setWidth(Double width) { - mW = SVGLength.from(width); - invalidate(); - } - public void setHeight(Dynamic height) { mH = SVGLength.from(height); invalidate(); } - public void setHeight(String height) { - mH = SVGLength.from(height); - invalidate(); - } - - public void setHeight(Double height) { - mH = SVGLength.from(height); - invalidate(); - } - @Override void draw(Canvas canvas, Paint paint, float opacity) { VirtualView template = getSvgView().getDefinedTemplate(mHref); diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGCircleManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGCircleManagerDelegate.java index 61ccf50e..dc1b2207 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGCircleManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGCircleManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGCircleManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setCx(T view, @Nullable String value); - void setCx(T view, @Nullable Double value); - void setCy(T view, @Nullable String value); - void setCy(T view, @Nullable Double value); - void setR(T view, @Nullable String value); - void setR(T view, @Nullable Double value); + void setCx(T view, Dynamic value); + void setCy(T view, Dynamic value); + void setR(T view, Dynamic value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGClipPathManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGClipPathManagerDelegate.java index 8b8dd491..f1006e5d 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGClipPathManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGClipPathManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGClipPathManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setFontSize(T view, @Nullable String value); - void setFontSize(T view, @Nullable Double value); - void setFontWeight(T view, @Nullable String value); - void setFontWeight(T view, @Nullable Double value); - void setFont(T view, @Nullable ReadableMap value); + void setFontSize(T view, Dynamic value); + void setFontWeight(T view, Dynamic value); + void setFont(T view, Dynamic value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGEllipseManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGEllipseManagerDelegate.java index 4a9a216f..38523cce 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGEllipseManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGEllipseManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGEllipseManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setCx(T view, @Nullable String value); - void setCx(T view, @Nullable Double value); - void setCy(T view, @Nullable String value); - void setCy(T view, @Nullable Double value); - void setRx(T view, @Nullable String value); - void setRx(T view, @Nullable Double value); - void setRy(T view, @Nullable String value); - void setRy(T view, @Nullable Double value); + void setCx(T view, Dynamic value); + void setCy(T view, Dynamic value); + void setRx(T view, Dynamic value); + void setRy(T view, Dynamic value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGForeignObjectManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGForeignObjectManagerDelegate.java index 77c1eb55..ffc9eee7 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGForeignObjectManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGForeignObjectManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGForeignObjectManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setFontSize(T view, @Nullable String value); - void setFontSize(T view, @Nullable Double value); - void setFontWeight(T view, @Nullable String value); - void setFontWeight(T view, @Nullable Double value); - void setFont(T view, @Nullable ReadableMap value); - void setX(T view, @Nullable String value); - void setX(T view, @Nullable Double value); - void setY(T view, @Nullable String value); - void setY(T view, @Nullable Double value); - void setHeight(T view, @Nullable String value); - void setHeight(T view, @Nullable Double value); - void setWidth(T view, @Nullable String value); - void setWidth(T view, @Nullable Double value); + void setFontSize(T view, Dynamic value); + void setFontWeight(T view, Dynamic value); + void setFont(T view, Dynamic value); + void setX(T view, Dynamic value); + void setY(T view, Dynamic value); + void setHeight(T view, Dynamic value); + void setWidth(T view, Dynamic value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGGroupManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGGroupManagerDelegate.java index 2b577350..5919fbf1 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGGroupManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGGroupManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGGroupManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setFontSize(T view, @Nullable String value); - void setFontSize(T view, @Nullable Double value); - void setFontWeight(T view, @Nullable String value); - void setFontWeight(T view, @Nullable Double value); - void setFont(T view, @Nullable ReadableMap value); + void setFontSize(T view, Dynamic value); + void setFontWeight(T view, Dynamic value); + void setFont(T view, Dynamic value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGImageManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGImageManagerDelegate.java index eb6729fe..c0d90d2d 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGImageManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGImageManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGImageManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setX(T view, @Nullable String value); - void setX(T view, @Nullable Double value); - void setY(T view, @Nullable String value); - void setY(T view, @Nullable Double value); - void setWidth(T view, @Nullable String value); - void setWidth(T view, @Nullable Double value); - void setHeight(T view, @Nullable String value); - void setHeight(T view, @Nullable Double value); + void setX(T view, Dynamic value); + void setY(T view, Dynamic value); + void setWidth(T view, Dynamic value); + void setHeight(T view, Dynamic value); void setSrc(T view, @Nullable ReadableMap value); void setAlign(T view, @Nullable String value); void setMeetOrSlice(T view, int value); diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGLineManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGLineManagerDelegate.java index dcc8e3c0..b75db014 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGLineManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGLineManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGLineManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setX1(T view, @Nullable String value); - void setX1(T view, @Nullable Double value); - void setY1(T view, @Nullable String value); - void setY1(T view, @Nullable Double value); - void setX2(T view, @Nullable String value); - void setX2(T view, @Nullable Double value); - void setY2(T view, @Nullable String value); - void setY2(T view, @Nullable Double value); + void setX1(T view, Dynamic value); + void setY1(T view, Dynamic value); + void setX2(T view, Dynamic value); + void setY2(T view, Dynamic value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGLinearGradientManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGLinearGradientManagerDelegate.java index 76004a3d..a49f5993 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGLinearGradientManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGLinearGradientManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; @@ -59,40 +60,16 @@ public class RNSVGLinearGradientManagerDelegate { @@ -26,14 +27,10 @@ public interface RNSVGLinearGradientManagerInterface { void setResponsible(T view, boolean value); void setDisplay(T view, @Nullable String value); void setPointerEvents(T view, @Nullable String value); - void setX1(T view, @Nullable String value); - void setX1(T view, @Nullable Double value); - void setY1(T view, @Nullable String value); - void setY1(T view, @Nullable Double value); - void setX2(T view, @Nullable String value); - void setX2(T view, @Nullable Double value); - void setY2(T view, @Nullable String value); - void setY2(T view, @Nullable Double value); + void setX1(T view, Dynamic value); + void setY1(T view, Dynamic value); + void setX2(T view, Dynamic value); + void setY2(T view, Dynamic value); void setGradient(T view, @Nullable ReadableArray value); void setGradientUnits(T view, int value); void setGradientTransform(T view, @Nullable ReadableArray value); diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGMarkerManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGMarkerManagerDelegate.java index db7d47bb..4fe754aa 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGMarkerManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGMarkerManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGMarkerManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setFontSize(T view, @Nullable String value); - void setFontSize(T view, @Nullable Double value); - void setFontWeight(T view, @Nullable String value); - void setFontWeight(T view, @Nullable Double value); - void setFont(T view, @Nullable ReadableMap value); - void setRefX(T view, @Nullable String value); - void setRefX(T view, @Nullable Double value); - void setRefY(T view, @Nullable String value); - void setRefY(T view, @Nullable Double value); - void setMarkerHeight(T view, @Nullable String value); - void setMarkerHeight(T view, @Nullable Double value); - void setMarkerWidth(T view, @Nullable String value); - void setMarkerWidth(T view, @Nullable Double value); + void setFontSize(T view, Dynamic value); + void setFontWeight(T view, Dynamic value); + void setFont(T view, Dynamic value); + void setRefX(T view, Dynamic value); + void setRefY(T view, Dynamic value); + void setMarkerHeight(T view, Dynamic value); + void setMarkerWidth(T view, Dynamic value); void setMarkerUnits(T view, @Nullable String value); void setOrient(T view, @Nullable String value); void setMinX(T view, float value); diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGMaskManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGMaskManagerDelegate.java index 456ab0e8..bc2a92b2 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGMaskManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGMaskManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGMaskManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setFontSize(T view, @Nullable String value); - void setFontSize(T view, @Nullable Double value); - void setFontWeight(T view, @Nullable String value); - void setFontWeight(T view, @Nullable Double value); - void setFont(T view, @Nullable ReadableMap value); - void setX(T view, @Nullable String value); - void setX(T view, @Nullable Double value); - void setY(T view, @Nullable String value); - void setY(T view, @Nullable Double value); - void setHeight(T view, @Nullable String value); - void setHeight(T view, @Nullable Double value); - void setWidth(T view, @Nullable String value); - void setWidth(T view, @Nullable Double value); + void setFontSize(T view, Dynamic value); + void setFontWeight(T view, Dynamic value); + void setFont(T view, Dynamic value); + void setX(T view, Dynamic value); + void setY(T view, Dynamic value); + void setHeight(T view, Dynamic value); + void setWidth(T view, Dynamic value); void setMaskUnits(T view, int value); void setMaskContentUnits(T view, int value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGPathManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGPathManagerDelegate.java index e0e2179a..01f99ac7 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGPathManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGPathManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGPathManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGPatternManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGPatternManagerDelegate.java index 054d1efc..1d9eff8b 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGPatternManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGPatternManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGPatternManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setFontSize(T view, @Nullable String value); - void setFontSize(T view, @Nullable Double value); - void setFontWeight(T view, @Nullable String value); - void setFontWeight(T view, @Nullable Double value); - void setFont(T view, @Nullable ReadableMap value); - void setX(T view, @Nullable String value); - void setX(T view, @Nullable Double value); - void setY(T view, @Nullable String value); - void setY(T view, @Nullable Double value); - void setHeight(T view, @Nullable String value); - void setHeight(T view, @Nullable Double value); - void setWidth(T view, @Nullable String value); - void setWidth(T view, @Nullable Double value); + void setFontSize(T view, Dynamic value); + void setFontWeight(T view, Dynamic value); + void setFont(T view, Dynamic value); + void setX(T view, Dynamic value); + void setY(T view, Dynamic value); + void setHeight(T view, Dynamic value); + void setWidth(T view, Dynamic value); void setPatternUnits(T view, int value); void setPatternContentUnits(T view, int value); void setPatternTransform(T view, @Nullable ReadableArray value); diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGRadialGradientManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGRadialGradientManagerDelegate.java index 5726bd78..5ba33709 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGRadialGradientManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGRadialGradientManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; @@ -59,58 +60,22 @@ public class RNSVGRadialGradientManagerDelegate { @@ -26,18 +27,12 @@ public interface RNSVGRadialGradientManagerInterface { void setResponsible(T view, boolean value); void setDisplay(T view, @Nullable String value); void setPointerEvents(T view, @Nullable String value); - void setFx(T view, @Nullable String value); - void setFx(T view, @Nullable Double value); - void setFy(T view, @Nullable String value); - void setFy(T view, @Nullable Double value); - void setCx(T view, @Nullable String value); - void setCx(T view, @Nullable Double value); - void setCy(T view, @Nullable String value); - void setCy(T view, @Nullable Double value); - void setRx(T view, @Nullable String value); - void setRx(T view, @Nullable Double value); - void setRy(T view, @Nullable String value); - void setRy(T view, @Nullable Double value); + void setFx(T view, Dynamic value); + void setFy(T view, Dynamic value); + void setCx(T view, Dynamic value); + void setCy(T view, Dynamic value); + void setRx(T view, Dynamic value); + void setRy(T view, Dynamic value); void setGradient(T view, @Nullable ReadableArray value); void setGradientUnits(T view, int value); void setGradientTransform(T view, @Nullable ReadableArray value); diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGRectManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGRectManagerDelegate.java index 8dbb9830..3f4ca43c 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGRectManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGRectManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGRectManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setX(T view, @Nullable String value); - void setX(T view, @Nullable Double value); - void setY(T view, @Nullable String value); - void setY(T view, @Nullable Double value); - void setHeight(T view, @Nullable String value); - void setHeight(T view, @Nullable Double value); - void setWidth(T view, @Nullable String value); - void setWidth(T view, @Nullable Double value); - void setRx(T view, @Nullable String value); - void setRx(T view, @Nullable Double value); - void setRy(T view, @Nullable String value); - void setRy(T view, @Nullable Double value); + void setX(T view, Dynamic value); + void setY(T view, Dynamic value); + void setHeight(T view, Dynamic value); + void setWidth(T view, Dynamic value); + void setRx(T view, Dynamic value); + void setRy(T view, Dynamic value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerDelegate.java index 043ed13d..7e4e61ab 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSvgViewAndroidManagerDelegate.java @@ -12,6 +12,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.bridge.ColorPropConverter; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.BaseViewManagerInterface; @@ -24,34 +25,22 @@ public class RNSVGSvgViewAndroidManagerDelegate { - void setBbWidth(T view, @Nullable String value); - void setBbWidth(T view, @Nullable Double value); - void setBbHeight(T view, @Nullable String value); - void setBbHeight(T view, @Nullable Double value); + void setBbWidth(T view, Dynamic value); + void setBbHeight(T view, Dynamic value); void setMinX(T view, float value); void setMinY(T view, float value); void setVbWidth(T view, float value); diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSymbolManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSymbolManagerDelegate.java index 6ae4acf3..7d916b85 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSymbolManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGSymbolManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGSymbolManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setFontSize(T view, @Nullable String value); - void setFontSize(T view, @Nullable Double value); - void setFontWeight(T view, @Nullable String value); - void setFontWeight(T view, @Nullable Double value); - void setFont(T view, @Nullable ReadableMap value); + void setFontSize(T view, Dynamic value); + void setFontWeight(T view, Dynamic value); + void setFont(T view, Dynamic value); void setMinX(T view, float value); void setMinY(T view, float value); void setVbWidth(T view, float value); diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTSpanManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTSpanManagerDelegate.java index cb189572..f19635a2 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTSpanManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTSpanManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGTSpanManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setFontSize(T view, @Nullable String value); - void setFontSize(T view, @Nullable Double value); - void setFontWeight(T view, @Nullable String value); - void setFontWeight(T view, @Nullable Double value); - void setFont(T view, @Nullable ReadableMap value); - void setDx(T view, @Nullable ReadableArray value); - void setDy(T view, @Nullable ReadableArray value); - void setX(T view, @Nullable ReadableArray value); - void setY(T view, @Nullable ReadableArray value); - void setRotate(T view, @Nullable ReadableArray value); - void setInlineSize(T view, @Nullable String value); - void setInlineSize(T view, @Nullable Double value); - void setTextLength(T view, @Nullable String value); - void setTextLength(T view, @Nullable Double value); - void setBaselineShift(T view, @Nullable String value); - void setBaselineShift(T view, @Nullable Double value); + void setFontSize(T view, Dynamic value); + void setFontWeight(T view, Dynamic value); + void setFont(T view, Dynamic value); + void setDx(T view, Dynamic value); + void setDy(T view, Dynamic value); + void setX(T view, Dynamic value); + void setY(T view, Dynamic value); + void setRotate(T view, Dynamic value); + void setInlineSize(T view, Dynamic value); + void setTextLength(T view, Dynamic value); + void setBaselineShift(T view, Dynamic value); void setLengthAdjust(T view, @Nullable String value); void setAlignmentBaseline(T view, @Nullable String value); - void setVerticalAlign(T view, @Nullable String value); + void setVerticalAlign(T view, Dynamic value); void setContent(T view, @Nullable String value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTextManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTextManagerDelegate.java index eb741608..3baa804b 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTextManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTextManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGTextManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setFontSize(T view, @Nullable String value); - void setFontSize(T view, @Nullable Double value); - void setFontWeight(T view, @Nullable String value); - void setFontWeight(T view, @Nullable Double value); - void setFont(T view, @Nullable ReadableMap value); - void setDx(T view, @Nullable ReadableArray value); - void setDy(T view, @Nullable ReadableArray value); - void setX(T view, @Nullable ReadableArray value); - void setY(T view, @Nullable ReadableArray value); - void setRotate(T view, @Nullable ReadableArray value); - void setInlineSize(T view, @Nullable String value); - void setInlineSize(T view, @Nullable Double value); - void setTextLength(T view, @Nullable String value); - void setTextLength(T view, @Nullable Double value); - void setBaselineShift(T view, @Nullable String value); - void setBaselineShift(T view, @Nullable Double value); + void setFontSize(T view, Dynamic value); + void setFontWeight(T view, Dynamic value); + void setFont(T view, Dynamic value); + void setDx(T view, Dynamic value); + void setDy(T view, Dynamic value); + void setX(T view, Dynamic value); + void setY(T view, Dynamic value); + void setRotate(T view, Dynamic value); + void setInlineSize(T view, Dynamic value); + void setTextLength(T view, Dynamic value); + void setBaselineShift(T view, Dynamic value); void setLengthAdjust(T view, @Nullable String value); void setAlignmentBaseline(T view, @Nullable String value); - void setVerticalAlign(T view, @Nullable String value); + void setVerticalAlign(T view, Dynamic value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTextPathManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTextPathManagerDelegate.java index 64f3ce1f..4a90b5c6 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTextPathManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGTextPathManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGTextPathManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); - void setFontSize(T view, @Nullable String value); - void setFontSize(T view, @Nullable Double value); - void setFontWeight(T view, @Nullable String value); - void setFontWeight(T view, @Nullable Double value); - void setFont(T view, @Nullable ReadableMap value); - void setDx(T view, @Nullable ReadableArray value); - void setDy(T view, @Nullable ReadableArray value); - void setX(T view, @Nullable ReadableArray value); - void setY(T view, @Nullable ReadableArray value); - void setRotate(T view, @Nullable ReadableArray value); - void setInlineSize(T view, @Nullable String value); - void setInlineSize(T view, @Nullable Double value); - void setTextLength(T view, @Nullable String value); - void setTextLength(T view, @Nullable Double value); - void setBaselineShift(T view, @Nullable String value); - void setBaselineShift(T view, @Nullable Double value); + void setFontSize(T view, Dynamic value); + void setFontWeight(T view, Dynamic value); + void setFont(T view, Dynamic value); + void setDx(T view, Dynamic value); + void setDy(T view, Dynamic value); + void setX(T view, Dynamic value); + void setY(T view, Dynamic value); + void setRotate(T view, Dynamic value); + void setInlineSize(T view, Dynamic value); + void setTextLength(T view, Dynamic value); + void setBaselineShift(T view, Dynamic value); void setLengthAdjust(T view, @Nullable String value); void setAlignmentBaseline(T view, @Nullable String value); - void setVerticalAlign(T view, @Nullable String value); + void setVerticalAlign(T view, Dynamic value); void setHref(T view, @Nullable String value); void setSide(T view, @Nullable String value); void setMethod(T view, @Nullable String value); void setMidLine(T view, @Nullable String value); void setSpacing(T view, @Nullable String value); - void setStartOffset(T view, @Nullable String value); - void setStartOffset(T view, @Nullable Double value); + void setStartOffset(T view, Dynamic value); } diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGUseManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGUseManagerDelegate.java index 65c70f4d..c6eab3ae 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGUseManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSVGUseManagerDelegate.java @@ -11,6 +11,7 @@ package com.facebook.react.viewmanagers; import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManagerDelegate; @@ -75,13 +76,7 @@ public class RNSVGUseManagerDelegate { void setFillRule(T view, int value); void setStroke(T view, @Nullable ReadableMap value); void setStrokeOpacity(T view, float value); - void setStrokeWidth(T view, @Nullable String value); - void setStrokeWidth(T view, @Nullable Double value); + void setStrokeWidth(T view, Dynamic value); void setStrokeLinecap(T view, int value); void setStrokeLinejoin(T view, int value); - void setStrokeDasharray(T view, @Nullable ReadableArray value); - void setStrokeDasharray(T view, @Nullable String value); + void setStrokeDasharray(T view, Dynamic value); void setStrokeDashoffset(T view, float value); void setStrokeMiterlimit(T view, float value); void setVectorEffect(T view, int value); void setPropList(T view, @Nullable ReadableArray value); void setHref(T view, @Nullable String value); - void setX(T view, @Nullable String value); - void setX(T view, @Nullable Double value); - void setY(T view, @Nullable String value); - void setY(T view, @Nullable Double value); - void setHeight(T view, @Nullable String value); - void setHeight(T view, @Nullable Double value); - void setWidth(T view, @Nullable String value); - void setWidth(T view, @Nullable Double value); + void setX(T view, Dynamic value); + void setY(T view, Dynamic value); + void setHeight(T view, Dynamic value); + void setWidth(T view, Dynamic value); } diff --git a/apple/Elements/RNSVGForeignObject.mm b/apple/Elements/RNSVGForeignObject.mm index 45cb7bee..9c25659c 100644 --- a/apple/Elements/RNSVGForeignObject.mm +++ b/apple/Elements/RNSVGForeignObject.mm @@ -43,17 +43,21 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.x = RCTNSStringFromStringNilIfEmpty(newProps.x) - ? [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)] - : nil; - self.y = RCTNSStringFromStringNilIfEmpty(newProps.y) - ? [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y)] - : nil; - if (RCTNSStringFromStringNilIfEmpty(newProps.height)) { - self.foreignObjectheight = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.height)]; + id x = RNSVGConvertFollyDynamicToId(newProps.x); + if (x != nil) { + self.x = [RCTConvert RNSVGLength:x]; } - if (RCTNSStringFromStringNilIfEmpty(newProps.width)) { - self.foreignObjectwidth = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.width)]; + id y = RNSVGConvertFollyDynamicToId(newProps.y); + if (y != nil) { + self.y = [RCTConvert RNSVGLength:y]; + } + id height = RNSVGConvertFollyDynamicToId(newProps.height); + if (height != nil) { + self.foreignObjectheight = [RCTConvert RNSVGLength:height]; + } + id width = RNSVGConvertFollyDynamicToId(newProps.width); + if (width != nil) { + self.foreignObjectwidth = [RCTConvert RNSVGLength:width]; } setCommonGroupProps(newProps, self); diff --git a/apple/Elements/RNSVGImage.mm b/apple/Elements/RNSVGImage.mm index ac7928ab..4a193a50 100644 --- a/apple/Elements/RNSVGImage.mm +++ b/apple/Elements/RNSVGImage.mm @@ -72,13 +72,21 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.x = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)]; - self.y = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y)]; - if (RCTNSStringFromStringNilIfEmpty(newProps.height)) { - self.imageheight = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.height)]; + id x = RNSVGConvertFollyDynamicToId(newProps.x); + if (x != nil) { + self.x = [RCTConvert RNSVGLength:x]; } - if (RCTNSStringFromStringNilIfEmpty(newProps.width)) { - self.imagewidth = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.width)]; + id y = RNSVGConvertFollyDynamicToId(newProps.y); + if (y != nil) { + self.y = [RCTConvert RNSVGLength:y]; + } + id height = RNSVGConvertFollyDynamicToId(newProps.height); + if (height != nil) { + self.imageheight = [RCTConvert RNSVGLength:height]; + } + id width = RNSVGConvertFollyDynamicToId(newProps.width); + if (width != nil) { + self.imagewidth = [RCTConvert RNSVGLength:width]; } self.align = RCTNSStringFromStringNilIfEmpty(newProps.align); self.meetOrSlice = intToRNSVGVBMOS(newProps.meetOrSlice); diff --git a/apple/Elements/RNSVGLinearGradient.mm b/apple/Elements/RNSVGLinearGradient.mm index 6a20af88..bdd3d570 100644 --- a/apple/Elements/RNSVGLinearGradient.mm +++ b/apple/Elements/RNSVGLinearGradient.mm @@ -42,10 +42,22 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.x1 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x1)]; - self.y1 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y1)]; - self.x2 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x2)]; - self.y2 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y2)]; + id x1 = RNSVGConvertFollyDynamicToId(newProps.x1); + if (x1 != nil) { + self.x1 = [RCTConvert RNSVGLength:x1]; + } + id y1 = RNSVGConvertFollyDynamicToId(newProps.y1); + if (y1 != nil) { + self.y1 = [RCTConvert RNSVGLength:y1]; + } + id x2 = RNSVGConvertFollyDynamicToId(newProps.x2); + if (x2 != nil) { + self.x2 = [RCTConvert RNSVGLength:x2]; + } + id y2 = RNSVGConvertFollyDynamicToId(newProps.y2); + if (y2 != nil) { + self.y2 = [RCTConvert RNSVGLength:y2]; + } if (newProps.gradient.size() > 0) { NSMutableArray *gradientArray = [NSMutableArray new]; for (auto number : newProps.gradient) { diff --git a/apple/Elements/RNSVGMarker.mm b/apple/Elements/RNSVGMarker.mm index 88e4daf9..8e26e2ca 100644 --- a/apple/Elements/RNSVGMarker.mm +++ b/apple/Elements/RNSVGMarker.mm @@ -44,10 +44,22 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.refX = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.refX)]; - self.refY = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.refY)]; - self.markerHeight = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.markerHeight)]; - self.markerWidth = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.markerWidth)]; + id refX = RNSVGConvertFollyDynamicToId(newProps.refX); + if (refX != nil) { + self.refX = [RCTConvert RNSVGLength:refX]; + } + id refY = RNSVGConvertFollyDynamicToId(newProps.refY); + if (refY != nil) { + self.refY = [RCTConvert RNSVGLength:refY]; + } + id markerHeight = RNSVGConvertFollyDynamicToId(newProps.markerHeight); + if (markerHeight != nil) { + self.markerHeight = [RCTConvert RNSVGLength:markerHeight]; + } + id markerWidth = RNSVGConvertFollyDynamicToId(newProps.markerWidth); + if (markerWidth != nil) { + self.markerWidth = [RCTConvert RNSVGLength:markerWidth]; + } self.markerUnits = RCTNSStringFromStringNilIfEmpty(newProps.markerUnits); self.orient = RCTNSStringFromStringNilIfEmpty(newProps.orient); diff --git a/apple/Elements/RNSVGMask.mm b/apple/Elements/RNSVGMask.mm index c482e877..4113bf2e 100644 --- a/apple/Elements/RNSVGMask.mm +++ b/apple/Elements/RNSVGMask.mm @@ -43,14 +43,23 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.x = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)]; - self.y = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y)]; - if (RCTNSStringFromStringNilIfEmpty(newProps.height)) { - self.maskheight = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.height)]; + id x = RNSVGConvertFollyDynamicToId(newProps.x); + if (x != nil) { + self.x = [RCTConvert RNSVGLength:x]; } - if (RCTNSStringFromStringNilIfEmpty(newProps.width)) { - self.maskwidth = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.width)]; + id y = RNSVGConvertFollyDynamicToId(newProps.y); + if (y != nil) { + self.y = [RCTConvert RNSVGLength:y]; } + id maskheight = RNSVGConvertFollyDynamicToId(newProps.height); + if (maskheight != nil) { + self.maskheight = [RCTConvert RNSVGLength:maskheight]; + } + id maskwidth = RNSVGConvertFollyDynamicToId(newProps.width); + if (maskwidth != nil) { + self.maskwidth = [RCTConvert RNSVGLength:maskwidth]; + } + self.maskUnits = newProps.maskUnits == 0 ? kRNSVGUnitsObjectBoundingBox : kRNSVGUnitsUserSpaceOnUse; self.maskContentUnits = newProps.maskUnits == 0 ? kRNSVGUnitsObjectBoundingBox : kRNSVGUnitsUserSpaceOnUse; diff --git a/apple/Elements/RNSVGPattern.mm b/apple/Elements/RNSVGPattern.mm index 400dbed9..5c8c0c76 100644 --- a/apple/Elements/RNSVGPattern.mm +++ b/apple/Elements/RNSVGPattern.mm @@ -43,13 +43,21 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.x = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)]; - self.y = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y)]; - if (RCTNSStringFromStringNilIfEmpty(newProps.height)) { - self.patternheight = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.height)]; + id x = RNSVGConvertFollyDynamicToId(newProps.x); + if (x != nil) { + self.x = [RCTConvert RNSVGLength:x]; } - if (RCTNSStringFromStringNilIfEmpty(newProps.width)) { - self.patternwidth = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.width)]; + id y = RNSVGConvertFollyDynamicToId(newProps.y); + if (y != nil) { + self.y = [RCTConvert RNSVGLength:y]; + } + id patternheight = RNSVGConvertFollyDynamicToId(newProps.height); + if (patternheight != nil) { + self.patternheight = [RCTConvert RNSVGLength:patternheight]; + } + id patternwidth = RNSVGConvertFollyDynamicToId(newProps.width); + if (patternwidth != nil) { + self.patternwidth = [RCTConvert RNSVGLength:patternwidth]; } self.patternUnits = newProps.patternUnits == 0 ? kRNSVGUnitsObjectBoundingBox : kRNSVGUnitsUserSpaceOnUse; self.patternContentUnits = diff --git a/apple/Elements/RNSVGRadialGradient.mm b/apple/Elements/RNSVGRadialGradient.mm index 6be35092..00f8488d 100644 --- a/apple/Elements/RNSVGRadialGradient.mm +++ b/apple/Elements/RNSVGRadialGradient.mm @@ -40,12 +40,30 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.fx = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.fx)]; - self.fy = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.fy)]; - self.cx = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.cx)]; - self.cy = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.cy)]; - self.rx = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.rx)]; - self.ry = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.ry)]; + id fx = RNSVGConvertFollyDynamicToId(newProps.fx); + if (fx != nil) { + self.fx = [RCTConvert RNSVGLength:fx]; + } + id fy = RNSVGConvertFollyDynamicToId(newProps.fy); + if (fy != nil) { + self.fy = [RCTConvert RNSVGLength:fy]; + } + id cx = RNSVGConvertFollyDynamicToId(newProps.cx); + if (cx != nil) { + self.cx = [RCTConvert RNSVGLength:cx]; + } + id cy = RNSVGConvertFollyDynamicToId(newProps.cy); + if (cy != nil) { + self.cy = [RCTConvert RNSVGLength:cy]; + } + id rx = RNSVGConvertFollyDynamicToId(newProps.rx); + if (rx != nil) { + self.rx = [RCTConvert RNSVGLength:rx]; + } + id ry = RNSVGConvertFollyDynamicToId(newProps.ry); + if (ry != nil) { + self.ry = [RCTConvert RNSVGLength:ry]; + } if (newProps.gradient.size() > 0) { NSMutableArray *gradientArray = [NSMutableArray new]; for (auto number : newProps.gradient) { diff --git a/apple/Elements/RNSVGSvgView.mm b/apple/Elements/RNSVGSvgView.mm index e7319b35..3047b4b8 100644 --- a/apple/Elements/RNSVGSvgView.mm +++ b/apple/Elements/RNSVGSvgView.mm @@ -70,8 +70,14 @@ using namespace facebook::react; self.minY = newProps.minY; self.vbWidth = newProps.vbWidth; self.vbHeight = newProps.vbHeight; - self.bbWidth = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.bbWidth)]; - self.bbHeight = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.bbHeight)]; + id bbWidth = RNSVGConvertFollyDynamicToId(newProps.bbWidth); + if (bbWidth != nil) { + self.bbWidth = [RCTConvert RNSVGLength:bbWidth]; + } + id bbHeight = RNSVGConvertFollyDynamicToId(newProps.bbHeight); + if (bbHeight != nil) { + self.bbHeight = [RCTConvert RNSVGLength:bbHeight]; + } self.align = RCTNSStringFromStringNilIfEmpty(newProps.align); self.meetOrSlice = intToRNSVGVBMOS(newProps.meetOrSlice); if (RCTUIColorFromSharedColor(newProps.tintColor)) { diff --git a/apple/Elements/RNSVGUse.mm b/apple/Elements/RNSVGUse.mm index 3350713f..d55ed7ab 100644 --- a/apple/Elements/RNSVGUse.mm +++ b/apple/Elements/RNSVGUse.mm @@ -42,13 +42,21 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.x = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)]; - self.y = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y)]; - if (RCTNSStringFromStringNilIfEmpty(newProps.height)) { - self.useheight = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.height)]; + id x = RNSVGConvertFollyDynamicToId(newProps.x); + if (x != nil) { + self.x = [RCTConvert RNSVGLength:x]; } - if (RCTNSStringFromStringNilIfEmpty(newProps.width)) { - self.usewidth = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.width)]; + id y = RNSVGConvertFollyDynamicToId(newProps.y); + if (y != nil) { + self.y = [RCTConvert RNSVGLength:y]; + } + id useheight = RNSVGConvertFollyDynamicToId(newProps.height); + if (useheight != nil) { + self.useheight = [RCTConvert RNSVGLength:useheight]; + } + id usewidth = RNSVGConvertFollyDynamicToId(newProps.width); + if (usewidth != nil) { + self.usewidth = [RCTConvert RNSVGLength:usewidth]; } self.href = RCTNSStringFromStringNilIfEmpty(newProps.href); diff --git a/apple/Shapes/RNSVGCircle.mm b/apple/Shapes/RNSVGCircle.mm index 569e0028..5a025887 100644 --- a/apple/Shapes/RNSVGCircle.mm +++ b/apple/Shapes/RNSVGCircle.mm @@ -42,9 +42,18 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.cx = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.cx)]; - self.cy = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.cy)]; - self.r = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.r)]; + id cx = RNSVGConvertFollyDynamicToId(newProps.cx); + if (cx != nil) { + self.cx = [RCTConvert RNSVGLength:cx]; + } + id cy = RNSVGConvertFollyDynamicToId(newProps.cy); + if (cy != nil) { + self.cy = [RCTConvert RNSVGLength:cy]; + } + id r = RNSVGConvertFollyDynamicToId(newProps.r); + if (r != nil) { + self.r = [RCTConvert RNSVGLength:r]; + } setCommonRenderableProps(newProps, self); _props = std::static_pointer_cast(props); diff --git a/apple/Shapes/RNSVGEllipse.mm b/apple/Shapes/RNSVGEllipse.mm index f212445e..67340857 100644 --- a/apple/Shapes/RNSVGEllipse.mm +++ b/apple/Shapes/RNSVGEllipse.mm @@ -42,10 +42,22 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.cx = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.cx)]; - self.cy = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.cy)]; - self.rx = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.rx)]; - self.ry = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.ry)]; + id cx = RNSVGConvertFollyDynamicToId(newProps.cx); + if (cx != nil) { + self.cx = [RCTConvert RNSVGLength:cx]; + } + id cy = RNSVGConvertFollyDynamicToId(newProps.cy); + if (cy != nil) { + self.cy = [RCTConvert RNSVGLength:cy]; + } + id rx = RNSVGConvertFollyDynamicToId(newProps.rx); + if (rx != nil) { + self.rx = [RCTConvert RNSVGLength:rx]; + } + id ry = RNSVGConvertFollyDynamicToId(newProps.ry); + if (ry != nil) { + self.ry = [RCTConvert RNSVGLength:ry]; + } setCommonRenderableProps(newProps, self); _props = std::static_pointer_cast(props); diff --git a/apple/Shapes/RNSVGLine.mm b/apple/Shapes/RNSVGLine.mm index 868b948e..0c8594c1 100644 --- a/apple/Shapes/RNSVGLine.mm +++ b/apple/Shapes/RNSVGLine.mm @@ -42,10 +42,22 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.x1 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x1)]; - self.y1 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y1)]; - self.x2 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x2)]; - self.y2 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y2)]; + id x1 = RNSVGConvertFollyDynamicToId(newProps.x1); + if (x1 != nil) { + self.x1 = [RCTConvert RNSVGLength:x1]; + } + id y1 = RNSVGConvertFollyDynamicToId(newProps.y1); + if (y1 != nil) { + self.y1 = [RCTConvert RNSVGLength:y1]; + } + id x2 = RNSVGConvertFollyDynamicToId(newProps.x2); + if (x2 != nil) { + self.x2 = [RCTConvert RNSVGLength:x2]; + } + id y2 = RNSVGConvertFollyDynamicToId(newProps.y2); + if (y2 != nil) { + self.y2 = [RCTConvert RNSVGLength:y2]; + } setCommonRenderableProps(newProps, self); _props = std::static_pointer_cast(props); diff --git a/apple/Shapes/RNSVGRect.mm b/apple/Shapes/RNSVGRect.mm index 07190020..dfec0b64 100644 --- a/apple/Shapes/RNSVGRect.mm +++ b/apple/Shapes/RNSVGRect.mm @@ -42,16 +42,30 @@ using namespace facebook::react; { const auto &newProps = static_cast(*props); - self.x = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)]; - self.y = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y)]; - if (RCTNSStringFromStringNilIfEmpty(newProps.height)) { - self.rectheight = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.height)]; + id x = RNSVGConvertFollyDynamicToId(newProps.x); + if (x != nil) { + self.x = [RCTConvert RNSVGLength:x]; } - if (RCTNSStringFromStringNilIfEmpty(newProps.width)) { - self.rectwidth = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.width)]; + id y = RNSVGConvertFollyDynamicToId(newProps.y); + if (y != nil) { + self.y = [RCTConvert RNSVGLength:y]; + } + id rectheight = RNSVGConvertFollyDynamicToId(newProps.height); + if (rectheight != nil) { + self.rectheight = [RCTConvert RNSVGLength:rectheight]; + } + id rectwidth = RNSVGConvertFollyDynamicToId(newProps.width); + if (rectwidth != nil) { + self.rectwidth = [RCTConvert RNSVGLength:rectwidth]; + } + id rx = RNSVGConvertFollyDynamicToId(newProps.rx); + if (rx != nil) { + self.rx = [RCTConvert RNSVGLength:rx]; + } + id ry = RNSVGConvertFollyDynamicToId(newProps.ry); + if (ry != nil) { + self.ry = [RCTConvert RNSVGLength:ry]; } - self.rx = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.rx)]; - self.ry = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.ry)]; setCommonRenderableProps(newProps, self); _props = std::static_pointer_cast(props); diff --git a/apple/Text/RNSVGTextPath.mm b/apple/Text/RNSVGTextPath.mm index b5403f6a..2a064815 100644 --- a/apple/Text/RNSVGTextPath.mm +++ b/apple/Text/RNSVGTextPath.mm @@ -46,7 +46,10 @@ using namespace facebook::react; self.method = RCTNSStringFromStringNilIfEmpty(newProps.method); self.midLine = RCTNSStringFromStringNilIfEmpty(newProps.midLine); self.spacing = RCTNSStringFromStringNilIfEmpty(newProps.spacing); - self.startOffset = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.startOffset)]; + id startOffset = RNSVGConvertFollyDynamicToId(newProps.startOffset); + if (startOffset != nil) { + self.startOffset = [RCTConvert RNSVGLength:startOffset]; + } setCommonTextProps(newProps, self); _props = std::static_pointer_cast(props); diff --git a/apple/Utils/RNSVGFabricConversions.h b/apple/Utils/RNSVGFabricConversions.h index e256bfa4..0e0f521a 100644 --- a/apple/Utils/RNSVGFabricConversions.h +++ b/apple/Utils/RNSVGFabricConversions.h @@ -10,6 +10,50 @@ #import #import +#import + +// copied from RCTFollyConvert +static id RNSVGConvertFollyDynamicToId(const folly::dynamic &dyn) +{ + // I could imagine an implementation which avoids copies by wrapping the + // dynamic in a derived class of NSDictionary. We can do that if profiling + // implies it will help. + + switch (dyn.type()) { + case folly::dynamic::NULLT: + return nil; + case folly::dynamic::BOOL: + return dyn.getBool() ? @YES : @NO; + case folly::dynamic::INT64: + return @(dyn.getInt()); + case folly::dynamic::DOUBLE: + return @(dyn.getDouble()); + case folly::dynamic::STRING: + return [[NSString alloc] initWithBytes:dyn.c_str() length:dyn.size() encoding:NSUTF8StringEncoding]; + case folly::dynamic::ARRAY: { + NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:dyn.size()]; + for (const auto &elem : dyn) { + id value = RNSVGConvertFollyDynamicToId(elem); + if (value) { + [array addObject:value]; + } + } + return array; + } + case folly::dynamic::OBJECT: { + NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:dyn.size()]; + for (const auto &elem : dyn.items()) { + id key = RNSVGConvertFollyDynamicToId(elem.first); + id value = RNSVGConvertFollyDynamicToId(elem.second); + if (key && value) { + dict[key] = value; + } + } + return dict; + } + } +} + template RNSVGBrush *brushFromColorStruct(const T &fillObject) { @@ -87,19 +131,6 @@ void setCommonNodeProps(const T &nodeProps, RNSVGNode *node) node.accessibilityLabel = RCTNSStringFromStringNilIfEmpty(nodeProps.accessibilityLabel); } -static NSMutableArray *createLengthArrayFromStrings(const std::vector &stringArray) -{ - if (stringArray.empty()) { - return nil; - } - NSMutableArray *lengthArray = [NSMutableArray new]; - for (auto str : stringArray) { - RNSVGLength *lengthFromString = [RNSVGLength lengthWithString:RCTNSStringFromString(str)]; - [lengthArray addObject:lengthFromString]; - } - return lengthArray; -} - template void setCommonRenderableProps(const T &renderableProps, RNSVGRenderable *renderableNode) { @@ -109,14 +140,20 @@ void setCommonRenderableProps(const T &renderableProps, RNSVGRenderable *rendera renderableNode.fillRule = renderableProps.fillRule == 0 ? kRNSVGCGFCRuleEvenodd : kRNSVGCGFCRuleNonzero; renderableNode.stroke = brushFromColorStruct(renderableProps.stroke); renderableNode.strokeOpacity = renderableProps.strokeOpacity; - renderableNode.strokeWidth = [RNSVGLength lengthWithString:RCTNSStringFromString(renderableProps.strokeWidth)]; + id strokeWidth = RNSVGConvertFollyDynamicToId(renderableProps.strokeWidth); + if (strokeWidth != nil) { + renderableNode.strokeWidth = [RCTConvert RNSVGLength:strokeWidth]; + } renderableNode.strokeLinecap = renderableProps.strokeLinecap == 0 ? kCGLineCapButt : renderableProps.strokeLinecap == 1 ? kCGLineCapRound : kCGLineCapSquare; renderableNode.strokeLinejoin = renderableProps.strokeLinejoin == 0 ? kCGLineJoinMiter : renderableProps.strokeLinejoin == 1 ? kCGLineJoinRound : kCGLineJoinBevel; - renderableNode.strokeDasharray = createLengthArrayFromStrings(renderableProps.strokeDasharray); + id strokeDasharray = RNSVGConvertFollyDynamicToId(renderableProps.strokeDasharray); + if (strokeDasharray != nil) { + renderableNode.strokeDasharray = [RCTConvert RNSVGLengthArray:strokeDasharray]; + } renderableNode.strokeDashoffset = renderableProps.strokeDashoffset; renderableNode.strokeMiterlimit = renderableProps.strokeMiterlimit; renderableNode.vectorEffect = renderableProps.vectorEffect == 0 ? kRNSVGVectorEffectDefault @@ -132,53 +169,27 @@ void setCommonRenderableProps(const T &renderableProps, RNSVGRenderable *rendera } } -static void addValueToDict(NSMutableDictionary *dict, const std::string &value, NSString *key) -{ - NSString *valueOrNil = RCTNSStringFromStringNilIfEmpty(value); - if (valueOrNil) { - dict[key] = valueOrNil; - } -} - -template -NSDictionary *parseFontStruct(const T &fontStruct) -{ - NSMutableDictionary *fontDict = [NSMutableDictionary new]; - - // TODO: do it better maybe - addValueToDict(fontDict, fontStruct.fontStyle, @"fontStyle"); - addValueToDict(fontDict, fontStruct.fontVariant, @"fontVariant"); - addValueToDict(fontDict, fontStruct.fontWeight, @"fontWeight"); - addValueToDict(fontDict, fontStruct.fontStretch, @"fontStretch"); - addValueToDict(fontDict, fontStruct.fontSize, @"fontSize"); - addValueToDict(fontDict, fontStruct.fontFamily, @"fontFamily"); - addValueToDict(fontDict, fontStruct.textAnchor, @"textAnchor"); - addValueToDict(fontDict, fontStruct.textDecoration, @"textDecoration"); - addValueToDict(fontDict, fontStruct.letterSpacing, @"letterSpacing"); - addValueToDict(fontDict, fontStruct.wordSpacing, @"wordSpacing"); - addValueToDict(fontDict, fontStruct.kerning, @"kerning"); - addValueToDict(fontDict, fontStruct.fontFeatureSettings, @"fontFeatureSettings"); - addValueToDict(fontDict, fontStruct.fontVariantLigatures, @"fontVariantLigatures"); - addValueToDict(fontDict, fontStruct.fontVariationSettings, @"fontVariationSettings"); - return [NSDictionary dictionaryWithDictionary:fontDict]; -} - template void setCommonGroupProps(const T &groupProps, RNSVGGroup *groupNode) { setCommonRenderableProps(groupProps, groupNode); - if (RCTNSStringFromStringNilIfEmpty(groupProps.fontSize)) { - groupNode.font = @{@"fontSize" : RCTNSStringFromString(groupProps.fontSize)}; + id fontSize = RNSVGConvertFollyDynamicToId(groupProps.fontSize); + if (fontSize != nil) { + groupNode.font = @{@"fontSize" : fontSize}; } - if (RCTNSStringFromStringNilIfEmpty(groupProps.fontWeight)) { - groupNode.font = @{@"fontWeight" : RCTNSStringFromString(groupProps.fontWeight)}; + id fontWeight = RNSVGConvertFollyDynamicToId(groupProps.fontWeight); + if (fontWeight != nil) { + groupNode.font = @{@"fontWeight" : fontWeight}; } - NSDictionary *fontDict = parseFontStruct(groupProps.font); - if (groupNode.font == nil || fontDict.count > 0) { - // some of text's rendering logic requires that `font` is not nil so we always set it - // even if to an empty dict - groupNode.font = fontDict; + id font = RNSVGConvertFollyDynamicToId(groupProps.font); + if (font != nil) { + NSDictionary *fontDict = (NSDictionary *)font; + if (groupNode.font == nil || fontDict.count > 0) { + // some of text's rendering logic requires that `font` is not nil so we always set it + // even if to an empty dict + groupNode.font = fontDict; + } } } @@ -186,18 +197,43 @@ template void setCommonTextProps(const T &textProps, RNSVGText *textNode) { setCommonGroupProps(textProps, textNode); - textNode.deltaX = createLengthArrayFromStrings(textProps.dx); - textNode.deltaY = createLengthArrayFromStrings(textProps.dy); - if (!textProps.x.empty()) { - textNode.positionX = createLengthArrayFromStrings(textProps.x); + id deltaX = RNSVGConvertFollyDynamicToId(textProps.dx); + if (deltaX != nil) { + textNode.deltaX = [RCTConvert RNSVGLengthArray:deltaX]; } - if (!textProps.y.empty()) { - textNode.positionY = createLengthArrayFromStrings(textProps.y); + id deltaY = RNSVGConvertFollyDynamicToId(textProps.dy); + if (deltaY != nil) { + textNode.deltaY = [RCTConvert RNSVGLengthArray:deltaY]; + } + id positionX = RNSVGConvertFollyDynamicToId(textProps.x); + if (positionX != nil) { + textNode.positionX = [RCTConvert RNSVGLengthArray:positionX]; + } + id positionY = RNSVGConvertFollyDynamicToId(textProps.y); + if (positionY != nil) { + textNode.positionY = [RCTConvert RNSVGLengthArray:positionY]; + } + id rotate = RNSVGConvertFollyDynamicToId(textProps.rotate); + if (rotate != nil) { + textNode.rotate = [RCTConvert RNSVGLengthArray:rotate]; + } + id textLength = RNSVGConvertFollyDynamicToId(textProps.textLength); + if (textLength != nil) { + textNode.textLength = [RCTConvert RNSVGLength:textLength]; + } + id inlineSize = RNSVGConvertFollyDynamicToId(textProps.inlineSize); + if (inlineSize != nil) { + textNode.inlineSize = [RCTConvert RNSVGLength:inlineSize]; + } + id baselineShift = RNSVGConvertFollyDynamicToId(textProps.baselineShift); + if (baselineShift != nil) { + if ([baselineShift isKindOfClass:[NSString class]]) { + NSString *stringValue = (NSString *)baselineShift; + textNode.baselineShift = stringValue; + } else { + textNode.baselineShift = [NSString stringWithFormat:@"%f", [baselineShift doubleValue]]; + } } - textNode.rotate = createLengthArrayFromStrings(textProps.rotate); - textNode.inlineSize = [RNSVGLength lengthWithString:RCTNSStringFromString(textProps.inlineSize)]; - textNode.textLength = [RNSVGLength lengthWithString:RCTNSStringFromString(textProps.textLength)]; - textNode.baselineShift = RCTNSStringFromStringNilIfEmpty(textProps.baselineShift); textNode.lengthAdjust = RCTNSStringFromStringNilIfEmpty(textProps.lengthAdjust); textNode.alignmentBaseline = RCTNSStringFromStringNilIfEmpty(textProps.alignmentBaseline); } diff --git a/src/css/css.tsx b/src/css/css.tsx index 3e066fca..a6a7a222 100644 --- a/src/css/css.tsx +++ b/src/css/css.tsx @@ -688,7 +688,7 @@ export const inlineStyles: Middleware = function inlineStyles( }; export function SvgCss(props: XmlProps) { - const {xml, override, fallback, onError = err} = props; + const { xml, override, fallback, onError = err } = props; try { const ast = useMemo( () => (xml !== null ? parse(xml, inlineStyles) : null), @@ -721,7 +721,7 @@ export function SvgCssUri(props: UriProps) { if (isError) { return fallback ?? null; } - return ; + return ; } // Extending Component is required for Animated support. diff --git a/src/elements/Circle.tsx b/src/elements/Circle.tsx index 0cf58dc6..c3a242c6 100644 --- a/src/elements/Circle.tsx +++ b/src/elements/Circle.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { extract, stringifyPropsForFabric } from '../lib/extract/extractProps'; +import { extract } from '../lib/extract/extractProps'; import type { CommonPathProps, NumberProp } from '../lib/extract/types'; import Shape from './Shape'; import RNSVGCircle from '../fabric/CircleNativeComponent'; @@ -24,10 +24,7 @@ export default class Circle extends Shape { render() { const { props } = this; const { cx, cy, r } = props; - const circleProps = { - ...extract(this, props), - ...stringifyPropsForFabric({ cx, cy, r }), - }; + const circleProps = { ...extract(this, props), cx, cy, r }; return ( { const { cx, cy, rx, ry } = props; const ellipseProps = { ...extract(this, props), - ...stringifyPropsForFabric({ cx, cy, rx, ry }), + cx, + cy, + rx, + ry, }; return ( { render() { const { props } = this; const { x, y, width, height, children } = props; - const foreignObjectProps = stringifyPropsForFabric({ x, y, width, height }); + const foreignObjectProps = { x, y, width, height }; return ( diff --git a/src/elements/Image.tsx b/src/elements/Image.tsx index 59358e63..1a97260e 100644 --- a/src/elements/Image.tsx +++ b/src/elements/Image.tsx @@ -2,10 +2,7 @@ import * as React from 'react'; import type { ImageProps as RNImageProps, NativeMethods } from 'react-native'; import { Image } from 'react-native'; import { alignEnum, meetOrSliceTypes } from '../lib/extract/extractViewBox'; -import { - stringifyPropsForFabric, - withoutXY, -} from '../lib/extract/extractProps'; +import { withoutXY } from '../lib/extract/extractProps'; import type { CommonPathProps, NumberProp } from '../lib/extract/types'; import Shape from './Shape'; import RNSVGImage from '../fabric/ImageNativeComponent'; @@ -51,14 +48,11 @@ export default class SvgImage extends Shape { const align = modes[0]; const meetOrSlice: 'meet' | 'slice' | 'none' | string | undefined = modes[1]; - const stringifiedImageProps = stringifyPropsForFabric({ + const imageProps = { x, y, width, height, - }); - const imageProps = { - ...stringifiedImageProps, meetOrSlice: meetOrSliceTypes[meetOrSlice] || 0, align: alignEnum[align] || 'xMidYMid', src: !href diff --git a/src/elements/Line.tsx b/src/elements/Line.tsx index b8d88383..dceea9b8 100644 --- a/src/elements/Line.tsx +++ b/src/elements/Line.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { extract, stringifyPropsForFabric } from '../lib/extract/extractProps'; +import { extract } from '../lib/extract/extractProps'; import type { CommonPathProps, NumberProp } from '../lib/extract/types'; import Shape from './Shape'; import RNSVGLine from '../fabric/LineNativeComponent'; @@ -28,7 +28,10 @@ export default class Line extends Shape { const { x1, y1, x2, y2 } = props; const lineProps = { ...extract(this, props), - ...stringifyPropsForFabric({ x1, y1, x2, y2 }), + x1, + y1, + x2, + y2, }; return ( { render() { const { props } = this; const { x1, y1, x2, y2 } = props; - const linearGradientProps = stringifyPropsForFabric({ x1, y1, x2, y2 }); + const linearGradientProps = { x1, y1, x2, y2 }; return ( diff --git a/src/elements/Marker.tsx b/src/elements/Marker.tsx index 4980c510..cacfdbb4 100644 --- a/src/elements/Marker.tsx +++ b/src/elements/Marker.tsx @@ -4,7 +4,6 @@ import extractViewBox from '../lib/extract/extractViewBox'; import type { NumberProp } from '../lib/extract/types'; import Shape from './Shape'; import RNSVGMarker from '../fabric/MarkerNativeComponent'; -import { stringifyPropsForFabric } from '../lib/extract/extractProps'; import type { NativeMethods } from 'react-native'; export type MarkerUnits = 'strokeWidth' | 'userSpaceOnUse'; @@ -50,7 +49,7 @@ export default class Marker extends Shape { markerHeight, children, } = props; - const markerProps = stringifyPropsForFabric({ + const markerProps = { name: id, refX, refY, @@ -58,7 +57,7 @@ export default class Marker extends Shape { orient: String(orient), markerWidth, markerHeight, - }); + }; return ( { const { props } = this; const { x, y, width, height, maskUnits, maskContentUnits, children } = props; - const strigifiedMaskProps = stringifyPropsForFabric({ + const maskProps = { x, y, width, height, - }); - const maskProps = { maskUnits: maskUnits !== undefined ? units[maskUnits] : 0, maskContentUnits: maskContentUnits !== undefined ? units[maskContentUnits] : 1, @@ -52,7 +47,6 @@ export default class Mask extends Shape { this.refMethod(ref as (Mask & NativeMethods) | null)} {...withoutXY(this, props)} - {...strigifiedMaskProps} {...maskProps}> {children} diff --git a/src/elements/Pattern.tsx b/src/elements/Pattern.tsx index 6a77474b..8af7d542 100644 --- a/src/elements/Pattern.tsx +++ b/src/elements/Pattern.tsx @@ -6,7 +6,6 @@ import type { NumberProp, TransformProps, Units } from '../lib/extract/types'; import units from '../lib/units'; import Shape from './Shape'; import RNSVGPattern from '../fabric/PatternNativeComponent'; -import { stringifyPropsForFabric } from '../lib/extract/extractProps'; import type { NativeMethods } from 'react-native'; export interface PatternProps extends TransformProps { @@ -50,13 +49,11 @@ export default class Pattern extends Shape { preserveAspectRatio, } = props; const matrix = extractTransform(patternTransform || transform || props); - const strigifiedPatternProps = stringifyPropsForFabric({ + const patternProps = { x, y, width, height, - }); - const patternProps = { name: id, matrix, patternTransform: matrix, @@ -66,7 +63,6 @@ export default class Pattern extends Shape { return ( this.refMethod(ref as (Pattern & NativeMethods) | null)} - {...strigifiedPatternProps} {...patternProps} {...extractViewBox({ viewBox, preserveAspectRatio })}> {children} diff --git a/src/elements/RadialGradient.tsx b/src/elements/RadialGradient.tsx index a7e06ca9..d79ac0b7 100644 --- a/src/elements/RadialGradient.tsx +++ b/src/elements/RadialGradient.tsx @@ -4,7 +4,6 @@ import extractGradient from '../lib/extract/extractGradient'; import type { NumberProp, TransformProps, Units } from '../lib/extract/types'; import Shape from './Shape'; import RNSVGRadialGradient from '../fabric/RadialGradientNativeComponent'; -import { stringifyPropsForFabric } from '../lib/extract/extractProps'; import type { NativeMethods } from 'react-native'; export interface RadialGradientProps { @@ -33,14 +32,14 @@ export default class RadialGradient extends Shape { render() { const { props } = this; const { rx, ry, r, cx, cy, fx = cx, fy = cy } = props; - const radialGradientProps = stringifyPropsForFabric({ + const radialGradientProps = { fx, fy, rx: rx || r, ry: ry || r, cx, cy, - }); + }; return ( diff --git a/src/elements/Rect.tsx b/src/elements/Rect.tsx index 2fa44b03..b97320e4 100644 --- a/src/elements/Rect.tsx +++ b/src/elements/Rect.tsx @@ -1,8 +1,5 @@ import * as React from 'react'; -import { - stringifyPropsForFabric, - withoutXY, -} from '../lib/extract/extractProps'; +import { withoutXY } from '../lib/extract/extractProps'; import type { CommonPathProps, NumberProp } from '../lib/extract/types'; import Shape from './Shape'; import RNSVGRect from '../fabric/RectNativeComponent'; @@ -31,7 +28,7 @@ export default class Rect extends Shape { render() { const { props } = this; const { x, y, width, height, rx, ry } = props; - const rectProps = stringifyPropsForFabric({ x, y, width, height, rx, ry }); + const rectProps = { x, y, width, height, rx, ry }; return ( this.refMethod(ref as (Rect & NativeMethods) | null)} diff --git a/src/elements/Svg.tsx b/src/elements/Svg.tsx index cfcec1a3..9a6eac63 100644 --- a/src/elements/Svg.tsx +++ b/src/elements/Svg.tsx @@ -74,13 +74,6 @@ export default class Svg extends Shape { bbHeight?: NumberProp; } ) => { - const { width, height } = props; - if (width) { - props.bbWidth = String(width); - } - if (height) { - props.bbHeight = String(height); - } const { root } = this; root && root.setNativeProps(props); }; @@ -169,10 +162,10 @@ export default class Svg extends Shape { props.style = rootStyles.length > 1 ? rootStyles : defaultStyle; if (width != null) { - props.bbWidth = String(width); + props.bbWidth = width; } if (height != null) { - props.bbHeight = String(height); + props.bbHeight = height; } extractResponder(props, props, this as ResponderInstanceProps); diff --git a/src/elements/TextPath.tsx b/src/elements/TextPath.tsx index 42a1979d..bede4977 100644 --- a/src/elements/TextPath.tsx +++ b/src/elements/TextPath.tsx @@ -73,7 +73,7 @@ export default class TextPath extends Shape { ), { href: match, - startOffset: startOffset === null ? null : String(startOffset), + startOffset, method, spacing, side, diff --git a/src/elements/Use.tsx b/src/elements/Use.tsx index 2f9f8a15..35763ed1 100644 --- a/src/elements/Use.tsx +++ b/src/elements/Use.tsx @@ -1,9 +1,6 @@ import type { ReactNode } from 'react'; import * as React from 'react'; -import { - stringifyPropsForFabric, - withoutXY, -} from '../lib/extract/extractProps'; +import { withoutXY } from '../lib/extract/extractProps'; import type { CommonPathProps, NumberProp } from '../lib/extract/types'; import { idPattern } from '../lib/util'; import Shape from './Shape'; @@ -53,13 +50,13 @@ export default class Use extends Shape { '"' ); } - const useProps = stringifyPropsForFabric({ - href: match, + const useProps = { + href: match ?? undefined, x, y, width, height, - }); + }; return ( this.refMethod(ref as (Use & NativeMethods) | null)} diff --git a/src/fabric/AndroidSvgViewNativeComponent.ts b/src/fabric/AndroidSvgViewNativeComponent.ts index 5b6e227e..56eac79e 100644 --- a/src/fabric/AndroidSvgViewNativeComponent.ts +++ b/src/fabric/AndroidSvgViewNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp } from '../lib/extract/types'; + type NativeBackgroundProp = Readonly<{ type?: string; color?: Float; @@ -22,8 +25,8 @@ type HitSlop = Readonly<{ }>; interface NativeProps extends ViewProps { - bbWidth?: string; - bbHeight?: string; + bbWidth?: UnsafeMixed; + bbHeight?: UnsafeMixed; minX?: Float; minY?: Float; vbWidth?: Float; diff --git a/src/fabric/CircleNativeComponent.ts b/src/fabric/CircleNativeComponent.ts index 5fee59ae..40f2b945 100644 --- a/src/fabric/CircleNativeComponent.ts +++ b/src/fabric/CircleNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,10 +37,10 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; @@ -48,9 +51,9 @@ interface NativeProps extends ViewProps, SvgNodeCommonProps, SvgRenderableCommonProps { - cx?: string; - cy?: string; - r?: string; + cx?: UnsafeMixed; + cy?: UnsafeMixed; + r?: UnsafeMixed; } export default codegenNativeComponent('RNSVGCircle'); diff --git a/src/fabric/ClipPathNativeComponent.ts b/src/fabric/ClipPathNativeComponent.ts index 04461cc5..c009f91f 100644 --- a/src/fabric/ClipPathNativeComponent.ts +++ b/src/fabric/ClipPathNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import { UnsafeMixed } from './codegenUtils'; +import { FontObject, NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,37 +37,20 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; propList?: ReadonlyArray; } -type FontObject = Readonly<{ - fontStyle?: string; - fontVariant?: string; - fontWeight?: string; - fontStretch?: string; - fontSize?: string; - fontFamily?: string; - textAnchor?: string; - textDecoration?: string; - letterSpacing?: string; - wordSpacing?: string; - kerning?: string; - fontFeatureSettings?: string; - fontVariantLigatures?: string; - fontVariationSettings?: string; -}>; - interface SvgGroupCommonProps { - fontSize?: string; - fontWeight?: string; - font?: FontObject; + fontSize?: UnsafeMixed; + fontWeight?: UnsafeMixed; + font?: UnsafeMixed; } interface NativeProps diff --git a/src/fabric/EllipseNativeComponent.ts b/src/fabric/EllipseNativeComponent.ts index ee050754..6233360e 100644 --- a/src/fabric/EllipseNativeComponent.ts +++ b/src/fabric/EllipseNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,10 +37,10 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; @@ -48,10 +51,10 @@ interface NativeProps extends ViewProps, SvgNodeCommonProps, SvgRenderableCommonProps { - cx?: string; - cy?: string; - rx?: string; - ry?: string; + cx?: UnsafeMixed; + cy?: UnsafeMixed; + rx?: UnsafeMixed; + ry?: UnsafeMixed; } export default codegenNativeComponent('RNSVGEllipse'); diff --git a/src/fabric/ForeignObjectNativeComponent.ts b/src/fabric/ForeignObjectNativeComponent.ts index e1cbf01e..fe5192bd 100644 --- a/src/fabric/ForeignObjectNativeComponent.ts +++ b/src/fabric/ForeignObjectNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp, FontObject } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,37 +37,20 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; propList?: ReadonlyArray; } -type FontObject = Readonly<{ - fontStyle?: string; - fontVariant?: string; - fontWeight?: string; - fontStretch?: string; - fontSize?: string; - fontFamily?: string; - textAnchor?: string; - textDecoration?: string; - letterSpacing?: string; - wordSpacing?: string; - kerning?: string; - fontFeatureSettings?: string; - fontVariantLigatures?: string; - fontVariationSettings?: string; -}>; - interface SvgGroupCommonProps { - fontSize?: string; - fontWeight?: string; - font?: FontObject; + fontSize?: UnsafeMixed; + fontWeight?: UnsafeMixed; + font?: UnsafeMixed; } interface NativeProps @@ -72,10 +58,10 @@ interface NativeProps SvgNodeCommonProps, SvgRenderableCommonProps, SvgGroupCommonProps { - x?: string; - y?: string; - height?: string; - width?: string; + x?: UnsafeMixed; + y?: UnsafeMixed; + height?: UnsafeMixed; + width?: UnsafeMixed; } export default codegenNativeComponent('RNSVGForeignObject'); diff --git a/src/fabric/GroupNativeComponent.ts b/src/fabric/GroupNativeComponent.ts index 3ddd11b7..0c0f6c69 100644 --- a/src/fabric/GroupNativeComponent.ts +++ b/src/fabric/GroupNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { FontObject, NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,37 +37,20 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; propList?: ReadonlyArray; } -type FontObject = Readonly<{ - fontStyle?: string; - fontVariant?: string; - fontWeight?: string; - fontStretch?: string; - fontSize?: string; - fontFamily?: string; - textAnchor?: string; - textDecoration?: string; - letterSpacing?: string; - wordSpacing?: string; - kerning?: string; - fontFeatureSettings?: string; - fontVariantLigatures?: string; - fontVariationSettings?: string; -}>; - interface SvgGroupCommonProps { - fontSize?: string; - fontWeight?: string; - font?: FontObject; + fontSize?: UnsafeMixed; + fontWeight?: UnsafeMixed; + font?: UnsafeMixed; } interface NativeProps diff --git a/src/fabric/IOSSvgViewNativeComponent.ts b/src/fabric/IOSSvgViewNativeComponent.ts index f3c01d80..efb6256b 100644 --- a/src/fabric/IOSSvgViewNativeComponent.ts +++ b/src/fabric/IOSSvgViewNativeComponent.ts @@ -3,9 +3,12 @@ import type { ColorValue } from 'react-native'; import type { Float, Int32 } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp } from '../lib/extract/types'; + interface NativeProps extends ViewProps { - bbWidth?: string; - bbHeight?: string; + bbWidth?: UnsafeMixed; + bbHeight?: UnsafeMixed; minX?: Float; minY?: Float; vbWidth?: Float; diff --git a/src/fabric/ImageNativeComponent.ts b/src/fabric/ImageNativeComponent.ts index ba1a4327..38941660 100644 --- a/src/fabric/ImageNativeComponent.ts +++ b/src/fabric/ImageNativeComponent.ts @@ -11,6 +11,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -38,10 +41,10 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; @@ -52,10 +55,10 @@ interface NativeProps extends ViewProps, SvgNodeCommonProps, SvgRenderableCommonProps { - x?: string; - y?: string; - width?: string; - height?: string; + x?: UnsafeMixed; + y?: UnsafeMixed; + width?: UnsafeMixed; + height?: UnsafeMixed; src?: ImageSource | null; align?: string; meetOrSlice?: Int32; diff --git a/src/fabric/LineNativeComponent.ts b/src/fabric/LineNativeComponent.ts index 6b2fb88d..e873047a 100644 --- a/src/fabric/LineNativeComponent.ts +++ b/src/fabric/LineNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,10 +37,10 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; @@ -48,10 +51,10 @@ interface NativeProps extends ViewProps, SvgNodeCommonProps, SvgRenderableCommonProps { - x1?: string; - y1?: string; - x2?: string; - y2?: string; + x1?: UnsafeMixed; + y1?: UnsafeMixed; + x2?: UnsafeMixed; + y2?: UnsafeMixed; } export default codegenNativeComponent('RNSVGLine'); diff --git a/src/fabric/LinearGradientNativeComponent.ts b/src/fabric/LinearGradientNativeComponent.ts index f648ca23..ee39834d 100644 --- a/src/fabric/LinearGradientNativeComponent.ts +++ b/src/fabric/LinearGradientNativeComponent.ts @@ -6,6 +6,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -22,10 +25,10 @@ interface SvgNodeCommonProps { } interface NativeProps extends ViewProps, SvgNodeCommonProps { - x1?: string; - y1?: string; - x2?: string; - y2?: string; + x1?: UnsafeMixed; + y1?: UnsafeMixed; + x2?: UnsafeMixed; + y2?: UnsafeMixed; gradient?: ReadonlyArray; gradientUnits?: Int32; gradientTransform?: ReadonlyArray | null; diff --git a/src/fabric/MarkerNativeComponent.ts b/src/fabric/MarkerNativeComponent.ts index e4aa19c6..416817e7 100644 --- a/src/fabric/MarkerNativeComponent.ts +++ b/src/fabric/MarkerNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { FontObject, NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,37 +37,20 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; propList?: ReadonlyArray; } -type FontObject = Readonly<{ - fontStyle?: string; - fontVariant?: string; - fontWeight?: string; - fontStretch?: string; - fontSize?: string; - fontFamily?: string; - textAnchor?: string; - textDecoration?: string; - letterSpacing?: string; - wordSpacing?: string; - kerning?: string; - fontFeatureSettings?: string; - fontVariantLigatures?: string; - fontVariationSettings?: string; -}>; - interface SvgGroupCommonProps { - fontSize?: string; - fontWeight?: string; - font?: FontObject; + fontSize?: UnsafeMixed; + fontWeight?: UnsafeMixed; + font?: UnsafeMixed; } interface NativeProps @@ -72,10 +58,10 @@ interface NativeProps SvgNodeCommonProps, SvgRenderableCommonProps, SvgGroupCommonProps { - refX?: string; - refY?: string; - markerHeight?: string; - markerWidth?: string; + refX?: UnsafeMixed; + refY?: UnsafeMixed; + markerHeight?: UnsafeMixed; + markerWidth?: UnsafeMixed; markerUnits?: string; orient?: string; minX?: Float; diff --git a/src/fabric/MaskNativeComponent.ts b/src/fabric/MaskNativeComponent.ts index a32edcab..6b20ae70 100644 --- a/src/fabric/MaskNativeComponent.ts +++ b/src/fabric/MaskNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { FontObject, NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,37 +37,20 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; propList?: ReadonlyArray; } -type FontObject = Readonly<{ - fontStyle?: string; - fontVariant?: string; - fontWeight?: string; - fontStretch?: string; - fontSize?: string; - fontFamily?: string; - textAnchor?: string; - textDecoration?: string; - letterSpacing?: string; - wordSpacing?: string; - kerning?: string; - fontFeatureSettings?: string; - fontVariantLigatures?: string; - fontVariationSettings?: string; -}>; - interface SvgGroupCommonProps { - fontSize?: string; - fontWeight?: string; - font?: FontObject; + fontSize?: UnsafeMixed; + fontWeight?: UnsafeMixed; + font?: UnsafeMixed; } interface NativeProps @@ -72,10 +58,10 @@ interface NativeProps SvgNodeCommonProps, SvgRenderableCommonProps, SvgGroupCommonProps { - x?: string; - y?: string; - height?: string; - width?: string; + x?: UnsafeMixed; + y?: UnsafeMixed; + height?: UnsafeMixed; + width?: UnsafeMixed; maskUnits?: Int32; maskContentUnits?: Int32; } diff --git a/src/fabric/PathNativeComponent.ts b/src/fabric/PathNativeComponent.ts index 3b8edf91..be5dae35 100644 --- a/src/fabric/PathNativeComponent.ts +++ b/src/fabric/PathNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,10 +37,10 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; diff --git a/src/fabric/PatternNativeComponent.ts b/src/fabric/PatternNativeComponent.ts index cdcb968f..05e019fd 100644 --- a/src/fabric/PatternNativeComponent.ts +++ b/src/fabric/PatternNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { FontObject, NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,37 +37,20 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; propList?: ReadonlyArray; } -type FontObject = Readonly<{ - fontStyle?: string; - fontVariant?: string; - fontWeight?: string; - fontStretch?: string; - fontSize?: string; - fontFamily?: string; - textAnchor?: string; - textDecoration?: string; - letterSpacing?: string; - wordSpacing?: string; - kerning?: string; - fontFeatureSettings?: string; - fontVariantLigatures?: string; - fontVariationSettings?: string; -}>; - interface SvgGroupCommonProps { - fontSize?: string; - fontWeight?: string; - font?: FontObject; + fontSize?: UnsafeMixed; + fontWeight?: UnsafeMixed; + font?: UnsafeMixed; } interface NativeProps @@ -72,10 +58,10 @@ interface NativeProps SvgNodeCommonProps, SvgRenderableCommonProps, SvgGroupCommonProps { - x?: string; - y?: string; - height?: string; - width?: string; + x?: UnsafeMixed; + y?: UnsafeMixed; + height?: UnsafeMixed; + width?: UnsafeMixed; patternUnits?: Int32; patternContentUnits?: Int32; patternTransform?: ReadonlyArray | null; diff --git a/src/fabric/RadialGradientNativeComponent.ts b/src/fabric/RadialGradientNativeComponent.ts index afbca466..6a0ca935 100644 --- a/src/fabric/RadialGradientNativeComponent.ts +++ b/src/fabric/RadialGradientNativeComponent.ts @@ -6,6 +6,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -22,12 +25,12 @@ interface SvgNodeCommonProps { } interface NativeProps extends ViewProps, SvgNodeCommonProps { - fx?: string; - fy?: string; - cx?: string; - cy?: string; - rx?: string; - ry?: string; + fx?: UnsafeMixed; + fy?: UnsafeMixed; + cx?: UnsafeMixed; + cy?: UnsafeMixed; + rx?: UnsafeMixed; + ry?: UnsafeMixed; gradient?: ReadonlyArray; gradientUnits?: Int32; gradientTransform?: ReadonlyArray | null; diff --git a/src/fabric/RectNativeComponent.ts b/src/fabric/RectNativeComponent.ts index 8a88ba49..6db2e304 100644 --- a/src/fabric/RectNativeComponent.ts +++ b/src/fabric/RectNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,10 +37,10 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; @@ -48,12 +51,12 @@ interface NativeProps extends ViewProps, SvgNodeCommonProps, SvgRenderableCommonProps { - x?: string; - y?: string; - height?: string; - width?: string; - rx?: string; - ry?: string; + x?: UnsafeMixed; + y?: UnsafeMixed; + height?: UnsafeMixed; + width?: UnsafeMixed; + rx?: UnsafeMixed; + ry?: UnsafeMixed; } export default codegenNativeComponent('RNSVGRect'); diff --git a/src/fabric/SymbolNativeComponent.ts b/src/fabric/SymbolNativeComponent.ts index 4694badc..52abe543 100644 --- a/src/fabric/SymbolNativeComponent.ts +++ b/src/fabric/SymbolNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { FontObject, NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,37 +37,20 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; propList?: ReadonlyArray; } -type FontObject = Readonly<{ - fontStyle?: string; - fontVariant?: string; - fontWeight?: string; - fontStretch?: string; - fontSize?: string; - fontFamily?: string; - textAnchor?: string; - textDecoration?: string; - letterSpacing?: string; - wordSpacing?: string; - kerning?: string; - fontFeatureSettings?: string; - fontVariantLigatures?: string; - fontVariationSettings?: string; -}>; - interface SvgGroupCommonProps { - fontSize?: string; - fontWeight?: string; - font?: FontObject; + fontSize?: UnsafeMixed; + fontWeight?: UnsafeMixed; + font?: UnsafeMixed; } interface NativeProps diff --git a/src/fabric/TSpanNativeComponent.ts b/src/fabric/TSpanNativeComponent.ts index 02a0c7c7..80246c78 100644 --- a/src/fabric/TSpanNativeComponent.ts +++ b/src/fabric/TSpanNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { FontObject, NumberArray, NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,51 +37,34 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; propList?: ReadonlyArray; } -type FontObject = Readonly<{ - fontStyle?: string; - fontVariant?: string; - fontWeight?: string; - fontStretch?: string; - fontSize?: string; - fontFamily?: string; - textAnchor?: string; - textDecoration?: string; - letterSpacing?: string; - wordSpacing?: string; - kerning?: string; - fontFeatureSettings?: string; - fontVariantLigatures?: string; - fontVariationSettings?: string; -}>; - interface SvgGroupCommonProps { - fontSize?: string; - fontWeight?: string; - font?: FontObject; + fontSize?: UnsafeMixed; + fontWeight?: UnsafeMixed; + font?: UnsafeMixed; } interface SvgTextCommonProps { - dx?: ReadonlyArray; - dy?: ReadonlyArray; - x?: ReadonlyArray; - y?: ReadonlyArray; - rotate?: ReadonlyArray; - inlineSize?: string; - textLength?: string; - baselineShift?: string; + dx?: UnsafeMixed; + dy?: UnsafeMixed; + x?: UnsafeMixed; + y?: UnsafeMixed; + rotate?: UnsafeMixed; + inlineSize?: UnsafeMixed; + textLength?: UnsafeMixed; + baselineShift?: UnsafeMixed; lengthAdjust?: string; alignmentBaseline?: string; - verticalAlign?: string; + verticalAlign?: UnsafeMixed; } interface NativeProps diff --git a/src/fabric/TextNativeComponent.ts b/src/fabric/TextNativeComponent.ts index eb447673..bbeba338 100644 --- a/src/fabric/TextNativeComponent.ts +++ b/src/fabric/TextNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { FontObject, NumberArray, NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,51 +37,34 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; propList?: ReadonlyArray; } -type FontObject = Readonly<{ - fontStyle?: string; - fontVariant?: string; - fontWeight?: string; - fontStretch?: string; - fontSize?: string; - fontFamily?: string; - textAnchor?: string; - textDecoration?: string; - letterSpacing?: string; - wordSpacing?: string; - kerning?: string; - fontFeatureSettings?: string; - fontVariantLigatures?: string; - fontVariationSettings?: string; -}>; - interface SvgGroupCommonProps { - fontSize?: string; - fontWeight?: string; - font?: FontObject; + fontSize?: UnsafeMixed; + fontWeight?: UnsafeMixed; + font?: UnsafeMixed; } interface SvgTextCommonProps { - dx?: ReadonlyArray; - dy?: ReadonlyArray; - x?: ReadonlyArray; - y?: ReadonlyArray; - rotate?: ReadonlyArray; - inlineSize?: string; - textLength?: string; - baselineShift?: string; + dx?: UnsafeMixed; + dy?: UnsafeMixed; + x?: UnsafeMixed; + y?: UnsafeMixed; + rotate?: UnsafeMixed; + inlineSize?: UnsafeMixed; + textLength?: UnsafeMixed; + baselineShift?: UnsafeMixed; lengthAdjust?: string; alignmentBaseline?: string; - verticalAlign?: string; + verticalAlign?: UnsafeMixed; } interface NativeProps diff --git a/src/fabric/TextPathNativeComponent.ts b/src/fabric/TextPathNativeComponent.ts index 80a8d5e6..2e509b2c 100644 --- a/src/fabric/TextPathNativeComponent.ts +++ b/src/fabric/TextPathNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { FontObject, NumberArray, NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,51 +37,34 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; propList?: ReadonlyArray; } -type FontObject = Readonly<{ - fontStyle?: string; - fontVariant?: string; - fontWeight?: string; - fontStretch?: string; - fontSize?: string; - fontFamily?: string; - textAnchor?: string; - textDecoration?: string; - letterSpacing?: string; - wordSpacing?: string; - kerning?: string; - fontFeatureSettings?: string; - fontVariantLigatures?: string; - fontVariationSettings?: string; -}>; - interface SvgGroupCommonProps { - fontSize?: string; - fontWeight?: string; - font?: FontObject; + fontSize?: UnsafeMixed; + fontWeight?: UnsafeMixed; + font?: UnsafeMixed; } interface SvgTextCommonProps { - dx?: ReadonlyArray; - dy?: ReadonlyArray; - x?: ReadonlyArray; - y?: ReadonlyArray; - rotate?: ReadonlyArray; - inlineSize?: string; - textLength?: string; - baselineShift?: string; + dx?: UnsafeMixed; + dy?: UnsafeMixed; + x?: UnsafeMixed; + y?: UnsafeMixed; + rotate?: UnsafeMixed; + inlineSize?: UnsafeMixed; + textLength?: UnsafeMixed; + baselineShift?: UnsafeMixed; lengthAdjust?: string; alignmentBaseline?: string; - verticalAlign?: string; + verticalAlign?: UnsafeMixed; } interface NativeProps extends ViewProps, @@ -91,7 +77,7 @@ interface NativeProps method?: string; midLine?: string; spacing?: string; - startOffset?: string; + startOffset?: UnsafeMixed; } export default codegenNativeComponent('RNSVGTextPath'); diff --git a/src/fabric/UseNativeComponent.ts b/src/fabric/UseNativeComponent.ts index 84249828..0a88f9a2 100644 --- a/src/fabric/UseNativeComponent.ts +++ b/src/fabric/UseNativeComponent.ts @@ -7,6 +7,9 @@ import type { } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from './utils'; +import type { UnsafeMixed } from './codegenUtils'; +import { NumberProp } from '../lib/extract/types'; + interface SvgNodeCommonProps { name?: string; opacity?: WithDefault; @@ -34,10 +37,10 @@ interface SvgRenderableCommonProps { fillRule?: WithDefault; stroke?: ColorStruct; strokeOpacity?: WithDefault; - strokeWidth?: WithDefault; + strokeWidth?: UnsafeMixed; strokeLinecap?: WithDefault; strokeLinejoin?: WithDefault; - strokeDasharray?: ReadonlyArray; + strokeDasharray?: UnsafeMixed | NumberProp>; strokeDashoffset?: Float; strokeMiterlimit?: Float; vectorEffect?: WithDefault; @@ -49,10 +52,10 @@ interface NativeProps SvgNodeCommonProps, SvgRenderableCommonProps { href?: string; - x?: string; - y?: string; - height?: string; - width?: string; + x?: UnsafeMixed; + y?: UnsafeMixed; + height?: UnsafeMixed; + width?: UnsafeMixed; } export default codegenNativeComponent('RNSVGUse'); diff --git a/src/fabric/codegenUtils.ts b/src/fabric/codegenUtils.ts new file mode 100644 index 00000000..7d22cc99 --- /dev/null +++ b/src/fabric/codegenUtils.ts @@ -0,0 +1,8 @@ +// codegen will generate folly::dynamic in place of this type, but it's not exported by RN +// since codegen doesn't really follow imports, this way we can trick it into generating the correct type +// while keeping typescript happy +export type UnsafeMixed = T; + +// Fabric doesn't support optional props, so we need to use UnsafeMixed +// https://github.com/rnmapbox/maps/pull/3082#discussion_r1339858750 +export type OptionalProp = UnsafeMixed; diff --git a/src/lib/extract/extractLengthList.ts b/src/lib/extract/extractLengthList.ts index 3c2f9f70..47eb7a46 100644 --- a/src/lib/extract/extractLengthList.ts +++ b/src/lib/extract/extractLengthList.ts @@ -4,12 +4,12 @@ const spaceReg = /\s+/; const commaReg = /,/g; export default function extractLengthList( - lengthList?: readonly NumberProp[] | NumberProp, -): string[] { + lengthList?: readonly NumberProp[] | NumberProp +): readonly NumberProp[] { if (Array.isArray(lengthList)) { - return lengthList.map((el) => String(el)); + return lengthList as NumberProp[]; } else if (typeof lengthList === 'number') { - return [String(lengthList)]; + return [lengthList]; } else if (typeof lengthList === 'string') { return lengthList.trim().replace(commaReg, ' ').split(spaceReg); } else { diff --git a/src/lib/extract/extractProps.ts b/src/lib/extract/extractProps.ts index 378aaf99..90a89f36 100644 --- a/src/lib/extract/extractProps.ts +++ b/src/lib/extract/extractProps.ts @@ -169,19 +169,6 @@ export function extract( return extractProps(propsAndStyles(props), instance); } -export function stringifyPropsForFabric(props: { - [key: string]: NumberProp | undefined | null; -}): { [key: string]: string } { - const extracted: { [key: string]: string } = {}; - Object.keys(props).forEach((k) => { - if (props[k] !== undefined && props[k] !== null) { - extracted[k] = String(props[k]); - } - }); - - return extracted; -} - export function withoutXY( instance: object, props: object & { style?: [] | unknown } diff --git a/src/lib/extract/extractProps.windows.ts b/src/lib/extract/extractProps.windows.ts index c2200a0a..2a949a8e 100644 --- a/src/lib/extract/extractProps.windows.ts +++ b/src/lib/extract/extractProps.windows.ts @@ -151,23 +151,6 @@ export function extract( return extractProps(propsAndStyles(props), instance); } -export function stringifyPropsForFabric(props: { - [key: string]: NumberProp | undefined | null; -}) { - const extracted: { [key: string]: NumberProp } = {}; - Object.keys(props).forEach((k) => { - const prop = props[k]; - if (prop !== undefined && prop !== null) { - const propStr = prop as string; - const propNum = parseInt(propStr, 10); - const doNotParse = isNaN(propNum) || propStr[propStr.length - 1] === '%'; - extracted[k] = doNotParse ? propStr : propNum; - } - }); - - return extracted; -} - export function withoutXY( instance: object, props: object & { style?: [] | unknown } diff --git a/src/lib/extract/extractStroke.ts b/src/lib/extract/extractStroke.ts index e1b914bb..71acabec 100644 --- a/src/lib/extract/extractStroke.ts +++ b/src/lib/extract/extractStroke.ts @@ -27,7 +27,7 @@ const vectorEffects = { export default function extractStroke( o: extractedProps, props: StrokeProps, - inherited: string[], + inherited: string[] ) { const { stroke, @@ -47,7 +47,7 @@ export default function extractStroke( } if (strokeWidth != null) { inherited.push('strokeWidth'); - o.strokeWidth = String(strokeWidth); + o.strokeWidth = strokeWidth; } if (strokeOpacity != null) { inherited.push('strokeOpacity'); diff --git a/src/lib/extract/extractText.tsx b/src/lib/extract/extractText.tsx index dda69c88..0cd72cc4 100644 --- a/src/lib/extract/extractText.tsx +++ b/src/lib/extract/extractText.tsx @@ -4,7 +4,6 @@ import { Children } from 'react'; import extractLengthList from './extractLengthList'; import { pickNotNil } from '../util'; import type { NumberArray, NumberProp } from './types'; -import { stringifyPropsForFabric } from './extractProps'; const fontRegExp = /^\s*((?:(?:normal|bold|italic)\s+)*)(?:(\d+(?:\.\d+)?(?:%|px|em|pt|pc|mm|cm|in]))*(?:\s*\/.*?)?\s+)?\s*"?([^"]*)/i; @@ -112,18 +111,7 @@ export function extractFont(props: fontProps) { const baseFont = typeof font === 'string' ? parseFontString(font) : font; - const fontProps: { [prop: string]: string | number | null } = { - ...baseFont, - ...ownedFont, - }; - const stringifiedFontProps: { [prop: string]: string | null } = {}; - Object.keys(fontProps).map( - (k) => - (stringifiedFontProps[k] = - fontProps[k] === null ? null : String(fontProps[k])) - ); - - return stringifiedFontProps; + return { ...baseFont, ...ownedFont }; } let TSpan: ComponentType; @@ -182,16 +170,12 @@ export default function extractText(props: TextProps, container: boolean) { children ); - const stringifiedTextProps = stringifyPropsForFabric({ - inlineSize, - baselineShift, - verticalAlign, - }); - return { content: textChildren === null ? String(children) : null, children: textChildren, - ...stringifiedTextProps, + inlineSize, + baselineShift, + verticalAlign, alignmentBaseline, font: extractFont(props), x: extractLengthList(x),