Introducing RCTRootShadowView.baseDirection property

Reviewed By: dshahidehpour

Differential Revision: D4555904

fbshipit-source-id: 8f0a2a9a38af42334188bc1cc5e0f6dded8592ae
This commit is contained in:
Valentin Shergin 2017-02-14 15:23:40 -08:00 committed by Facebook Github Bot
parent a86559ffb5
commit 5263699f90
2 changed files with 10 additions and 2 deletions

View File

@ -8,6 +8,7 @@
*/ */
#import <React/RCTShadowView.h> #import <React/RCTShadowView.h>
#import <yoga/YGEnums.h>
@interface RCTRootShadowView : RCTShadowView @interface RCTRootShadowView : RCTShadowView
@ -17,6 +18,13 @@
*/ */
@property (nonatomic, assign) RCTRootViewSizeFlexibility sizeFlexibility; @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. * Calculate all views whose frame needs updating after layout has been calculated.
* Returns a set contains the shadowviews that need updating. * Returns a set contains the shadowviews that need updating.

View File

@ -21,7 +21,7 @@
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
self.direction = [[RCTI18nUtil sharedInstance] isRTL] ? YGDirectionRTL : YGDirectionLTR; _baseDirection = [[RCTI18nUtil sharedInstance] isRTL] ? YGDirectionRTL : YGDirectionLTR;
} }
return self; return self;
} }
@ -48,7 +48,7 @@
{ {
[self applySizeConstraints]; [self applySizeConstraints];
YGNodeCalculateLayout(self.cssNode, YGUndefined, YGUndefined, YGDirectionInherit); YGNodeCalculateLayout(self.cssNode, YGUndefined, YGUndefined, _baseDirection);
NSMutableSet<RCTShadowView *> *viewsWithNewFrame = [NSMutableSet set]; NSMutableSet<RCTShadowView *> *viewsWithNewFrame = [NSMutableSet set];
[self applyLayoutNode:self.cssNode viewsWithNewFrame:viewsWithNewFrame absolutePosition:CGPointZero]; [self applyLayoutNode:self.cssNode viewsWithNewFrame:viewsWithNewFrame absolutePosition:CGPointZero];