Skip to content

Commit

Permalink
fix border style without borderRadius
Browse files Browse the repository at this point in the history
Summary:
closes facebook#6721 closes facebook#3159
before(without borderRadius)
![bug](https://cloud.githubusercontent.com/assets/1488195/14235087/fcf79f8a-f9eb-11e5-9d44-7ab1d131be24.jpg)

after
![fix](https://cloud.githubusercontent.com/assets/1488195/14235067/8cf128b4-f9eb-11e5-8170-ad3a146d6104.jpg)
Closes facebook#6789

Differential Revision: D3240657

Pulled By: mkonicek

fb-gh-sync-id: 4eb8f72d7278d880297fb73653ef530719af3d5b
fbshipit-source-id: 4eb8f72d7278d880297fb73653ef530719af3d5b
  • Loading branch information
skv-headless authored and samerce committed Aug 23, 2016
1 parent 354619d commit 491cb44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 0 additions & 1 deletion Examples/UIExplorer/ViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ var ViewBorderStyleExample = React.createClass({
<View>
<View style={{
borderWidth: 1,
borderRadius: 5,
borderStyle: this.state.showBorder ? 'dashed' : null,
padding: 5
}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ private static enum BorderStyle {

@Override
public void draw(Canvas canvas) {
if ((!CSSConstants.isUndefined(mBorderRadius) && mBorderRadius > 0) || mBorderCornerRadii != null) {
drawRoundedBackgroundWithBorders(canvas);
} else {
updatePathEffect();
boolean roundedBorders = mBorderCornerRadii != null ||
(!CSSConstants.isUndefined(mBorderRadius) && mBorderRadius > 0);

if ((mBorderStyle == null || mBorderStyle == BorderStyle.SOLID) && !roundedBorders) {
drawRectangularBackgroundWithBorders(canvas);
} else {
drawRoundedBackgroundWithBorders(canvas);
}
}

Expand Down Expand Up @@ -231,7 +235,6 @@ private void drawRoundedBackgroundWithBorders(Canvas canvas) {
mPaint.setColor(ColorUtil.multiplyColorAlpha(borderColor, mAlpha));
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(fullBorderWidth);
mPaint.setPathEffect(mPathEffectForBorderStyle);
canvas.drawPath(mPathForBorderRadius, mPaint);
}
}
Expand Down Expand Up @@ -298,10 +301,17 @@ private void updatePath() {
bottomLeftRadius + extraRadiusForOutline
},
Path.Direction.CW);
}

/**
* Set type of border
*/
private void updatePathEffect() {
mPathEffectForBorderStyle = mBorderStyle != null
? mBorderStyle.getPathEffect(getFullBorderWidth())
: null;

mPaint.setPathEffect(mPathEffectForBorderStyle);
}

/**
Expand Down

0 comments on commit 491cb44

Please sign in to comment.