From 5058e7eb05073b656fac2cf0ec2a0604ed407805 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Sun, 7 May 2017 23:54:51 -0700 Subject: [PATCH] Several layout related helper methods of RCTShadowView was moved to new (+Layout) category. Reviewed By: javache Differential Revision: D4865327 fbshipit-source-id: 4df71b57433370ee09c3f1288c4d6241a33f440a --- Libraries/Text/RCTShadowText.m | 1 + Libraries/Text/RCTTextFieldManager.m | 1 + Libraries/Text/RCTTextManager.m | 3 +- Libraries/Text/RCTTextViewManager.m | 1 + .../RNTesterUnitTests/RCTShadowViewTests.m | 1 + React/React.xcodeproj/project.pbxproj | 16 ++++++ React/ReactLegacy.xcodeproj/project.pbxproj | 16 ++++++ React/Views/RCTShadowView+Layout.h | 21 +++++++ React/Views/RCTShadowView+Layout.m | 56 +++++++++++++++++++ React/Views/RCTShadowView.h | 2 - React/Views/RCTShadowView.m | 10 ---- 11 files changed, 115 insertions(+), 13 deletions(-) create mode 100644 React/Views/RCTShadowView+Layout.h create mode 100644 React/Views/RCTShadowView+Layout.m diff --git a/Libraries/Text/RCTShadowText.m b/Libraries/Text/RCTShadowText.m index 6025cc9d0..1a0e7980b 100644 --- a/Libraries/Text/RCTShadowText.m +++ b/Libraries/Text/RCTShadowText.m @@ -14,6 +14,7 @@ #import #import #import +#import #import #import diff --git a/Libraries/Text/RCTTextFieldManager.m b/Libraries/Text/RCTTextFieldManager.m index 27287c32a..3848143f2 100644 --- a/Libraries/Text/RCTTextFieldManager.m +++ b/Libraries/Text/RCTTextFieldManager.m @@ -11,6 +11,7 @@ #import #import +#import #import #import "RCTConvert+Text.h" diff --git a/Libraries/Text/RCTTextManager.m b/Libraries/Text/RCTTextManager.m index d5c8c86ae..b26a29d7e 100644 --- a/Libraries/Text/RCTTextManager.m +++ b/Libraries/Text/RCTTextManager.m @@ -9,12 +9,13 @@ #import "RCTTextManager.h" -#import #import #import #import #import +#import #import +#import #import "RCTShadowRawText.h" #import "RCTShadowText.h" diff --git a/Libraries/Text/RCTTextViewManager.m b/Libraries/Text/RCTTextViewManager.m index ab26d1b8e..b32eeaf5b 100644 --- a/Libraries/Text/RCTTextViewManager.m +++ b/Libraries/Text/RCTTextViewManager.m @@ -12,6 +12,7 @@ #import #import #import +#import #import #import "RCTConvert+Text.h" diff --git a/RNTester/RNTesterUnitTests/RCTShadowViewTests.m b/RNTester/RNTesterUnitTests/RCTShadowViewTests.m index b6c69e20a..c00922e41 100644 --- a/RNTester/RNTesterUnitTests/RCTShadowViewTests.m +++ b/RNTester/RNTesterUnitTests/RCTShadowViewTests.m @@ -11,6 +11,7 @@ #import #import +#import #import diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index 75843240a..155605541 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -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 = ""; }; 58C571BF1AA56C1900CDF9C8 /* RCTDatePickerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDatePickerManager.m; sourceTree = ""; }; 58C571C01AA56C1900CDF9C8 /* RCTDatePickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RCTDatePickerManager.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 590D7BFB1EBD458B00D8A370 /* RCTShadowView+Layout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTShadowView+Layout.h"; sourceTree = ""; }; + 590D7BFC1EBD458B00D8A370 /* RCTShadowView+Layout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTShadowView+Layout.m"; sourceTree = ""; }; 59A7B9FB1E577DBF0068EDBF /* RCTRootContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRootContentView.h; sourceTree = ""; }; 59A7B9FC1E577DBF0068EDBF /* RCTRootContentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootContentView.m; sourceTree = ""; }; 59FBEFAC1E46D91C0095D885 /* RCTScrollContentShadowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTScrollContentShadowView.h; sourceTree = ""; }; @@ -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 */, diff --git a/React/ReactLegacy.xcodeproj/project.pbxproj b/React/ReactLegacy.xcodeproj/project.pbxproj index 8b8ad3c95..dc1a49e7b 100644 --- a/React/ReactLegacy.xcodeproj/project.pbxproj +++ b/React/ReactLegacy.xcodeproj/project.pbxproj @@ -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 = ""; }; 594AD5CB1E46D87500B07237 /* RCTScrollContentViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTScrollContentViewManager.h; sourceTree = ""; }; 594AD5CC1E46D87500B07237 /* RCTScrollContentViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTScrollContentViewManager.m; sourceTree = ""; }; + 595405551EC03A1700766D3C /* RCTShadowView+Layout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTShadowView+Layout.h"; sourceTree = ""; }; + 595405561EC03A1700766D3C /* RCTShadowView+Layout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTShadowView+Layout.m"; sourceTree = ""; }; 597AD1BB1E577D7800152581 /* RCTRootContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRootContentView.h; sourceTree = ""; }; 597AD1BC1E577D7800152581 /* RCTRootContentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootContentView.m; sourceTree = ""; }; 65F3E41D1E73031C009375BD /* systemJSCWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = systemJSCWrapper.cpp; sourceTree = ""; }; @@ -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 */, diff --git a/React/Views/RCTShadowView+Layout.h b/React/Views/RCTShadowView+Layout.h new file mode 100644 index 000000000..f80ef434c --- /dev/null +++ b/React/Views/RCTShadowView+Layout.h @@ -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 + +#import + +@interface RCTShadowView (Layout) + +@property (nonatomic, readonly) UIEdgeInsets paddingAsInsets; +@property (nonatomic, readonly) UIEdgeInsets borderAsInsets; +@property (nonatomic, readonly) UIEdgeInsets compoundInsets; +@property (nonatomic, readonly) CGSize availableSize; + +@end diff --git a/React/Views/RCTShadowView+Layout.m b/React/Views/RCTShadowView+Layout.m new file mode 100644 index 000000000..783ea95b2 --- /dev/null +++ b/React/Views/RCTShadowView+Layout.m @@ -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 + +@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 diff --git a/React/Views/RCTShadowView.h b/React/Views/RCTShadowView.h index 8ec452d5e..bcf0522f8 100644 --- a/React/Views/RCTShadowView.h +++ b/React/Views/RCTShadowView.h @@ -128,8 +128,6 @@ typedef void (^RCTApplierBlock)(NSDictionary *viewRegistry @property (nonatomic, assign) YGValue paddingBottom; @property (nonatomic, assign) YGValue paddingRight; -- (UIEdgeInsets)paddingAsInsets; - /** * Flexbox properties. All zero/disabled by default */ diff --git a/React/Views/RCTShadowView.m b/React/Views/RCTShadowView.m index 7cae648e9..d7b431fd4 100644 --- a/React/Views/RCTShadowView.m +++ b/React/Views/RCTShadowView.m @@ -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) \