2015-03-23 20:28:42 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
#import "RCTViewManager.h"
|
|
|
|
|
2015-12-01 15:41:20 +00:00
|
|
|
#import "RCTBorderStyle.h"
|
2016-11-23 15:47:52 +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-04-18 17:43:20 +00:00
|
|
|
#import "RCTUIManager.h"
|
2015-03-01 23:33:55 +00:00
|
|
|
#import "RCTUtils.h"
|
2015-02-20 04:10:52 +00:00
|
|
|
#import "RCTView.h"
|
2015-05-19 13:21:52 +00:00
|
|
|
#import "UIView+React.h"
|
2017-01-27 02:14:40 +00:00
|
|
|
#import "RCTConvert+Transform.h"
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2016-12-19 14:26:07 +00:00
|
|
|
#if TARGET_OS_TV
|
|
|
|
#import "RCTTVView.h"
|
|
|
|
#endif
|
|
|
|
|
2015-05-18 14:32:21 +00:00
|
|
|
@implementation RCTConvert(UIAccessibilityTraits)
|
|
|
|
|
|
|
|
RCT_MULTI_ENUM_CONVERTER(UIAccessibilityTraits, (@{
|
2015-08-11 13:37:12 +00:00
|
|
|
@"none": @(UIAccessibilityTraitNone),
|
|
|
|
@"button": @(UIAccessibilityTraitButton),
|
|
|
|
@"link": @(UIAccessibilityTraitLink),
|
|
|
|
@"header": @(UIAccessibilityTraitHeader),
|
|
|
|
@"search": @(UIAccessibilityTraitSearchField),
|
|
|
|
@"image": @(UIAccessibilityTraitImage),
|
|
|
|
@"selected": @(UIAccessibilityTraitSelected),
|
|
|
|
@"plays": @(UIAccessibilityTraitPlaysSound),
|
|
|
|
@"key": @(UIAccessibilityTraitKeyboardKey),
|
|
|
|
@"text": @(UIAccessibilityTraitStaticText),
|
|
|
|
@"summary": @(UIAccessibilityTraitSummaryElement),
|
|
|
|
@"disabled": @(UIAccessibilityTraitNotEnabled),
|
|
|
|
@"frequentUpdates": @(UIAccessibilityTraitUpdatesFrequently),
|
|
|
|
@"startsMedia": @(UIAccessibilityTraitStartsMediaSession),
|
|
|
|
@"adjustable": @(UIAccessibilityTraitAdjustable),
|
|
|
|
@"allowsDirectInteraction": @(UIAccessibilityTraitAllowsDirectInteraction),
|
|
|
|
@"pageTurn": @(UIAccessibilityTraitCausesPageTurn),
|
|
|
|
}), UIAccessibilityTraitNone, unsignedLongLongValue)
|
2015-05-18 14:32:21 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
@implementation RCTViewManager
|
|
|
|
|
2015-04-08 12:42:43 +00:00
|
|
|
@synthesize bridge = _bridge;
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-04-08 15:52:48 +00:00
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
|
2015-04-18 17:43:20 +00:00
|
|
|
- (dispatch_queue_t)methodQueue
|
|
|
|
{
|
2016-05-16 15:01:35 +00:00
|
|
|
return RCTGetUIManagerQueue();
|
2015-04-18 17:43:20 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
- (UIView *)view
|
|
|
|
{
|
2016-12-19 14:26:07 +00:00
|
|
|
#if TARGET_OS_TV
|
|
|
|
return [RCTTVView new];
|
|
|
|
#else
|
2015-08-17 14:35:34 +00:00
|
|
|
return [RCTView new];
|
2016-12-19 14:26:07 +00:00
|
|
|
#endif
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (RCTShadowView *)shadowView
|
|
|
|
{
|
2015-08-17 14:35:34 +00:00
|
|
|
return [RCTShadowView new];
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
2015-11-03 22:45:46 +00:00
|
|
|
- (NSArray<NSString *> *)customBubblingEventTypes
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
2015-08-11 13:37:12 +00:00
|
|
|
return @[
|
|
|
|
|
|
|
|
// Generic events
|
|
|
|
@"press",
|
|
|
|
@"change",
|
|
|
|
@"focus",
|
|
|
|
@"blur",
|
|
|
|
@"submitEditing",
|
|
|
|
@"endEditing",
|
2015-11-02 17:13:41 +00:00
|
|
|
@"keyPress",
|
2015-08-11 13:37:12 +00:00
|
|
|
|
|
|
|
// Touch events
|
|
|
|
@"touchStart",
|
|
|
|
@"touchMove",
|
|
|
|
@"touchCancel",
|
|
|
|
@"touchEnd",
|
|
|
|
];
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
2015-06-15 14:53:45 +00:00
|
|
|
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(__unused RCTShadowView *)shadowView
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2015-11-14 18:25:00 +00:00
|
|
|
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(__unused NSDictionary<NSNumber *, RCTShadowView *> *)shadowViewRegistry
|
2015-02-20 04:10:52 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2015-03-17 14:04:39 +00:00
|
|
|
#pragma mark - View properties
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2016-12-19 14:26:07 +00:00
|
|
|
#if TARGET_OS_TV
|
|
|
|
// Apple TV properties
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(isTVSelectable, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(hasTVPreferredFocus, BOOL)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(tvParallaxProperties, NSDictionary)
|
|
|
|
#endif
|
|
|
|
|
2017-06-21 01:56:26 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(nativeID, NSString)
|
|
|
|
|
2017-06-02 21:17:56 +00:00
|
|
|
// Acessibility related properties
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(accessible, reactAccessibilityElement.isAccessibilityElement, BOOL)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(accessibilityLabel, reactAccessibilityElement.accessibilityLabel, NSString)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(accessibilityTraits, reactAccessibilityElement.accessibilityTraits, UIAccessibilityTraits)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(accessibilityViewIsModal, reactAccessibilityElement.accessibilityViewIsModal, BOOL)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(onAccessibilityTap, reactAccessibilityElement.onAccessibilityTap, RCTDirectEventBlock)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(onMagicTap, reactAccessibilityElement.onMagicTap, RCTDirectEventBlock)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(testID, reactAccessibilityElement.accessibilityIdentifier, NSString)
|
|
|
|
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor)
|
2015-07-15 00:03:41 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(backfaceVisibility, layer.doubleSided, css_backface_visibility_t)
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(opacity, alpha, CGFloat)
|
2016-06-07 07:08:16 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(shadowColor, layer.shadowColor, CGColor)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(shadowOffset, layer.shadowOffset, CGSize)
|
2015-04-01 00:34:51 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(shadowOpacity, layer.shadowOpacity, float)
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(shadowRadius, layer.shadowRadius, CGFloat)
|
2016-12-02 13:47:43 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(overflow, YGOverflow, RCTView)
|
2016-08-30 07:58:15 +00:00
|
|
|
{
|
|
|
|
if (json) {
|
2016-12-02 13:47:43 +00:00
|
|
|
view.clipsToBounds = [RCTConvert YGOverflow:json] != YGOverflowVisible;
|
2016-08-30 07:58:15 +00:00
|
|
|
} else {
|
|
|
|
view.clipsToBounds = defaultView.clipsToBounds;
|
|
|
|
}
|
|
|
|
}
|
2016-11-18 22:33:23 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(shouldRasterizeIOS, BOOL, RCTView)
|
2015-08-04 23:37:38 +00:00
|
|
|
{
|
|
|
|
view.layer.shouldRasterize = json ? [RCTConvert BOOL:json] : defaultView.layer.shouldRasterize;
|
2015-08-17 12:53:42 +00:00
|
|
|
view.layer.rasterizationScale = view.layer.shouldRasterize ? [UIScreen mainScreen].scale : defaultView.layer.rasterizationScale;
|
2015-08-04 23:37:38 +00:00
|
|
|
}
|
2017-02-07 21:59:17 +00:00
|
|
|
|
2016-11-18 22:33:23 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(transform, CATransform3D, RCTView)
|
2016-04-29 21:17:58 +00:00
|
|
|
{
|
|
|
|
view.layer.transform = json ? [RCTConvert CATransform3D:json] : defaultView.layer.transform;
|
|
|
|
// TODO: Improve this by enabling edge antialiasing only for transforms with rotation or skewing
|
|
|
|
view.layer.allowsEdgeAntialiasing = !CATransform3DIsIdentity(view.layer.transform);
|
|
|
|
}
|
2017-02-07 21:59:17 +00:00
|
|
|
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(pointerEvents, RCTPointerEvents, 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-03-25 00:37:03 +00:00
|
|
|
switch ([RCTConvert RCTPointerEvents:json]) {
|
2015-02-20 04:10:52 +00:00
|
|
|
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
|
2015-03-26 09:58:06 +00:00
|
|
|
// supported in `React`. "auto" may override a parent's "none".
|
2015-02-20 04:10:52 +00:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
}
|
2016-11-18 22:33:23 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(removeClippedSubviews, BOOL, RCTView)
|
|
|
|
{
|
|
|
|
if ([view respondsToSelector:@selector(setRemoveClippedSubviews:)]) {
|
|
|
|
view.removeClippedSubviews = json ? [RCTConvert BOOL:json] : defaultView.removeClippedSubviews;
|
|
|
|
}
|
|
|
|
}
|
2015-05-13 15:22:21 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(borderRadius, CGFloat, RCTView) {
|
|
|
|
if ([view respondsToSelector:@selector(setBorderRadius:)]) {
|
2015-07-31 18:23:29 +00:00
|
|
|
view.borderRadius = json ? [RCTConvert CGFloat:json] : defaultView.borderRadius;
|
2015-05-13 15:22:21 +00:00
|
|
|
} else {
|
2015-07-31 18:23:29 +00:00
|
|
|
view.layer.cornerRadius = json ? [RCTConvert CGFloat:json] : defaultView.layer.cornerRadius;
|
2015-05-13 15:22:21 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-26 08:43:17 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(borderColor, CGColor, RCTView)
|
|
|
|
{
|
|
|
|
if ([view respondsToSelector:@selector(setBorderColor:)]) {
|
|
|
|
view.borderColor = json ? [RCTConvert CGColor:json] : defaultView.borderColor;
|
|
|
|
} else {
|
|
|
|
view.layer.borderColor = json ? [RCTConvert CGColor:json] : defaultView.layer.borderColor;
|
|
|
|
}
|
|
|
|
}
|
2016-10-26 20:12:26 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(borderWidth, float, RCTView)
|
2015-03-26 08:43:17 +00:00
|
|
|
{
|
|
|
|
if ([view respondsToSelector:@selector(setBorderWidth:)]) {
|
|
|
|
view.borderWidth = json ? [RCTConvert CGFloat:json] : defaultView.borderWidth;
|
|
|
|
} else {
|
|
|
|
view.layer.borderWidth = json ? [RCTConvert CGFloat:json] : defaultView.layer.borderWidth;
|
|
|
|
}
|
|
|
|
}
|
2015-12-01 15:41:20 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(borderStyle, RCTBorderStyle, RCTView)
|
|
|
|
{
|
|
|
|
if ([view respondsToSelector:@selector(setBorderStyle:)]) {
|
|
|
|
view.borderStyle = json ? [RCTConvert RCTBorderStyle:json] : defaultView.borderStyle;
|
|
|
|
}
|
|
|
|
}
|
2016-02-17 00:50:35 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(hitSlop, UIEdgeInsets, RCTView)
|
|
|
|
{
|
|
|
|
if ([view respondsToSelector:@selector(setHitTestEdgeInsets:)]) {
|
|
|
|
if (json) {
|
|
|
|
UIEdgeInsets hitSlopInsets = [RCTConvert UIEdgeInsets:json];
|
|
|
|
view.hitTestEdgeInsets = UIEdgeInsetsMake(-hitSlopInsets.top, -hitSlopInsets.left, -hitSlopInsets.bottom, -hitSlopInsets.right);
|
|
|
|
} else {
|
|
|
|
view.hitTestEdgeInsets = defaultView.hitTestEdgeInsets;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-26 08:43:17 +00:00
|
|
|
|
|
|
|
#define RCT_VIEW_BORDER_PROPERTY(SIDE) \
|
2016-10-26 20:12:26 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(border##SIDE##Width, float, RCTView) \
|
2015-03-26 08:43:17 +00:00
|
|
|
{ \
|
|
|
|
if ([view respondsToSelector:@selector(setBorder##SIDE##Width:)]) { \
|
2016-11-01 18:07:04 +00:00
|
|
|
view.border##SIDE##Width = json ? [RCTConvert CGFloat:json] : defaultView.border##SIDE##Width; \
|
2015-03-26 08:43:17 +00:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(border##SIDE##Color, UIColor, RCTView) \
|
|
|
|
{ \
|
|
|
|
if ([view respondsToSelector:@selector(setBorder##SIDE##Color:)]) { \
|
|
|
|
view.border##SIDE##Color = json ? [RCTConvert CGColor:json] : defaultView.border##SIDE##Color; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT_VIEW_BORDER_PROPERTY(Top)
|
|
|
|
RCT_VIEW_BORDER_PROPERTY(Right)
|
|
|
|
RCT_VIEW_BORDER_PROPERTY(Bottom)
|
|
|
|
RCT_VIEW_BORDER_PROPERTY(Left)
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-05-13 15:22:21 +00:00
|
|
|
#define RCT_VIEW_BORDER_RADIUS_PROPERTY(SIDE) \
|
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(border##SIDE##Radius, CGFloat, RCTView) \
|
|
|
|
{ \
|
|
|
|
if ([view respondsToSelector:@selector(setBorder##SIDE##Radius:)]) { \
|
|
|
|
view.border##SIDE##Radius = json ? [RCTConvert CGFloat:json] : defaultView.border##SIDE##Radius; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
|
|
|
|
RCT_VIEW_BORDER_RADIUS_PROPERTY(TopLeft)
|
|
|
|
RCT_VIEW_BORDER_RADIUS_PROPERTY(TopRight)
|
|
|
|
RCT_VIEW_BORDER_RADIUS_PROPERTY(BottomLeft)
|
|
|
|
RCT_VIEW_BORDER_RADIUS_PROPERTY(BottomRight)
|
|
|
|
|
2017-06-21 00:12:52 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(display, reactDisplay, YGDisplay)
|
2016-06-09 16:48:56 +00:00
|
|
|
RCT_REMAP_VIEW_PROPERTY(zIndex, reactZIndex, NSInteger)
|
Implement CSS z-index for iOS
Summary:
This diff implement the CSS z-index for React Native iOS views. We've had numerous pull request for this feature, but they've all attempted to use the `layer.zPosition` property, which is problematic for two reasons:
1. zPosition only affects rendering order, not event processing order. Views with a higher zPosition will appear in front of others in the hierarchy, but won't be the first to receive touch events, and may be blocked by views that are visually behind them.
2. when using a perspective transform matrix, views with a nonzero zPosition will be rendered in a different position due to parallax, which probably isn't desirable.
See https://github.com/facebook/react-native/pull/7825 for further discussion of this problem.
So instead of using `layer.zPosition`, I've implemented this by actually adjusting the order of the subviews within their parent based on the zIndex. This can't be done on the JS side because it would affect layout, which is order-dependent, so I'm doing it inside the view itself.
It works as follows:
1. The `reactSubviews` array is set, whose order matches the order of the JS components and shadowView components, as specified by the UIManager.
2. `didUpdateReactSubviews` is called, which in turn calls `sortedSubviews` (which lazily generates a sorted array of `reactSubviews` by zIndex) and inserts the result into the view.
3. If a subview is added or removed, or the zIndex of any subview is changed, the previous `sortedSubviews` array is cleared and `didUpdateReactSubviews` is called again.
To demonstrate it working, I've modified the UIExplorer example from https://github.com/facebook/react-native/pull/7825
Reviewed By: javache
Differential Revision: D3365717
fbshipit-source-id: b34aa8bfad577bce023f8af5414f9b974aafd8aa
2016-06-07 14:40:25 +00:00
|
|
|
|
2015-03-17 14:04:39 +00:00
|
|
|
#pragma mark - ShadowView properties
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-05-26 11:14:31 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(backgroundColor, UIColor)
|
|
|
|
|
2017-01-11 11:58:03 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(top, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(right, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(bottom, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(left, YGValue);
|
2016-10-26 20:12:26 +00:00
|
|
|
|
2017-01-11 11:58:03 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(width, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(height, YGValue)
|
2016-10-26 20:12:26 +00:00
|
|
|
|
2017-01-11 11:58:03 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(minWidth, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(maxWidth, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(minHeight, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(maxHeight, YGValue)
|
2016-10-26 20:12:26 +00:00
|
|
|
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(borderTopWidth, float)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(borderRightWidth, float)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(borderBottomWidth, float)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(borderLeftWidth, float)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(borderWidth, float)
|
|
|
|
|
2017-01-11 11:58:03 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(marginTop, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(marginRight, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(marginBottom, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(marginLeft, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(marginVertical, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(marginHorizontal, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(margin, YGValue)
|
|
|
|
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(paddingTop, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(paddingRight, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(paddingBottom, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(paddingLeft, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(paddingVertical, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(paddingHorizontal, YGValue)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(padding, YGValue)
|
2016-10-26 20:12:26 +00:00
|
|
|
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(flex, float)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(flexGrow, float)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(flexShrink, float)
|
2017-01-11 11:58:03 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(flexBasis, YGValue)
|
2016-12-02 13:47:43 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(flexDirection, YGFlexDirection)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(flexWrap, YGWrap)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(justifyContent, YGJustify)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(alignItems, YGAlign)
|
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(alignSelf, YGAlign)
|
Expose alignContent to react native
Summary:
This diff adds alignContent (https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) support to React Native. This enables aligning the lines of multi-line content. See below playground for example usage.
```
class Playground extends React.Component {
render() {
return (
<View style={{width: '100%', height: '100%', flexDirection: 'row', backgroundColor: 'white', flexWrap: 'wrap', alignContent: 'space-between'}}>
<View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
<View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
<View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
<View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
<View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
<View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
<View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
</View>
);
}
}
```
Reviewed By: astreet
Differential Revision: D4611803
fbshipit-source-id: ae7f6b4b7e9f4bc78d2502da948214294aad4dd2
2017-03-01 17:12:48 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(alignContent, YGAlign)
|
2016-12-02 13:47:43 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(position, YGPositionType)
|
2016-11-23 15:32:08 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(aspectRatio, float)
|
2015-03-26 04:29:28 +00:00
|
|
|
|
2016-12-02 13:47:43 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(overflow, YGOverflow)
|
2017-03-01 17:12:50 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(display, YGDisplay)
|
2016-08-30 07:58:15 +00:00
|
|
|
|
Added mechanism for directly mapping JS event handlers to blocks
Summary:
Currently, the system for mapping JS event handlers to blocks is quite clean on the JS side, but is clunky on the native side. The event property is passed as a boolean, which can then be checked by the native side, and if true, the native side is supposed to send an event via the event dispatcher.
This diff adds the facility to declare the property as a block instead. This means that the event side can simply call the block, and it will automatically send the event. Because the blocks for bubbling and direct events are named differently, we can also use this to generate the event registration data and get rid of the arrays of event names.
The name of the event is inferred from the property name, which means that the property for an event called "load" must be called `onLoad` or the mapping won't work. This can be optionally remapped to a different property name on the view itself if necessary, e.g.
RCT_REMAP_VIEW_PROPERTY(onLoad, loadEventBlock, RCTDirectEventBlock)
If you don't want to use this mechanism then for now it is still possible to declare the property as a BOOL instead and use the old mechanism (this approach is now deprecated however, and may eventually be removed altogether).
2015-09-02 12:58:10 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(onLayout, RCTDirectEventBlock)
|
[ReactNative] Introduce onLayout events
Summary:
Simply add an `onLayout` callback to a native view component, and the callback
will be invoked with the current layout information when the view is mounted and
whenever the layout changes.
The only limitation is that scroll position and other stuff the layout system
isn't aware of is not taken into account. This is because onLayout events
wouldn't be triggered for these changes and if they are desired they should be
tracked separately (e.g. with `onScroll`) and combined.
Also fixes some bugs with LayoutAnimation callbacks.
@public
Test Plan:
- Run new LayoutEventsExample in UIExplorer and see it work correctly.
- New integration test passes internally (IntegrationTest project seems busted).
- New jest test case passes.
{F22318433}
```
2015-05-06 15:45:05.848 [info][tid:com.facebook.React.JavaScript] "Running application "UIExplorerApp" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF"
2015-05-06 15:45:05.881 [info][tid:com.facebook.React.JavaScript] "received text layout event
", {"target":27,"layout":{"y":123,"x":12.5,"width":140.5,"height":18}}
2015-05-06 15:45:05.882 [info][tid:com.facebook.React.JavaScript] "received image layout event
", {"target":23,"layout":{"y":12.5,"x":122,"width":50,"height":50}}
2015-05-06 15:45:05.883 [info][tid:com.facebook.React.JavaScript] "received view layout event
", {"target":22,"layout":{"y":70.5,"x":20,"width":294,"height":204}}
2015-05-06 15:45:05.897 [info][tid:com.facebook.React.JavaScript] "received text layout event
", {"target":27,"layout":{"y":206.5,"x":12.5,"width":140.5,"height":18}}
2015-05-06 15:45:05.897 [info][tid:com.facebook.React.JavaScript] "received view layout event
", {"target":22,"layout":{"y":70.5,"x":20,"width":294,"height":287.5}}
2015-05-06 15:45:09.847 [info][tid:com.facebook.React.JavaScript] "layout animation done."
2015-05-06 15:45:09.847 [info][tid:com.facebook.React.JavaScript] "received image layout event
", {"target":23,"layout":{"y":12.5,"x":82,"width":50,"height":50}}
2015-05-06 15:45:09.848 [info][tid:com.facebook.React.JavaScript] "received view layout event
", {"target":22,"layout":{"y":110.5,"x":60,"width":214,"height":287.5}}
2015-05-06 15:45:09.862 [info][tid:com.facebook.React.JavaScript] "received text layout event
", {"target":27,"layout":{"y":206.5,"x":12.5,"width":120,"height":68}}
2015-05-06 15:45:09.863 [info][tid:com.facebook.React.JavaScript] "received image layout event
", {"target":23,"layout":{"y":12.5,"x":55,"width":50,"height":50}}
2015-05-06 15:45:09.863 [info][tid:com.facebook.React.JavaScript] "received view layout event
", {"target":22,"layout":{"y":128,"x":60,"width":160,"height":337.5}}
```
2015-05-07 19:11:02 +00:00
|
|
|
|
2016-06-09 16:48:56 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(zIndex, NSInteger)
|
2017-02-07 04:58:23 +00:00
|
|
|
RCT_EXPORT_SHADOW_PROPERTY(direction, YGDirection)
|
Implement CSS z-index for iOS
Summary:
This diff implement the CSS z-index for React Native iOS views. We've had numerous pull request for this feature, but they've all attempted to use the `layer.zPosition` property, which is problematic for two reasons:
1. zPosition only affects rendering order, not event processing order. Views with a higher zPosition will appear in front of others in the hierarchy, but won't be the first to receive touch events, and may be blocked by views that are visually behind them.
2. when using a perspective transform matrix, views with a nonzero zPosition will be rendered in a different position due to parallax, which probably isn't desirable.
See https://github.com/facebook/react-native/pull/7825 for further discussion of this problem.
So instead of using `layer.zPosition`, I've implemented this by actually adjusting the order of the subviews within their parent based on the zIndex. This can't be done on the JS side because it would affect layout, which is order-dependent, so I'm doing it inside the view itself.
It works as follows:
1. The `reactSubviews` array is set, whose order matches the order of the JS components and shadowView components, as specified by the UIManager.
2. `didUpdateReactSubviews` is called, which in turn calls `sortedSubviews` (which lazily generates a sorted array of `reactSubviews` by zIndex) and inserts the result into the view.
3. If a subview is added or removed, or the zIndex of any subview is changed, the previous `sortedSubviews` array is cleared and `didUpdateReactSubviews` is called again.
To demonstrate it working, I've modified the UIExplorer example from https://github.com/facebook/react-native/pull/7825
Reviewed By: javache
Differential Revision: D3365717
fbshipit-source-id: b34aa8bfad577bce023f8af5414f9b974aafd8aa
2016-06-07 14:40:25 +00:00
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
@end
|