Skip to content
Permalink
Browse files

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

Reviewed By: majak

Differential Revision: D2939842

fbshipit-source-id: c8726f1160269e432afc7562c58886313e42963c
  • Loading branch information
javache authored and Facebook Github Bot 1 committed Jun 15, 2016
1 parent 0a9cc99 commit 78b892906b00932447e86465bec4613c118f01fc
@@ -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,
@@ -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;
@@ -505,33 +505,31 @@ - (CGFloat)border##prop##Width \

// 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)
@@ -260,6 +260,11 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(__unused NSDictio
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)

0 comments on commit 78b8929

Please sign in to comment.
You can’t perform that action at this time.