mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-03 22:48:25 +08:00
Add margin auto support to react native
Summary: This diff adds margin:auto (https://drafts.csswg.org/css-flexbox-1/#auto-margins) support to React Native. This enables layout not previously supported without inserting empty 'spacer' views. See below Playground for usage. ``` class Playground extends React.Component { render() { return ( <View style={{width: '100%', height: '100%', flexDirection: 'row', backgroundColor: 'white'}}> <View style={{width: 100, height: 100, backgroundColor: 'red'}}/> <View style={{width: 100, height: 100, marginLeft: 'auto', backgroundColor: 'blue'}}/> </View> ); } } ``` Reviewed By: astreet Differential Revision: D4611753 fbshipit-source-id: e78335565c193f7fb263129a638b444715ba5ab0
This commit is contained in:
committed by
Facebook Github Bot
parent
fb266fcaad
commit
cc275557be
@@ -554,6 +554,10 @@ public class ReactShadowNode {
|
||||
mYogaNode.setWidthPercent(percent);
|
||||
}
|
||||
|
||||
public void setStyleWidthAuto() {
|
||||
mYogaNode.setWidthAuto();
|
||||
}
|
||||
|
||||
public void setStyleMinWidth(float widthPx) {
|
||||
mYogaNode.setMinWidth(widthPx);
|
||||
}
|
||||
@@ -582,6 +586,10 @@ public class ReactShadowNode {
|
||||
mYogaNode.setHeightPercent(percent);
|
||||
}
|
||||
|
||||
public void setStyleHeightAuto() {
|
||||
mYogaNode.setHeightAuto();
|
||||
}
|
||||
|
||||
public void setStyleMinHeight(float widthPx) {
|
||||
mYogaNode.setMinHeight(widthPx);
|
||||
}
|
||||
@@ -614,6 +622,10 @@ public class ReactShadowNode {
|
||||
mYogaNode.setFlexBasis(flexBasis);
|
||||
}
|
||||
|
||||
public void setFlexBasisAuto() {
|
||||
mYogaNode.setFlexBasisAuto();
|
||||
}
|
||||
|
||||
public void setFlexBasisPercent(float percent) {
|
||||
mYogaNode.setFlexBasisPercent(percent);
|
||||
}
|
||||
@@ -654,6 +666,10 @@ public class ReactShadowNode {
|
||||
mYogaNode.setMarginPercent(YogaEdge.fromInt(spacingType), percent);
|
||||
}
|
||||
|
||||
public void setMarginAuto(int spacingType) {
|
||||
mYogaNode.setMarginAuto(YogaEdge.fromInt(spacingType));
|
||||
}
|
||||
|
||||
public final float getPadding(int spacingType) {
|
||||
return mYogaNode.getLayoutPadding(YogaEdge.fromInt(spacingType));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user