diff --git a/android/src/main/java/com/horcrux/svg/RNSVGPathShadowNode.java b/android/src/main/java/com/horcrux/svg/RNSVGPathShadowNode.java index c2c40498..1d865ae4 100644 --- a/android/src/main/java/com/horcrux/svg/RNSVGPathShadowNode.java +++ b/android/src/main/java/com/horcrux/svg/RNSVGPathShadowNode.java @@ -51,7 +51,7 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode { protected @Nullable Path mPath; private @Nullable float[] mStrokeColor; private @Nullable float[] mFillColor; - private @Nullable float[] mStrokeDash; + private @Nullable float[] mStrokeDasharray; private float mStrokeWidth = 1; private float mStrokeDashoffset = 0; private int mStrokeLinecap = CAP_ROUND; @@ -85,9 +85,9 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode { markUpdated(); } - @ReactProp(name = "strokeDash") - public void setStrokeDash(@Nullable ReadableArray strokeDash) { - mStrokeDash = PropHelper.toFloatArray(strokeDash); + @ReactProp(name = "strokeDasharray") + public void setStrokeDash(@Nullable ReadableArray strokeDasharray) { + mStrokeDasharray = PropHelper.toFloatArray(strokeDasharray); markUpdated(); } @@ -229,8 +229,8 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode { setupPaint(paint, opacity, mStrokeColor); - if (mStrokeDash != null && mStrokeDash.length > 0) { - paint.setPathEffect(new DashPathEffect(mStrokeDash, mStrokeDashoffset)); + if (mStrokeDasharray != null && mStrokeDasharray.length > 0) { + paint.setPathEffect(new DashPathEffect(mStrokeDasharray, mStrokeDashoffset)); } return true; diff --git a/ios/RNSVGRenderable.h b/ios/RNSVGRenderable.h index c1664363..c941e081 100644 --- a/ios/RNSVGRenderable.h +++ b/ios/RNSVGRenderable.h @@ -21,7 +21,7 @@ @property (nonatomic, assign) CGFloat strokeWidth; @property (nonatomic, assign) CGLineCap strokeLinecap; @property (nonatomic, assign) CGLineJoin strokeLinejoin; -@property (nonatomic, assign) RNSVGCGFloatArray strokeDash; +@property (nonatomic, assign) RNSVGCGFloatArray strokeDasharray; @property (nonatomic, assign) CGFloat strokeDashoffset; @end diff --git a/ios/RNSVGRenderable.m b/ios/RNSVGRenderable.m index a766abcb..1d3b324b 100644 --- a/ios/RNSVGRenderable.m +++ b/ios/RNSVGRenderable.m @@ -40,16 +40,16 @@ _strokeLinejoin = strokeLinejoin; } -- (void)setStrokeDash:(RNSVGCGFloatArray)strokeDash +- (void)setStrokeDash:(RNSVGCGFloatArray)strokeDasharray { - if (strokeDash.array == _strokeDash.array) { + if (strokeDasharray.array == _strokeDasharray.array) { return; } - if (_strokeDash.array) { - free(_strokeDash.array); + if (_strokeDasharray.array) { + free(_strokeDasharray.array); } [self invalidate]; - _strokeDash = strokeDash; + _strokeDasharray = strokeDasharray; } - (void)setStrokeDashoffset:(CGFloat)strokeDashoffset @@ -60,8 +60,8 @@ - (void)dealloc { - if (_strokeDash.array) { - free(_strokeDash.array); + if (_strokeDasharray.array) { + free(_strokeDasharray.array); } } diff --git a/ios/ViewManagers/RNSVGRenderableManager.m b/ios/ViewManagers/RNSVGRenderableManager.m index 9aeefa57..98d9ee3c 100644 --- a/ios/ViewManagers/RNSVGRenderableManager.m +++ b/ios/ViewManagers/RNSVGRenderableManager.m @@ -28,7 +28,7 @@ RCT_EXPORT_VIEW_PROPERTY(strokeLinecap, CGLineCap) RCT_EXPORT_VIEW_PROPERTY(strokeLinejoin, CGLineJoin) RCT_EXPORT_VIEW_PROPERTY(clipPath, CGPath) RCT_EXPORT_VIEW_PROPERTY(clipRule, RNSVGCGFCRule) -RCT_EXPORT_VIEW_PROPERTY(strokeDash, RNSVGCGFloatArray) +RCT_EXPORT_VIEW_PROPERTY(strokeDasharray, RNSVGCGFloatArray) RCT_EXPORT_VIEW_PROPERTY(strokeDashoffset, CGFloat) @end diff --git a/lib/attributes.js b/lib/attributes.js index b447f75a..f61c5f9a 100644 --- a/lib/attributes.js +++ b/lib/attributes.js @@ -63,7 +63,7 @@ var RenderableAttributes = Object.assign({ strokeLinecap: true, strokeLinejoin: true, fillRule: true, - strokeDash: { + strokeDasharray: { diff: arrayDiffer }, strokeDashoffset: true diff --git a/lib/extract/extractStroke.js b/lib/extract/extractStroke.js index e8a0823a..680ba79e 100644 --- a/lib/extract/extractStroke.js +++ b/lib/extract/extractStroke.js @@ -38,13 +38,12 @@ function strokeFilter(props, dimensions) { } - // TODO: dashoffset // TODO: propTypes check return { stroke: patterns(stroke, +props.strokeOpacity, dimensions, props.svgId), strokeLinecap: caps[props.strokeLinecap] || 0, strokeLinejoin: joins[props.strokeLinejoin] || 0, - strokeDash: strokeDasharray || null, + strokeDasharray: strokeDasharray || null, strokeWidth: strokeWidth || 1, strokeDashoffset: strokeDasharray ? (+props.strokeDashoffset || 0) : null };