2015-02-20 04:10:52 +00:00
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
|
|
|
|
#import "RCTViewManager.h"
|
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
#import "RCTBridge.h"
|
2015-02-20 04:10:52 +00:00
|
|
|
#import "RCTConvert.h"
|
|
|
|
#import "RCTEventDispatcher.h"
|
|
|
|
#import "RCTLog.h"
|
|
|
|
#import "RCTShadowView.h"
|
2015-03-01 23:33:55 +00:00
|
|
|
#import "RCTUtils.h"
|
2015-02-20 04:10:52 +00:00
|
|
|
#import "RCTView.h"
|
|
|
|
|
|
|
|
@implementation RCTViewManager
|
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
@synthesize bridge = _bridge;
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
+ (NSString *)moduleName
|
|
|
|
{
|
|
|
|
// Default implementation, works in most cases
|
|
|
|
NSString *name = NSStringFromClass(self);
|
2015-03-01 23:33:55 +00:00
|
|
|
if ([name hasPrefix:@"RK"]) {
|
|
|
|
name = [name stringByReplacingCharactersInRange:(NSRange){0,@"RK".length} withString:@"RCT"];
|
|
|
|
}
|
2015-02-20 04:10:52 +00:00
|
|
|
if ([name hasPrefix:@"RCTUI"]) {
|
|
|
|
name = [name substringFromIndex:@"RCT".length];
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UIView *)view
|
|
|
|
{
|
|
|
|
return [[RCTView alloc] init];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (RCTShadowView *)shadowView
|
|
|
|
{
|
|
|
|
return [[RCTShadowView alloc] init];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSDictionary *)customBubblingEventTypes
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSDictionary *)customDirectEventTypes
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
- (NSDictionary *)constantsToExport
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowView *)shadowView
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(RCTSparseArray *)shadowViewRegistry
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
// View properties
|
|
|
|
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(accessibilityLabel)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(hidden)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(backgroundColor)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(accessible, isAccessibilityElement)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(testID, accessibilityIdentifier)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(opacity, alpha)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(shadowColor, layer.shadowColor);
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(shadowOffset, layer.shadowOffset);
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(shadowOpacity, layer.shadowOpacity)
|
|
|
|
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, layer.transform)
|
2015-03-01 23:33:55 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(overflow, UIView *)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
|
|
|
view.clipsToBounds = json ? ![RCTConvert css_overflow:json] : defaultView.clipsToBounds;
|
|
|
|
}
|
2015-03-01 23:33:55 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(pointerEvents, RCTView *)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
|
|
|
if ([view respondsToSelector:@selector(setPointerEvents:)]) {
|
|
|
|
view.pointerEvents = json ? [RCTConvert RCTPointerEvents:json] : defaultView.pointerEvents;
|
|
|
|
return;
|
|
|
|
}
|
2015-03-01 23:33:55 +00:00
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
if (!json) {
|
|
|
|
view.userInteractionEnabled = defaultView.userInteractionEnabled;
|
|
|
|
return;
|
|
|
|
}
|
2015-03-01 23:33:55 +00:00
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
switch ([RCTConvert NSInteger:json]) {
|
|
|
|
case RCTPointerEventsUnspecified:
|
|
|
|
// Pointer events "unspecified" acts as if a stylesheet had not specified,
|
|
|
|
// which is different than "auto" in CSS (which cannot and will not be
|
|
|
|
// supported in `ReactKit`. "auto" may override a parent's "none".
|
|
|
|
// Unspecified values do not.
|
|
|
|
// This wouldn't override a container view's `userInteractionEnabled = NO`
|
|
|
|
view.userInteractionEnabled = YES;
|
|
|
|
case RCTPointerEventsNone:
|
|
|
|
view.userInteractionEnabled = NO;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RCTLogError(@"UIView base class does not support pointerEvent value: %@", json);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ShadowView properties
|
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
RCT_CUSTOM_SHADOW_PROPERTY(backgroundColor, RCTShadowView *)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-03-01 23:33:55 +00:00
|
|
|
view.backgroundColor = json ? [RCTConvert UIColor:json] : defaultView.backgroundColor;
|
|
|
|
view.isBGColorExplicitlySet = json ? YES : defaultView.isBGColorExplicitlySet;
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
2015-03-01 23:33:55 +00:00
|
|
|
RCT_CUSTOM_SHADOW_PROPERTY(flexDirection, RCTShadowView *)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-03-01 23:33:55 +00:00
|
|
|
view.flexDirection = json? [RCTConvert css_flex_direction_t:json] : defaultView.flexDirection;
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
2015-03-01 23:33:55 +00:00
|
|
|
RCT_CUSTOM_SHADOW_PROPERTY(flexWrap, RCTShadowView *)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-03-01 23:33:55 +00:00
|
|
|
view.flexWrap = json ? [RCTConvert css_wrap_type_t:json] : defaultView.flexWrap;
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
2015-03-01 23:33:55 +00:00
|
|
|
RCT_CUSTOM_SHADOW_PROPERTY(justifyContent, RCTShadowView *)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-03-01 23:33:55 +00:00
|
|
|
view.justifyContent = json ? [RCTConvert css_justify_t:json] : defaultView.justifyContent;
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
2015-03-01 23:33:55 +00:00
|
|
|
RCT_CUSTOM_SHADOW_PROPERTY(alignItems, RCTShadowView *)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-03-01 23:33:55 +00:00
|
|
|
view.alignItems = json ? [RCTConvert css_align_t:json] : defaultView.alignItems;
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
2015-03-01 23:33:55 +00:00
|
|
|
RCT_CUSTOM_SHADOW_PROPERTY(alignSelf, RCTShadowView *)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-03-01 23:33:55 +00:00
|
|
|
view.alignSelf = json ? [RCTConvert css_align_t:json] : defaultView.alignSelf;
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
2015-03-01 23:33:55 +00:00
|
|
|
RCT_CUSTOM_SHADOW_PROPERTY(position, RCTShadowView *)
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-03-01 23:33:55 +00:00
|
|
|
view.positionType = json ? [RCTConvert css_position_type_t:json] : defaultView.positionType;
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|