Several layout related helper methods of RCTShadowView was moved to new (+Layout) category.

Reviewed By: javache

Differential Revision: D4865327

fbshipit-source-id: 4df71b57433370ee09c3f1288c4d6241a33f440a
This commit is contained in:
Valentin Shergin 2017-05-07 23:54:51 -07:00 committed by Facebook Github Bot
parent 20c2ae85f0
commit 5058e7eb05
11 changed files with 115 additions and 13 deletions

View File

@ -14,6 +14,7 @@
#import <React/RCTConvert.h>
#import <React/RCTFont.h>
#import <React/RCTLog.h>
#import <React/RCTShadowView+Layout.h>
#import <React/RCTUIManager.h>
#import <React/RCTUtils.h>

View File

@ -11,6 +11,7 @@
#import <React/RCTBridge.h>
#import <React/RCTFont.h>
#import <React/RCTShadowView+Layout.h>
#import <React/RCTShadowView.h>
#import "RCTConvert+Text.h"

View File

@ -9,12 +9,13 @@
#import "RCTTextManager.h"
#import <yoga/Yoga.h>
#import <React/RCTAccessibilityManager.h>
#import <React/RCTAssert.h>
#import <React/RCTConvert.h>
#import <React/RCTLog.h>
#import <React/RCTShadowView+Layout.h>
#import <React/UIView+React.h>
#import <yoga/Yoga.h>
#import "RCTShadowRawText.h"
#import "RCTShadowText.h"

View File

@ -12,6 +12,7 @@
#import <React/RCTBridge.h>
#import <React/RCTConvert.h>
#import <React/RCTFont.h>
#import <React/RCTShadowView+Layout.h>
#import <React/RCTShadowView.h>
#import "RCTConvert+Text.h"

View File

@ -11,6 +11,7 @@
#import <XCTest/XCTest.h>
#import <React/RCTRootShadowView.h>
#import <React/RCTShadowView+Layout.h>
#import <React/RCTShadowView.h>

View File

