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];