strokeDash => strokeDasharray

This commit is contained in:
Horcrux
2016-04-23 15:28:32 +08:00
parent b144bd23fc
commit 70a9473b5f
6 changed files with 17 additions and 18 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -63,7 +63,7 @@ var RenderableAttributes = Object.assign({
strokeLinecap: true,
strokeLinejoin: true,
fillRule: true,
strokeDash: {
strokeDasharray: {
diff: arrayDiffer
},
strokeDashoffset: true

View File

@@ -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
};