@ -943,8 +943,14 @@
58114A171AAE854800E7D092 /* RCTPickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A151AAE854800E7D092 /* RCTPickerManager.m */; };
58114A501AAE93D500E7D092 /* RCTAsyncLocalStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A4E1AAE93D500E7D092 /* RCTAsyncLocalStorage.m */; };
58C571C11AA56C1900CDF9C8 /* RCTDatePickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58C571BF1AA56C1900CDF9C8 /* RCTDatePickerManager.m */; };
590D7BFD1EBD458B00D8A370 /* RCTShadowView+Layout.h in Headers */ = {isa = PBXBuildFile; fileRef = 590D7BFB1EBD458B00D8A370 /* RCTShadowView+Layout.h */; };
590D7BFE1EBD458B00D8A370 /* RCTShadowView+Layout.h in Headers */ = {isa = PBXBuildFile; fileRef = 590D7BFB1EBD458B00D8A370 /* RCTShadowView+Layout.h */; };
590D7BFF1EBD458B00D8A370 /* RCTShadowView+Layout.m in Sources */ = {isa = PBXBuildFile; fileRef = 590D7BFC1EBD458B00D8A370 /* RCTShadowView+Layout.m */; };
590D7C001EBD458B00D8A370 /* RCTShadowView+Layout.m in Sources */ = {isa = PBXBuildFile; fileRef = 590D7BFC1EBD458B00D8A370 /* RCTShadowView+Layout.m */; };
59A7B9FD1E577DBF0068EDBF /* RCTRootContentView.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A7B9FB1E577DBF0068EDBF /* RCTRootContentView.h */; };
59A7B9FE1E577DBF0068EDBF /* RCTRootContentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 59A7B9FC1E577DBF0068EDBF /* RCTRootContentView.m */; };
59B1EBC91EBD46250047B19B /* RCTShadowView+Layout.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 590D7BFB1EBD458B00D8A370 /* RCTShadowView+Layout.h */; };
59B1EBCA1EBD47520047B19B /* RCTShadowView+Layout.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 590D7BFB1EBD458B00D8A370 /* RCTShadowView+Layout.h */; };
59FBEFB01E46D91C0095D885 /* RCTScrollContentShadowView.h in Headers */ = {isa = PBXBuildFile; fileRef = 59FBEFAC1E46D91C0095D885 /* RCTScrollContentShadowView.h */; };
59FBEFB11E46D91C0095D885 /* RCTScrollContentShadowView.h in Headers */ = {isa = PBXBuildFile; fileRef = 59FBEFAC1E46D91C0095D885 /* RCTScrollContentShadowView.h */; };
59FBEFB21E46D91C0095D885 /* RCTScrollContentShadowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 59FBEFAD1E46D91C0095D885 /* RCTScrollContentShadowView.m */; };
@ -1072,6 +1078,7 @@
dstPath = include/React;
dstSubfolderSpec = 16;
files = (
59B1EBCA1EBD47520047B19B /* RCTShadowView+Layout.h in Copy Headers */,
3D7BFD351EA8E43F008DFB7A /* RCTDevSettings.h in Copy Headers */,
3D7BFD331EA8E433008DFB7A /* RCTPackagerClient.h in Copy Headers */,
3D0976D71E9739FB00B9C6DD /* RCTBridge+JavaScriptCore.h in Copy Headers */,
@ -1264,6 +1271,7 @@
dstPath = include/React;
dstSubfolderSpec = 16;
files = (
59B1EBC91EBD46250047B19B /* RCTShadowView+Layout.h in Copy Headers */,
3D7BFD311EA8E41F008DFB7A /* RCTPackagerClient.h in Copy Headers */,
3D7BFD291EA8E37B008DFB7A /* RCTDevSettings.h in Copy Headers */,
3D0976D81E973A0200B9C6DD /* RCTBridge+JavaScriptCore.h in Copy Headers */,
@ -1787,6 +1795,8 @@
58114A4F1AAE93D500E7D092 /* RCTAsyncLocalStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAsyncLocalStorage.h; sourceTree = "<group>"; };
58C571BF1AA56C1900CDF9C8 /* RCTDatePickerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDatePickerManager.m; sourceTree = "<group>"; };
58C571C01AA56C1900CDF9C8 /* RCTDatePickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RCTDatePickerManager.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
590D7BFB1EBD458B00D8A370 /* RCTShadowView+Layout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTShadowView+Layout.h"; sourceTree = "<group>"; };
590D7BFC1EBD458B00D8A370 /* RCTShadowView+Layout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTShadowView+Layout.m"; sourceTree = "<group>"; };
59A7B9FB1E577DBF0068EDBF /* RCTRootContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRootContentView.h; sourceTree = "<group>"; };
59A7B9FC1E577DBF0068EDBF /* RCTRootContentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootContentView.m; sourceTree = "<group>"; };
59FBEFAC1E46D91C0095D885 /* RCTScrollContentShadowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTScrollContentShadowView.h; sourceTree = "<group>"; };
@ -2139,6 +2149,8 @@
131B6AF31AF1093D00FFC3E0 /* RCTSegmentedControlManager.m */,
13E0674B1A70F44B002CDEE1 /* RCTShadowView.h */,
13E0674C1A70F44B002CDEE1 /* RCTShadowView.m */,
590D7BFB1EBD458B00D8A370 /* RCTShadowView+Layout.h */,
590D7BFC1EBD458B00D8A370 /* RCTShadowView+Layout.m */,
13AF20431AE707F8005F5298 /* RCTSlider.h */,
13AF20441AE707F9005F5298 /* RCTSlider.m */,
14F484541AABFCE100FDF6B9 /* RCTSliderManager.h */,
@ -2515,6 +2527,7 @@
13134C991E296B2A00B9F3CB /* RCTCxxMethod.h in Headers */,
3D302F471DF828F800D6DDAE /* RCTPlatform.h in Headers */,
13134C951E296B2A00B9F3CB /* RCTObjcExecutor.h in Headers */,
590D7BFE1EBD458B00D8A370 /* RCTShadowView+Layout.h in Headers */,
13134C9D1E296B2A00B9F3CB /* RCTCxxModule.h in Headers */,
59FBEFB11E46D91C0095D885 /* RCTScrollContentShadowView.h in Headers */,
130443A31E3FEAAE00D93A67 /* RCTFollyConvert.h in Headers */,
@ -2898,6 +2911,7 @@
3D80DA8C1DF820620028D040 /* RCTTextDecorationLineType.h in Headers */,
3D80DA8D1DF820620028D040 /* RCTView.h in Headers */,
3D80DA8E1DF820620028D040 /* RCTViewControllerProtocol.h in Headers */,
590D7BFD1EBD458B00D8A370 /* RCTShadowView+Layout.h in Headers */,
3D80DA8F1DF820620028D040 /* RCTViewManager.h in Headers */,
13134CA01E296B2A00B9F3CB /* RCTCxxUtils.h in Headers */,
3D80DA901DF820620028D040 /* RCTWebView.h in Headers */,
@ -3282,6 +3296,7 @@
2D3B5E991D9B089A00451313 /* RCTDisplayLink.m in Sources */,
2D3B5EA11D9B08B600451313 /* RCTModuleData.mm in Sources */,
2D3B5EEA1D9B09CD00451313 /* RCTTabBar.m in Sources */,
590D7C001EBD458B00D8A370 /* RCTShadowView+Layout.m in Sources */,
2D3B5EAE1D9B08F800451313 /* RCTEventEmitter.m in Sources */,
2D3B5ECA1D9B095F00451313 /* RCTComponentData.m in Sources */,
2D3B5EA31D9B08BE00451313 /* RCTParserUtils.m in Sources */,
@ -3560,6 +3575,7 @@
191E3EC11C29DC3800C180A6 /* RCTRefreshControl.m in Sources */,
13C156051AB1A2840079392D /* RCTWebView.m in Sources */,
83CBBA601A601EAA00E9B192 /* RCTBridge.m in Sources */,
590D7BFF1EBD458B00D8A370 /* RCTShadowView+Layout.m in Sources */,
13C156061AB1A2840079392D /* RCTWebViewManager.m in Sources */,
58114A161AAE854800E7D092 /* RCTPicker.m in Sources */,
137327E81AA5CF210034F82E /* RCTTabBarItem.m in Sources */,

View File

@ -696,6 +696,12 @@
594AD5D21E46D87500B07237 /* RCTScrollContentViewManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 594AD5CB1E46D87500B07237 /* RCTScrollContentViewManager.h */; };
594AD5D31E46D87500B07237 /* RCTScrollContentViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 594AD5CC1E46D87500B07237 /* RCTScrollContentViewManager.m */; };
594AD5D41E46D87500B07237 /* RCTScrollContentViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 594AD5CC1E46D87500B07237 /* RCTScrollContentViewManager.m */; };
595405571EC03A1700766D3C /* RCTShadowView+Layout.h in Headers */ = {isa = PBXBuildFile; fileRef = 595405551EC03A1700766D3C /* RCTShadowView+Layout.h */; };
595405581EC03A1700766D3C /* RCTShadowView+Layout.h in Headers */ = {isa = PBXBuildFile; fileRef = 595405551EC03A1700766D3C /* RCTShadowView+Layout.h */; };
595405591EC03A1700766D3C /* RCTShadowView+Layout.m in Sources */ = {isa = PBXBuildFile; fileRef = 595405561EC03A1700766D3C /* RCTShadowView+Layout.m */; };
5954055A1EC03A1700766D3C /* RCTShadowView+Layout.m in Sources */ = {isa = PBXBuildFile; fileRef = 595405561EC03A1700766D3C /* RCTShadowView+Layout.m */; };
5954055B1EC03A7F00766D3C /* RCTShadowView+Layout.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 595405551EC03A1700766D3C /* RCTShadowView+Layout.h */; };
5954055C1EC03A8E00766D3C /* RCTShadowView+Layout.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 595405551EC03A1700766D3C /* RCTShadowView+Layout.h */; };
597AD1BD1E577D7800152581 /* RCTRootContentView.h in Headers */ = {isa = PBXBuildFile; fileRef = 597AD1BB1E577D7800152581 /* RCTRootContentView.h */; };
597AD1BE1E577D7800152581 /* RCTRootContentView.h in Headers */ = {isa = PBXBuildFile; fileRef = 597AD1BB1E577D7800152581 /* RCTRootContentView.h */; };
597AD1BF1E577D7800152581 /* RCTRootContentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 597AD1BC1E577D7800152581 /* RCTRootContentView.m */; };
@ -808,6 +814,7 @@
dstPath = include/React;
dstSubfolderSpec = 16;
files = (
5954055C1EC03A8E00766D3C /* RCTShadowView+Layout.h in Copy Headers */,
2D7B05391E9D82080032604E /* RCTBridge+Private.h in Copy Headers */,
3D0976C31E9739AE00B9C6DD /* RCTBridge+JavaScriptCore.h in Copy Headers */,
3D6B76D51E83DD3A008FA614 /* RCTDevSettings.h in Copy Headers */,
@ -970,6 +977,7 @@
dstPath = include/React;
dstSubfolderSpec = 16;
files = (
5954055B1EC03A7F00766D3C /* RCTShadowView+Layout.h in Copy Headers */,
3D7BFCEB1EA8E23A008DFB7A /* RCTDevSettings.h in Copy Headers */,
3D0976C41E9739B400B9C6DD /* RCTBridge+JavaScriptCore.h in Copy Headers */,
A12E9E1F1E5DEAEF0029001B /* RCTPackagerClient.h in Copy Headers */,
@ -1335,6 +1343,8 @@
594AD5CA1E46D87500B07237 /* RCTScrollContentShadowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTScrollContentShadowView.m; sourceTree = "<group>"; };
594AD5CB1E46D87500B07237 /* RCTScrollContentViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTScrollContentViewManager.h; sourceTree = "<group>"; };
594AD5CC1E46D87500B07237 /* RCTScrollContentViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTScrollContentViewManager.m; sourceTree = "<group>"; };
595405551EC03A1700766D3C /* RCTShadowView+Layout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTShadowView+Layout.h"; sourceTree = "<group>"; };
595405561EC03A1700766D3C /* RCTShadowView+Layout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTShadowView+Layout.m"; sourceTree = "<group>"; };
597AD1BB1E577D7800152581 /* RCTRootContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRootContentView.h; sourceTree = "<group>"; };
597AD1BC1E577D7800152581 /* RCTRootContentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootContentView.m; sourceTree = "<group>"; };
65F3E41D1E73031C009375BD /* systemJSCWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = systemJSCWrapper.cpp; sourceTree = "<group>"; };
@ -1558,6 +1568,8 @@
131B6AF31AF1093D00FFC3E0 /* RCTSegmentedControlManager.m */,
13E0674B1A70F44B002CDEE1 /* RCTShadowView.h */,
13E0674C1A70F44B002CDEE1 /* RCTShadowView.m */,
595405551EC03A1700766D3C /* RCTShadowView+Layout.h */,
595405561EC03A1700766D3C /* RCTShadowView+Layout.m */,
13AF20431AE707F8005F5298 /* RCTSlider.h */,
13AF20441AE707F9005F5298 /* RCTSlider.m */,
14F484541AABFCE100FDF6B9 /* RCTSliderManager.h */,
@ -1935,6 +1947,7 @@
3D302F6B1DF828F800D6DDAE /* RCTActivityIndicatorViewManager.h in Headers */,
3D302F6C1DF828F800D6DDAE /* RCTAnimationType.h in Headers */,
3D302F6D1DF828F800D6DDAE /* RCTAutoInsetsProtocol.h in Headers */,
595405581EC03A1700766D3C /* RCTShadowView+Layout.h in Headers */,
3D302F6E1DF828F800D6DDAE /* RCTBorderDrawing.h in Headers */,
3D302F6F1DF828F800D6DDAE /* RCTBorderStyle.h in Headers */,
3D302F701DF828F800D6DDAE /* RCTComponent.h in Headers */,
@ -2109,6 +2122,7 @@
3D80DA541DF820620028D040 /* RCTI18nUtil.h in Headers */,
3D80DA551DF820620028D040 /* RCTKeyboardObserver.h in Headers */,
3D80DA561DF820620028D040 /* RCTRedBox.h in Headers */,
595405571EC03A1700766D3C /* RCTShadowView+Layout.h in Headers */,
3D80DA571DF820620028D040 /* RCTSourceCode.h in Headers */,
3D80DA581DF820620028D040 /* RCTStatusBarManager.h in Headers */,
3D80DA591DF820620028D040 /* RCTTiming.h in Headers */,
@ -2507,6 +2521,7 @@
A12E9E5D1E5DF8720029001B /* RCTReloadPackagerMethod.m in Sources */,
3D5AC71A1E0056E0000F9153 /* RCTTVNavigationEventEmitter.m in Sources */,
2D3B5EA61D9B08CA00451313 /* RCTTouchEvent.m in Sources */,
5954055A1EC03A1700766D3C /* RCTShadowView+Layout.m in Sources */,
2D8C2E331DA40441000EE098 /* RCTMultipartStreamReader.m in Sources */,
2D3B5EF01D9B09E300451313 /* RCTWrapperViewController.m in Sources */,
3D5AC7141E0056C7000F9153 /* RCTTVView.m in Sources */,
@ -2612,6 +2627,7 @@
A12E9E8F1E5DFA620029001B /* RCTSamplingProfilerPackagerMethod.mm in Sources */,
13BCE8091C99CB9D00DD7AAD /* RCTRootShadowView.m in Sources */,
14C2CA711B3AC63800E6CBB2 /* RCTModuleMethod.m in Sources */,
595405591EC03A1700766D3C /* RCTShadowView+Layout.m in Sources */,
006FC4141D9B20820057AAAD /* RCTMultipartDataTask.m in Sources */,
A12E9E1C1E5DEA350029001B /* RCTPackagerClient.m in Sources */,
13CC8A821B17642100940AE7 /* RCTBorderDrawing.m in Sources */,

View File

@ -0,0 +1,21 @@
/**
* 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.
*/
#import <UIKit/UIKit.h>
#import <React/RCTShadowView.h>
@interface RCTShadowView (Layout)
@property (nonatomic, readonly) UIEdgeInsets paddingAsInsets;
@property (nonatomic, readonly) UIEdgeInsets borderAsInsets;
@property (nonatomic, readonly) UIEdgeInsets compoundInsets;
@property (nonatomic, readonly) CGSize availableSize;
@end

View File

@ -0,0 +1,56 @@
/**
* 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.
*/
#import "RCTShadowView+Layout.h"
#import <yoga/Yoga.h>
@implementation RCTShadowView (Layout)
- (UIEdgeInsets)paddingAsInsets
{
YGNodeRef yogaNode = self.yogaNode;
return (UIEdgeInsets){
YGNodeLayoutGetPadding(yogaNode, YGEdgeTop),
YGNodeLayoutGetPadding(yogaNode, YGEdgeLeft),
YGNodeLayoutGetPadding(yogaNode, YGEdgeBottom),
YGNodeLayoutGetPadding(yogaNode, YGEdgeRight)
};
}
- (UIEdgeInsets)borderAsInsets
{
YGNodeRef yogaNode = self.yogaNode;
return (UIEdgeInsets){
YGNodeLayoutGetBorder(yogaNode, YGEdgeTop),
YGNodeLayoutGetBorder(yogaNode, YGEdgeLeft),
YGNodeLayoutGetBorder(yogaNode, YGEdgeBottom),
YGNodeLayoutGetBorder(yogaNode, YGEdgeRight)
};
}
- (UIEdgeInsets)compoundInsets
{
UIEdgeInsets borderAsInsets = self.borderAsInsets;
UIEdgeInsets paddingAsInsets = self.paddingAsInsets;
return (UIEdgeInsets){
borderAsInsets.top + paddingAsInsets.top,
borderAsInsets.left + paddingAsInsets.left,
borderAsInsets.bottom + paddingAsInsets.bottom,
borderAsInsets.right + paddingAsInsets.right
};
}
- (CGSize)availableSize
{
return UIEdgeInsetsInsetRect((CGRect){CGPointZero, self.frame.size}, self.compoundInsets).size;
}
@end

View File

@ -128,8 +128,6 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
@property (nonatomic, assign) YGValue paddingBottom;
@property (nonatomic, assign) YGValue paddingRight;
- (UIEdgeInsets)paddingAsInsets;
/**
* Flexbox properties. All zero/disabled by default
*/

View File

@ -528,16 +528,6 @@ RCT_PADDING_PROPERTY(Left, LEFT)
RCT_PADDING_PROPERTY(Bottom, BOTTOM)
RCT_PADDING_PROPERTY(Right, RIGHT)
- (UIEdgeInsets)paddingAsInsets
{
return (UIEdgeInsets){
YGNodeLayoutGetPadding(_yogaNode, YGEdgeTop),
YGNodeLayoutGetPadding(_yogaNode, YGEdgeLeft),
YGNodeLayoutGetPadding(_yogaNode, YGEdgeBottom),
YGNodeLayoutGetPadding(_yogaNode, YGEdgeRight)
};
}
// Border
#define RCT_BORDER_PROPERTY(prop, metaProp) \