From 558f934f446010a6cb75338992164323dd44b64e Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Fri, 2 Sep 2016 10:47:32 -0700 Subject: [PATCH] Fix the drawing of left and right borders in Nodes Summary: Due to the RTL implementation, the ViewProps spacing array has START and END, whereas Nodes should deal with RIGHT and LEFT directly (just like non-Nodes does). This is the same implementation in use by non-Nodes. Reviewed By: astreet Differential Revision: D3809028 --- .../src/main/java/com/facebook/react/flat/RCTView.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTView.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTView.java index 56eb01b5e25..0bb926d1c7a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTView.java @@ -13,10 +13,10 @@ import javax.annotation.Nullable; import android.graphics.Rect; +import com.facebook.csslayout.Spacing; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.ReactStylesDiffMap; -import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactPropGroup; @@ -24,6 +24,9 @@ import com.facebook.react.uimanager.annotations.ReactPropGroup; * Node for a react View. */ /* package */ final class RCTView extends FlatShadowNode { + private static final int[] SPACING_TYPES = { + Spacing.ALL, Spacing.LEFT, Spacing.RIGHT, Spacing.TOP, Spacing.BOTTOM, + }; private @Nullable DrawBorder mDrawBorder; @@ -91,7 +94,7 @@ import com.facebook.react.uimanager.annotations.ReactPropGroup; public void setBorderWidths(int index, float borderWidth) { super.setBorderWidths(index, borderWidth); - int type = ViewProps.BORDER_SPACING_TYPES[index]; + int type = SPACING_TYPES[index]; getMutableBorder().setBorderWidth(type, PixelUtil.toPixelFromDIP(borderWidth)); } @@ -106,7 +109,7 @@ import com.facebook.react.uimanager.annotations.ReactPropGroup; "borderColor", "borderLeftColor", "borderRightColor", "borderTopColor", "borderBottomColor" }, customType = "Color", defaultDouble = Double.NaN) public void setBorderColor(int index, double color) { - int type = ViewProps.BORDER_SPACING_TYPES[index]; + int type = SPACING_TYPES[index]; if (Double.isNaN(color)) { getMutableBorder().resetBorderColor(type); } else {