From 5263699f90de1a733367641770320853f8d216db Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 14 Feb 2017 15:23:40 -0800 Subject: [PATCH] Introducing RCTRootShadowView.baseDirection property Reviewed By: dshahidehpour Differential Revision: D4555904 fbshipit-source-id: 8f0a2a9a38af42334188bc1cc5e0f6dded8592ae --- React/Views/RCTRootShadowView.h | 8 ++++++++ React/Views/RCTRootShadowView.m | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/React/Views/RCTRootShadowView.h b/React/Views/RCTRootShadowView.h index ec830d84f..bda4835ea 100644 --- a/React/Views/RCTRootShadowView.h +++ b/React/Views/RCTRootShadowView.h @@ -8,6 +8,7 @@ */ #import +#import @interface RCTRootShadowView : RCTShadowView @@ -17,6 +18,13 @@ */ @property (nonatomic, assign) RCTRootViewSizeFlexibility sizeFlexibility; +/** + * Layout direction (LTR or RTL) inherited from native environment and + * is using as a base direction value in layout engine. + * Defaults to value inferred from current locale. + */ +@property (nonatomic, assign) YGDirection baseDirection; + /** * Calculate all views whose frame needs updating after layout has been calculated. * Returns a set contains the shadowviews that need updating. diff --git a/React/Views/RCTRootShadowView.m b/React/Views/RCTRootShadowView.m index 70fb827b9..004225922 100644 --- a/React/Views/RCTRootShadowView.m +++ b/React/Views/RCTRootShadowView.m @@ -21,7 +21,7 @@ { self = [super init]; if (self) { - self.direction = [[RCTI18nUtil sharedInstance] isRTL] ? YGDirectionRTL : YGDirectionLTR; + _baseDirection = [[RCTI18nUtil sharedInstance] isRTL] ? YGDirectionRTL : YGDirectionLTR; } return self; } @@ -48,7 +48,7 @@ { [self applySizeConstraints]; - YGNodeCalculateLayout(self.cssNode, YGUndefined, YGUndefined, YGDirectionInherit); + YGNodeCalculateLayout(self.cssNode, YGUndefined, YGUndefined, _baseDirection); NSMutableSet *viewsWithNewFrame = [NSMutableSet set]; [self applyLayoutNode:self.cssNode viewsWithNewFrame:viewsWithNewFrame absolutePosition:CGPointZero];