Removed redundant views and shadow views

This commit is contained in:
Nick Lockwood 2015-04-07 14:26:43 -07:00
parent bec7d0202c
commit 60a6533422
2 changed files with 29 additions and 27 deletions

View File

@ -15,7 +15,7 @@
- (UIView *)view - (UIView *)view
{ {
return [[UIView alloc] init]; return nil;
} }
- (RCTShadowView *)shadowView - (RCTShadowView *)shadowView
@ -26,4 +26,3 @@
RCT_EXPORT_SHADOW_PROPERTY(text, NSString) RCT_EXPORT_SHADOW_PROPERTY(text, NSString)
@end @end

View File

@ -750,20 +750,27 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView
// Register manager // Register manager
_viewManagerRegistry[reactTag] = manager; _viewManagerRegistry[reactTag] = manager;
RCTShadowView *shadowView = [manager shadowView];
if (shadowView) {
// Generate default view, used for resetting default props // Generate default view, used for resetting default props
if (!_defaultShadowViews[viewName]) { if (!_defaultShadowViews[viewName]) {
_defaultShadowViews[viewName] = [manager shadowView]; _defaultShadowViews[viewName] = [manager shadowView];
} }
RCTShadowView *shadowView = [manager shadowView]; // Set properties
shadowView.viewName = 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[reactTag] = shadowView;
[self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){ [self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){
RCTCAssertMainThread(); RCTCAssertMainThread();
UIView *view = [manager view];
if (view) {
// Generate default view, used for resetting default props // Generate default view, used for resetting default props
if (!uiManager->_defaultViews[viewName]) { if (!uiManager->_defaultViews[viewName]) {
// Note the default is setup after the props are read for the first time ever // Note the default is setup after the props are read for the first time ever
@ -772,22 +779,18 @@ static void RCTSetShadowViewProps(NSDictionary *props, RCTShadowView *shadowView
uiManager->_defaultViews[viewName] = [manager view]; uiManager->_defaultViews[viewName] = [manager view];
} }
UIView *view = [manager view]; // Set properties
if (view) {
// Set required properties
view.reactTag = reactTag; view.reactTag = reactTag;
if ([view isKindOfClass:[UIView class]]) {
view.multipleTouchEnabled = YES; view.multipleTouchEnabled = YES;
view.userInteractionEnabled = YES; // required for touch handling view.userInteractionEnabled = YES; // required for touch handling
view.layer.allowsGroupOpacity = YES; // required for touch handling view.layer.allowsGroupOpacity = YES; // required for touch handling
}
// Set custom properties
RCTSetViewProps(props, view, uiManager->_defaultViews[viewName], manager); RCTSetViewProps(props, view, uiManager->_defaultViews[viewName], manager);
} }
viewRegistry[view.reactTag] = view; viewRegistry[reactTag] = view;
}]; }];
} }
// TODO: remove viewName param as it isn't needed // TODO: remove viewName param as it isn't needed
- (void)updateView:(NSNumber *)reactTag viewName:(__unused NSString *)_ props:(NSDictionary *)props - (void)updateView:(NSNumber *)reactTag viewName:(__unused NSString *)_ props:(NSDictionary *)props
{ {