From 1decb7e1cb96c719f49c7a2fc3972cfdecd9b04b Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Tue, 17 Mar 2015 03:51:58 -0700 Subject: [PATCH] [ReactNative] Unforked RCTShadowView, moved RKTextView into FBReactKitTextModule --- ReactKit/Modules/RCTUIManager.m | 9 ++++----- ReactKit/Views/RCTShadowView.h | 13 ++++++++----- ReactKit/Views/RCTShadowView.m | 7 ++++--- ReactKit/Views/RCTTextFieldManager.m | 1 + 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ReactKit/Modules/RCTUIManager.m b/ReactKit/Modules/RCTUIManager.m index 98b10dfa0..93090e2c1 100644 --- a/ReactKit/Modules/RCTUIManager.m +++ b/ReactKit/Modules/RCTUIManager.m @@ -718,7 +718,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView } RCTShadowView *shadowView = [manager shadowView]; - shadowView.moduleName = viewName; + shadowView.viewName = viewName; shadowView.reactTag = reactTag; RCTSetShadowViewProps(props, shadowView, _defaultShadowViews[viewName], manager); _shadowViewRegistry[shadowView.reactTag] = shadowView; @@ -973,8 +973,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView NSMutableArray *results = [[NSMutableArray alloc] initWithCapacity:[childShadowViews count]]; CGRect layoutRect = [RCTConvert CGRect:rect]; - for (int ii = 0; ii < [childShadowViews count]; ii++) { - RCTShadowView *childShadowView = [childShadowViews objectAtIndex:ii]; + [childShadowViews enumerateObjectsUsingBlock:^(RCTShadowView *childShadowView, NSUInteger idx, BOOL *stop) { CGRect childLayout = [RCTShadowView measureLayout:childShadowView relativeTo:shadowView]; if (CGRectIsNull(childLayout)) { RCTLogError(@"View %@ (tag #%@) is not a decendant of %@ (tag #%@)", @@ -992,7 +991,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView topOffset <= layoutRect.origin.y + layoutRect.size.height && topOffset + height >= layoutRect.origin.y) { // This view is within the layout rect - NSDictionary *result = @{@"index": @(ii), + NSDictionary *result = @{@"index": @(idx), @"left": @(leftOffset), @"top": @(topOffset), @"width": @(width), @@ -1000,7 +999,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView [results addObject:result]; } - } + }]; callback(@[results]); } diff --git a/ReactKit/Views/RCTShadowView.h b/ReactKit/Views/RCTShadowView.h index f869ca614..3b961fac6 100644 --- a/ReactKit/Views/RCTShadowView.h +++ b/ReactKit/Views/RCTShadowView.h @@ -2,8 +2,8 @@ #import -#import "Layout.h" -#import "RCTUIManager.h" +#import "../Layout/Layout.h" + #import "RCTViewNodeProtocol.h" @class RCTSparseArray; @@ -31,7 +31,7 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *); @property (nonatomic, weak, readonly) RCTShadowView *superview; @property (nonatomic, assign, readonly) css_node_t *cssNode; -@property (nonatomic, copy) NSString *moduleName; +@property (nonatomic, copy) NSString *viewName; @property (nonatomic, assign) BOOL isBGColorExplicitlySet; // Used to propagate to children @property (nonatomic, strong) UIColor *backgroundColor; // Used to propagate to children @property (nonatomic, assign) RCTUpdateLifecycle layoutLifecycle; @@ -54,6 +54,9 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *); */ @property (nonatomic, assign) CGFloat top; @property (nonatomic, assign) CGFloat left; +@property (nonatomic, assign) CGFloat bottom; +@property (nonatomic, assign) CGFloat right; + @property (nonatomic, assign) CGFloat width; @property (nonatomic, assign) CGFloat height; @property (nonatomic, assign) CGRect frame; @@ -66,8 +69,8 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *); */ @property (nonatomic, assign) CGFloat borderTop; @property (nonatomic, assign) CGFloat borderLeft; -@property (nonatomic, assign) CGFloat borderWidth; -@property (nonatomic, assign) CGFloat borderHeight; +@property (nonatomic, assign) CGFloat borderBottom; +@property (nonatomic, assign) CGFloat borderRight; - (void)setBorderWidth:(CGFloat)value; diff --git a/ReactKit/Views/RCTShadowView.m b/ReactKit/Views/RCTShadowView.m index 62d38249e..d28495b4c 100644 --- a/ReactKit/Views/RCTShadowView.m +++ b/ReactKit/Views/RCTShadowView.m @@ -44,7 +44,7 @@ typedef enum { static void RCTPrint(void *context) { RCTShadowView *shadowView = (__bridge RCTShadowView *)context; - printf("%s(%zd), ", [[shadowView moduleName] UTF8String], [[shadowView reactTag] integerValue]); + printf("%s(%zd), ", shadowView.viewName.UTF8String, shadowView.reactTag.integerValue); } static css_node_t *RCTGetChild(void *context, int i) @@ -132,12 +132,13 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st RCTRoundPixelValue(absolutePosition.y + node->layout.position[CSS_TOP] + node->layout.dimensions[CSS_HEIGHT]) }; - CGRect frame = { + CGRect frame = {{ RCTRoundPixelValue(node->layout.position[CSS_LEFT]), RCTRoundPixelValue(node->layout.position[CSS_TOP]), + }, { RCTRoundPixelValue(absoluteBottomRight.x - absoluteTopLeft.x), RCTRoundPixelValue(absoluteBottomRight.y - absoluteTopLeft.y) - }; + }}; if (!CGRectEqualToRect(frame, _frame)) { _frame = frame; diff --git a/ReactKit/Views/RCTTextFieldManager.m b/ReactKit/Views/RCTTextFieldManager.m index 40a46e100..6f3924223 100644 --- a/ReactKit/Views/RCTTextFieldManager.m +++ b/ReactKit/Views/RCTTextFieldManager.m @@ -2,6 +2,7 @@ #import "RCTTextFieldManager.h" +#import "RCTBridge.h" #import "RCTConvert.h" #import "RCTShadowView.h" #import "RCTSparseArray.h"