Permalink
Browse files

Android: Implement padding(Start|End) styles for RN

Reviewed By: AaaChiuuu

Differential Revision: D5907207

fbshipit-source-id: c9bb322f94d701463be35fb1ca92aab80f47d8ab
  • Loading branch information...
RSNara authored and facebook-github-bot committed Oct 19, 2017
1 parent dc92e69 commit 1ed08d3c011f56f72bb9fa59e24583350108bf5d
@@ -582,28 +582,47 @@ public void setMargins(int index, Dynamic margin) {
margin.recycle();
}
@ReactPropGroup(names = {
@ReactPropGroup(
names = {
ViewProps.PADDING,
ViewProps.PADDING_VERTICAL,
ViewProps.PADDING_HORIZONTAL,
ViewProps.PADDING_LEFT,
ViewProps.PADDING_RIGHT,
ViewProps.PADDING_START,
ViewProps.PADDING_END,
ViewProps.PADDING_TOP,
ViewProps.PADDING_BOTTOM,
})
ViewProps.PADDING_LEFT,
ViewProps.PADDING_RIGHT,
}
)
public void setPaddings(int index, Dynamic padding) {
if (isVirtual()) {
return;
}
int spacingType = ViewProps.PADDING_MARGIN_SPACING_TYPES[index];
if (I18nUtil.getInstance().doesRTLFlipLeftAndRightStyles(getThemedContext())) {
switch (spacingType) {
case Spacing.LEFT:
spacingType = Spacing.START;
break;
case Spacing.RIGHT:
spacingType = Spacing.END;
break;
default:
break;
}
}
mTempYogaValue.setFromDynamic(padding);
switch (mTempYogaValue.unit) {
case POINT:
case UNDEFINED:
setPadding(ViewProps.PADDING_MARGIN_SPACING_TYPES[index], mTempYogaValue.value);
setPadding(spacingType, mTempYogaValue.value);
break;
case PERCENT:
setPaddingPercent(ViewProps.PADDING_MARGIN_SPACING_TYPES[index], mTempYogaValue.value);
setPaddingPercent(spacingType, mTempYogaValue.value);
break;
}
@@ -55,6 +55,8 @@
public static final String PADDING_RIGHT = "paddingRight";
public static final String PADDING_TOP = "paddingTop";
public static final String PADDING_BOTTOM = "paddingBottom";
public static final String PADDING_START = "paddingStart";
public static final String PADDING_END = "paddingEnd";
public static final String POSITION = "position";
public static final String RIGHT = "right";
@@ -116,8 +118,15 @@
Spacing.ALL, Spacing.START, Spacing.END, Spacing.TOP, Spacing.BOTTOM
};
public static final int[] PADDING_MARGIN_SPACING_TYPES = {
Spacing.ALL, Spacing.VERTICAL, Spacing.HORIZONTAL, Spacing.START, Spacing.END, Spacing.TOP,
Spacing.BOTTOM
Spacing.ALL,
Spacing.VERTICAL,
Spacing.HORIZONTAL,
Spacing.START,
Spacing.END,
Spacing.TOP,
Spacing.BOTTOM,
Spacing.LEFT,
Spacing.RIGHT,
};
public static final int[] POSITION_SPACING_TYPES = {
Spacing.START, Spacing.END, Spacing.TOP, Spacing.BOTTOM
@@ -173,7 +182,10 @@
PADDING_LEFT,
PADDING_RIGHT,
PADDING_TOP,
PADDING_BOTTOM));
PADDING_BOTTOM,
PADDING_START,
PADDING_END));
public static boolean sIsOptimizationsEnabled;

0 comments on commit 1ed08d3

Please sign in to comment.