mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-09 22:43:10 +08:00
Add support for aspectRatio style prop
Summary:
Expose aspectRatio style prop from css-layout to React Native.
This means the following will now work:
<View style={{backgroundColor: 'blue', aspectRatio: 1}}/>
Reviewed By: javache
Differential Revision: D4226472
fbshipit-source-id: c8709a7c0abbf77089a4e867879b42dcd9116f65
This commit is contained in:
committed by
Facebook Github Bot
parent
1488725db3
commit
5850165795
@@ -112,6 +112,11 @@ public class LayoutShadowNode extends ReactShadowNode {
|
||||
super.setFlexBasis(flexBasis);
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.ASPECT_RATIO, defaultFloat = CSSConstants.UNDEFINED)
|
||||
public void setAspectRatio(float aspectRatio) {
|
||||
setStyleAspectRatio(aspectRatio);
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.FLEX_DIRECTION)
|
||||
public void setFlexDirection(@Nullable String flexDirection) {
|
||||
if (isVirtual()) {
|
||||
|
||||
@@ -576,6 +576,10 @@ public class ReactShadowNode {
|
||||
mCSSNode.setFlexBasis(flexBasis);
|
||||
}
|
||||
|
||||
public void setStyleAspectRatio(float aspectRatio) {
|
||||
mCSSNode.setStyleAspectRatio(aspectRatio);
|
||||
}
|
||||
|
||||
public void setFlexDirection(CSSFlexDirection flexDirection) {
|
||||
mCSSNode.setFlexDirection(flexDirection);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,8 @@ public class ViewProps {
|
||||
public static final String MIN_HEIGHT = "minHeight";
|
||||
public static final String MAX_HEIGHT = "maxHeight";
|
||||
|
||||
public static final String ASPECT_RATIO = "aspectRatio";
|
||||
|
||||
// Props that affect more than just layout
|
||||
public static final String ENABLED = "enabled";
|
||||
public static final String BACKGROUND_COLOR = "backgroundColor";
|
||||
|
||||
Reference in New Issue
Block a user