[ReactNative] Unforked RCTShadowView, moved RKTextView into FBReactKitTextModule

This commit is contained in:
Nick Lockwood 2015-03-17 03:51:58 -07:00
parent d8ee4e87a1
commit 1decb7e1cb
4 changed files with 17 additions and 13 deletions

View File

@ -718,7 +718,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView
} }
RCTShadowView *shadowView = [manager shadowView]; RCTShadowView *shadowView = [manager shadowView];
shadowView.moduleName = viewName; shadowView.viewName = viewName;
shadowView.reactTag = reactTag; shadowView.reactTag = reactTag;
RCTSetShadowViewProps(props, shadowView, _defaultShadowViews[viewName], manager); RCTSetShadowViewProps(props, shadowView, _defaultShadowViews[viewName], manager);
_shadowViewRegistry[shadowView.reactTag] = shadowView; _shadowViewRegistry[shadowView.reactTag] = shadowView;
@ -973,8 +973,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView
NSMutableArray *results = [[NSMutableArray alloc] initWithCapacity:[childShadowViews count]]; NSMutableArray *results = [[NSMutableArray alloc] initWithCapacity:[childShadowViews count]];
CGRect layoutRect = [RCTConvert CGRect:rect]; CGRect layoutRect = [RCTConvert CGRect:rect];
for (int ii = 0; ii < [childShadowViews count]; ii++) { [childShadowViews enumerateObjectsUsingBlock:^(RCTShadowView *childShadowView, NSUInteger idx, BOOL *stop) {
RCTShadowView *childShadowView = [childShadowViews objectAtIndex:ii];
CGRect childLayout = [RCTShadowView measureLayout:childShadowView relativeTo:shadowView]; CGRect childLayout = [RCTShadowView measureLayout:childShadowView relativeTo:shadowView];
if (CGRectIsNull(childLayout)) { if (CGRectIsNull(childLayout)) {
RCTLogError(@"View %@ (tag #%@) is not a decendant of %@ (tag #%@)", 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 <= layoutRect.origin.y + layoutRect.size.height &&
topOffset + height >= layoutRect.origin.y) { topOffset + height >= layoutRect.origin.y) {
// This view is within the layout rect // This view is within the layout rect
NSDictionary *result = @{@"index": @(ii), NSDictionary *result = @{@"index": @(idx),
@"left": @(leftOffset), @"left": @(leftOffset),
@"top": @(topOffset), @"top": @(topOffset),
@"width": @(width), @"width": @(width),
@ -1000,7 +999,7 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView
[results addObject:result]; [results addObject:result];
} }
} }];
callback(@[results]); callback(@[results]);
} }

View File

@ -2,8 +2,8 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "Layout.h" #import "../Layout/Layout.h"
#import "RCTUIManager.h"
#import "RCTViewNodeProtocol.h" #import "RCTViewNodeProtocol.h"
@class RCTSparseArray; @class RCTSparseArray;
@ -31,7 +31,7 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *);
@property (nonatomic, weak, readonly) RCTShadowView *superview; @property (nonatomic, weak, readonly) RCTShadowView *superview;
@property (nonatomic, assign, readonly) css_node_t *cssNode; @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, assign) BOOL isBGColorExplicitlySet; // Used to propagate to children
@property (nonatomic, strong) UIColor *backgroundColor; // Used to propagate to children @property (nonatomic, strong) UIColor *backgroundColor; // Used to propagate to children
@property (nonatomic, assign) RCTUpdateLifecycle layoutLifecycle; @property (nonatomic, assign) RCTUpdateLifecycle layoutLifecycle;
@ -54,6 +54,9 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *);
*/ */
@property (nonatomic, assign) CGFloat top; @property (nonatomic, assign) CGFloat top;
@property (nonatomic, assign) CGFloat left; @property (nonatomic, assign) CGFloat left;
@property (nonatomic, assign) CGFloat bottom;
@property (nonatomic, assign) CGFloat right;
@property (nonatomic, assign) CGFloat width; @property (nonatomic, assign) CGFloat width;
@property (nonatomic, assign) CGFloat height; @property (nonatomic, assign) CGFloat height;
@property (nonatomic, assign) CGRect frame; @property (nonatomic, assign) CGRect frame;
@ -66,8 +69,8 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *);
*/ */
@property (nonatomic, assign) CGFloat borderTop; @property (nonatomic, assign) CGFloat borderTop;
@property (nonatomic, assign) CGFloat borderLeft; @property (nonatomic, assign) CGFloat borderLeft;
@property (nonatomic, assign) CGFloat borderWidth; @property (nonatomic, assign) CGFloat borderBottom;
@property (nonatomic, assign) CGFloat borderHeight; @property (nonatomic, assign) CGFloat borderRight;
- (void)setBorderWidth:(CGFloat)value; - (void)setBorderWidth:(CGFloat)value;

View File

@ -44,7 +44,7 @@ typedef enum {
static void RCTPrint(void *context) static void RCTPrint(void *context)
{ {
RCTShadowView *shadowView = (__bridge RCTShadowView *)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) 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]) 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_LEFT]),
RCTRoundPixelValue(node->layout.position[CSS_TOP]), RCTRoundPixelValue(node->layout.position[CSS_TOP]),
}, {
RCTRoundPixelValue(absoluteBottomRight.x - absoluteTopLeft.x), RCTRoundPixelValue(absoluteBottomRight.x - absoluteTopLeft.x),
RCTRoundPixelValue(absoluteBottomRight.y - absoluteTopLeft.y) RCTRoundPixelValue(absoluteBottomRight.y - absoluteTopLeft.y)
}; }};
if (!CGRectEqualToRect(frame, _frame)) { if (!CGRectEqualToRect(frame, _frame)) {
_frame = frame; _frame = frame;

View File

@ -2,6 +2,7 @@
#import "RCTTextFieldManager.h" #import "RCTTextFieldManager.h"
#import "RCTBridge.h"
#import "RCTConvert.h" #import "RCTConvert.h"
#import "RCTShadowView.h" #import "RCTShadowView.h"
#import "RCTSparseArray.h" #import "RCTSparseArray.h"