Support {min,max}{Width,Height} on RCTView

Reviewed By: majak

Differential Revision: D2939842

fbshipit-source-id: c8726f1160269e432afc7562c58886313e42963c
This commit is contained in:
Pieter De Baets 2016-06-15 09:44:34 -07:00 committed by Facebook Github Bot 1
parent 0a9cc99a4f
commit 78b892906b
4 changed files with 34 additions and 21 deletions

View File

@ -32,6 +32,10 @@ var LayoutPropTypes = {
left: ReactPropTypes.number,
right: ReactPropTypes.number,
bottom: ReactPropTypes.number,
minWidth: ReactPropTypes.number,
maxWidth: ReactPropTypes.number,
minHeight: ReactPropTypes.number,
maxHeight: ReactPropTypes.number,
margin: ReactPropTypes.number,
marginVertical: ReactPropTypes.number,
marginHorizontal: ReactPropTypes.number,

View File

@ -74,6 +74,12 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
@property (nonatomic, assign) CGFloat width;
@property (nonatomic, assign) CGFloat height;
@property (nonatomic, assign) CGFloat minWidth;
@property (nonatomic, assign) CGFloat maxWidth;
@property (nonatomic, assign) CGFloat minHeight;
@property (nonatomic, assign) CGFloat maxHeight;
@property (nonatomic, assign) CGRect frame;
- (void)setTopLeft:(CGPoint)topLeft;

View File

@ -505,33 +505,31 @@ RCT_BORDER_PROPERTY(Right, RIGHT)
// Dimensions
#define RCT_DIMENSIONS_PROPERTY(setProp, getProp, cssProp, dimensions) \
- (void)set##setProp:(CGFloat)value \
{ \
_cssNode->style.dimensions[CSS_##cssProp] = value; \
[self dirtyLayout]; \
[self dirtyText]; \
} \
- (CGFloat)getProp \
{ \
return _cssNode->style.dimensions[CSS_##cssProp]; \
#define RCT_DIMENSION_PROPERTY(setProp, getProp, cssProp, category) \
- (void)set##setProp:(CGFloat)value \
{ \
_cssNode->style.category[CSS_##cssProp] = value; \
[self dirtyLayout]; \
[self dirtyText]; \
} \
- (CGFloat)getProp \
{ \
return _cssNode->style.category[CSS_##cssProp]; \
}
RCT_DIMENSIONS_PROPERTY(Width, width, WIDTH, dimensions)
RCT_DIMENSIONS_PROPERTY(Height, height, HEIGHT, dimensions)
RCT_DIMENSION_PROPERTY(Width, width, WIDTH, dimensions)
RCT_DIMENSION_PROPERTY(Height, height, HEIGHT, dimensions)
RCT_DIMENSION_PROPERTY(MinWidth, minWidth, WIDTH, minDimensions)
RCT_DIMENSION_PROPERTY(MaxWidth, maxWidth, WIDTH, maxDimensions)
RCT_DIMENSION_PROPERTY(MinHeight, minHeight, HEIGHT, minDimensions)
RCT_DIMENSION_PROPERTY(maxHeight, maxHeight, HEIGHT, maxDimensions)
// Position
#define RCT_POSITION_PROPERTY(setProp, getProp, cssProp) \
- (void)set##setProp:(CGFloat)value \
{ \
_cssNode->style.position[CSS_##cssProp] = value; \
[self dirtyLayout]; \
} \
- (CGFloat)getProp \
{ \
return _cssNode->style.position[CSS_##cssProp]; \
}
RCT_DIMENSION_PROPERTY(setProp, getProp, cssProp, position)
RCT_POSITION_PROPERTY(Top, top, TOP)
RCT_POSITION_PROPERTY(Right, right, RIGHT)

View File

@ -260,6 +260,11 @@ RCT_EXPORT_SHADOW_PROPERTY(left, CGFloat);
RCT_EXPORT_SHADOW_PROPERTY(width, CGFloat)
RCT_EXPORT_SHADOW_PROPERTY(height, CGFloat)
RCT_EXPORT_SHADOW_PROPERTY(minWidth, CGFloat)
RCT_EXPORT_SHADOW_PROPERTY(maxWidth, CGFloat)
RCT_EXPORT_SHADOW_PROPERTY(minHeight, CGFloat)
RCT_EXPORT_SHADOW_PROPERTY(maxHeight, CGFloat)
RCT_EXPORT_SHADOW_PROPERTY(borderTopWidth, CGFloat)
RCT_EXPORT_SHADOW_PROPERTY(borderRightWidth, CGFloat)
RCT_EXPORT_SHADOW_PROPERTY(borderBottomWidth, CGFloat)