diff --git a/ReactKit/Base/RCTConvert.m b/ReactKit/Base/RCTConvert.m index b1b461b83..89fca31ba 100644 --- a/ReactKit/Base/RCTConvert.m +++ b/ReactKit/Base/RCTConvert.m @@ -2,9 +2,10 @@ #import "RCTConvert.h" +#import + #import #import -#import #import "RCTLog.h" @@ -431,7 +432,7 @@ RCT_STRUCT_CONVERTER(CGAffineTransform, (@[@"a", @"b", @"c", @"d", @"tx", @"ty"] + (CAKeyframeAnimation *)GIF:(id)json { - CGImageSourceRef imageSource; + CGImageSourceRef imageSource = NULL; if ([json isKindOfClass:[NSString class]]) { NSString *path = json; if (path.length == 0) { @@ -568,7 +569,7 @@ RCT_STRUCT_CONVERTER(CGAffineTransform, (@[@"a", @"b", @"c", @"d", @"tx", @"ty"] NSString *familyName = [RCTConvert NSString:family]; if (familyName) { if ([UIFont fontNamesForFamilyName:familyName].count == 0) { - UIFont *font = [UIFont fontWithName:familyName size:fontDescriptor.pointSize]; + font = [UIFont fontWithName:familyName size:fontDescriptor.pointSize]; if (font) { // It's actually a font name, not a font family name, // but we'll do what was meant, not what was said. diff --git a/ReactKit/Modules/RCTUIManager.m b/ReactKit/Modules/RCTUIManager.m index a86c4f718..27a23c43f 100644 --- a/ReactKit/Modules/RCTUIManager.m +++ b/ReactKit/Modules/RCTUIManager.m @@ -692,7 +692,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView [self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){ RCTCAssertMainThread(); - // Register manager (TODO: should we do this, or leave it nil?) + // Register manager uiManager->_viewManagerRegistry[reactTag] = manager; // Generate default view, used for resetting default props diff --git a/ReactKit/Views/RCTShadowView.h b/ReactKit/Views/RCTShadowView.h index 1a75fdb08..ec2b8c353 100644 --- a/ReactKit/Views/RCTShadowView.h +++ b/ReactKit/Views/RCTShadowView.h @@ -64,7 +64,7 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *); /** * Position and dimensions. - * Defaults to { 0, 0, NAN, NAN } + * Defaults to { 0, 0, NAN, NAN }. */ @property (nonatomic, assign) CGFloat top; @property (nonatomic, assign) CGFloat left; @@ -76,12 +76,29 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *); - (void)setSize:(CGSize)size; /** - * Border. Defaults to 0. + * Border. Defaults to { 0, 0, 0, 0 }. */ +@property (nonatomic, assign) CGFloat borderTop; +@property (nonatomic, assign) CGFloat borderLeft; +@property (nonatomic, assign) CGFloat borderWidth; +@property (nonatomic, assign) CGFloat borderHeight; + - (void)setBorderWidth:(CGFloat)value; /** - * Padding. Defaults to 0. + * Margin. Defaults to { 0, 0, 0, 0 }. + */ +@property (nonatomic, assign) CGFloat marginTop; +@property (nonatomic, assign) CGFloat marginLeft; +@property (nonatomic, assign) CGFloat marginBottom; +@property (nonatomic, assign) CGFloat marginRight; + +- (void)setMargin:(CGFloat)margin; +- (void)setMarginVertical:(CGFloat)margin; +- (void)setMarginHorizontal:(CGFloat)margin; + +/** + * Padding. Defaults to { 0, 0, 0, 0 }. */ @property (nonatomic, assign) CGFloat paddingTop; @property (nonatomic, assign) CGFloat paddingLeft; diff --git a/ReactKit/Views/RCTShadowView.m b/ReactKit/Views/RCTShadowView.m index 3872570b1..4877b0d67 100644 --- a/ReactKit/Views/RCTShadowView.m +++ b/ReactKit/Views/RCTShadowView.m @@ -126,16 +126,6 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st : 0; } -- (UIEdgeInsets)paddingAsInsets -{ - return (UIEdgeInsets){ - _cssNode->style.padding[CSS_TOP], - _cssNode->style.padding[CSS_LEFT], - _cssNode->style.padding[CSS_BOTTOM], - _cssNode->style.padding[CSS_RIGHT] - }; -} - - (void)fillCSSNode:(css_node_t *)node { node->children_count = (int)_reactSubviews.count; @@ -432,7 +422,7 @@ RCT_MARGIN_PROPERTY(Right, RIGHT) } \ - (CGFloat)padding##prop \ { \ - return _marginMetaProps[META_PROP_##metaProp]; \ + return _paddingMetaProps[META_PROP_##metaProp]; \ } RCT_PADDING_PROPERTY(, ALL) @@ -443,8 +433,34 @@ RCT_PADDING_PROPERTY(Left, LEFT) RCT_PADDING_PROPERTY(Bottom, BOTTOM) RCT_PADDING_PROPERTY(Right, RIGHT) +- (UIEdgeInsets)paddingAsInsets +{ + return (UIEdgeInsets){ + _cssNode->style.padding[CSS_TOP], + _cssNode->style.padding[CSS_LEFT], + _cssNode->style.padding[CSS_BOTTOM], + _cssNode->style.padding[CSS_RIGHT] + }; +} + // Border +#define RCT_BORDER_PROPERTY(prop, metaProp) \ +- (void)setBorder##prop:(CGFloat)value \ +{ \ + _cssNode->style.border[CSS_##metaProp] = value; \ + [self dirtyLayout]; \ +} \ +- (CGFloat)border##prop \ +{ \ + return _cssNode->style.border[META_PROP_##metaProp]; \ +} + +RCT_BORDER_PROPERTY(Top, TOP) +RCT_BORDER_PROPERTY(Left, LEFT) +RCT_BORDER_PROPERTY(Bottom, BOTTOM) +RCT_BORDER_PROPERTY(Right, RIGHT) + - (void)setBorderWidth:(CGFloat)value { for (int i = 0; i < 4; i++) { diff --git a/ReactKit/Views/RCTViewManager.m b/ReactKit/Views/RCTViewManager.m index 84ca14991..05ecc2198 100644 --- a/ReactKit/Views/RCTViewManager.m +++ b/ReactKit/Views/RCTViewManager.m @@ -76,7 +76,7 @@ RCT_REMAP_VIEW_PROPERTY(shadowRadius, layer.shadowRadius) RCT_REMAP_VIEW_PROPERTY(borderColor, layer.borderColor); RCT_REMAP_VIEW_PROPERTY(borderRadius, layer.cornerRadius) RCT_REMAP_VIEW_PROPERTY(borderWidth, layer.borderWidth) -RCT_REMAP_VIEW_PROPERTY(transformMatrix, view.layer.transform) +RCT_REMAP_VIEW_PROPERTY(transformMatrix, layer.transform) - (void)set_overflow:(id)json forView:(UIView *)view @@ -86,11 +86,11 @@ RCT_REMAP_VIEW_PROPERTY(transformMatrix, view.layer.transform) } - (void)set_pointerEvents:(id)json - forView:(UIView *)view - withDefaultView:(UIView *)defaultView + forView:(RCTView *)view + withDefaultView:(RCTView *)defaultView { if ([view respondsToSelector:@selector(setPointerEvents:)]) { - [(id)view setPointerEvents:json ? [RCTConvert RCTPointerEvents:json] : [(id)defaultView pointerEvents]]; + view.pointerEvents = json ? [RCTConvert RCTPointerEvents:json] : defaultView.pointerEvents; return; }