mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-09 17:31:39 +08:00
Provide RTL support for RCTShadowView according to new csslayout
Summary: The make current RCTShadowView support RTL layout. 1 Change all left/right to start/end for margin, padding, boarder and position 2 Calculate position in the same way as margin, padding and boarder Reviewed By: fkgozali Differential Revision: D3619292 fbshipit-source-id: eaaa6faeee93c964d59bb6f498d89effc09ed567
This commit is contained in:
committed by
Facebook Github Bot 8
parent
654a36018c
commit
70dc98dea4
@@ -378,11 +378,11 @@ public class CSSNode {
|
||||
/**
|
||||
* Get this node's position, as defined by style.
|
||||
*/
|
||||
public Spacing getPosition() {
|
||||
public Spacing getPositionValue() {
|
||||
return style.position;
|
||||
}
|
||||
|
||||
public void setPosition(int spacingType, float position) {
|
||||
public void setPositionValue(int spacingType, float position) {
|
||||
if (style.position.set(spacingType, position)) {
|
||||
dirty();
|
||||
}
|
||||
@@ -396,9 +396,7 @@ public class CSSNode {
|
||||
}
|
||||
|
||||
public void setPositionTop(float positionTop) {
|
||||
if (style.position.set(TOP, positionTop)) {
|
||||
dirty();
|
||||
}
|
||||
setPositionValue(TOP, positionTop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,9 +407,7 @@ public class CSSNode {
|
||||
}
|
||||
|
||||
public void setPositionBottom(float positionBottom) {
|
||||
if (style.position.set(BOTTOM, positionBottom)) {
|
||||
dirty();
|
||||
}
|
||||
setPositionValue(BOTTOM, positionBottom);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,9 +418,7 @@ public class CSSNode {
|
||||
}
|
||||
|
||||
public void setPositionLeft(float positionLeft) {
|
||||
if (style.position.set(LEFT, positionLeft)) {
|
||||
dirty();
|
||||
}
|
||||
setPositionValue(LEFT, positionLeft);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -435,9 +429,7 @@ public class CSSNode {
|
||||
}
|
||||
|
||||
public void setPositionRight(float positionRight) {
|
||||
if (style.position.set(RIGHT, positionRight)) {
|
||||
dirty();
|
||||
}
|
||||
setPositionValue(RIGHT, positionRight);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,26 +51,6 @@ public class LayoutShadowNode extends ReactShadowNode {
|
||||
setStyleMaxHeight(CSSConstants.isUndefined(maxHeight) ? maxHeight : PixelUtil.toPixelFromDIP(maxHeight));
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.LEFT, defaultFloat = CSSConstants.UNDEFINED)
|
||||
public void setLeft(float left) {
|
||||
setPositionLeft(CSSConstants.isUndefined(left) ? left : PixelUtil.toPixelFromDIP(left));
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.TOP, defaultFloat = CSSConstants.UNDEFINED)
|
||||
public void setTop(float top) {
|
||||
setPositionTop(CSSConstants.isUndefined(top) ? top : PixelUtil.toPixelFromDIP(top));
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.BOTTOM, defaultFloat = CSSConstants.UNDEFINED)
|
||||
public void setBottom(float bottom) {
|
||||
setPositionBottom(CSSConstants.isUndefined(bottom) ? bottom : PixelUtil.toPixelFromDIP(bottom));
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.RIGHT, defaultFloat = CSSConstants.UNDEFINED)
|
||||
public void setRight(float right) {
|
||||
setPositionRight(CSSConstants.isUndefined(right) ? right : PixelUtil.toPixelFromDIP(right));
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.FLEX, defaultFloat = 0f)
|
||||
public void setFlex(float flex) {
|
||||
super.setFlex(flex);
|
||||
@@ -146,6 +126,19 @@ public class LayoutShadowNode extends ReactShadowNode {
|
||||
setBorder(ViewProps.BORDER_SPACING_TYPES[index], PixelUtil.toPixelFromDIP(borderWidth));
|
||||
}
|
||||
|
||||
@ReactPropGroup(names = {
|
||||
ViewProps.LEFT,
|
||||
ViewProps.RIGHT,
|
||||
ViewProps.TOP,
|
||||
ViewProps.BOTTOM,
|
||||
}, defaultFloat = CSSConstants.UNDEFINED)
|
||||
public void setPositionValues(int index, float position) {
|
||||
setPositionValue(
|
||||
ViewProps.POSITION_SPACING_TYPES[index],
|
||||
CSSConstants.isUndefined(position) ? position : PixelUtil.toPixelFromDIP(position)
|
||||
);
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.POSITION)
|
||||
public void setPosition(@Nullable String position) {
|
||||
CSSPositionType positionType = position == null ?
|
||||
|
||||
@@ -90,12 +90,15 @@ public class ViewProps {
|
||||
public static final String BORDER_BOTTOM_LEFT_RADIUS = "borderBottomLeftRadius";
|
||||
public static final String BORDER_BOTTOM_RIGHT_RADIUS = "borderBottomRightRadius";
|
||||
public static final int[] BORDER_SPACING_TYPES = {
|
||||
Spacing.ALL, Spacing.LEFT, Spacing.RIGHT, Spacing.TOP, Spacing.BOTTOM
|
||||
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.LEFT, Spacing.RIGHT, Spacing.TOP,
|
||||
Spacing.ALL, Spacing.VERTICAL, Spacing.HORIZONTAL, Spacing.START, Spacing.END, Spacing.TOP,
|
||||
Spacing.BOTTOM
|
||||
};
|
||||
public static final int[] POSITION_SPACING_TYPES = {
|
||||
Spacing.START, Spacing.END, Spacing.TOP, Spacing.BOTTOM
|
||||
};
|
||||
|
||||
private static final HashSet<String> LAYOUT_ONLY_PROPS = new HashSet<>(
|
||||
Arrays.asList(
|
||||
|
||||
Reference in New Issue
Block a user