2016-03-21 10:20:49 +00:00
|
|
|
/**
|
|
|
|
* 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 "RCTRootShadowView.h"
|
|
|
|
|
2017-02-07 04:58:23 +00:00
|
|
|
#import "RCTI18nUtil.h"
|
|
|
|
|
2016-03-21 10:20:49 +00:00
|
|
|
@implementation RCTRootShadowView
|
|
|
|
|
2016-06-21 18:51:49 +00:00
|
|
|
- (instancetype)init
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self) {
|
2017-02-14 23:23:40 +00:00
|
|
|
_baseDirection = [[RCTI18nUtil sharedInstance] isRTL] ? YGDirectionRTL : YGDirectionLTR;
|
2017-02-20 07:05:42 +00:00
|
|
|
_availableSize = CGSizeMake(INFINITY, INFINITY);
|
2016-06-21 18:51:49 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2016-03-21 10:20:49 +00:00
|
|
|
- (NSSet<RCTShadowView *> *)collectViewsWithUpdatedFrames
|
|
|
|
{
|
2017-02-20 07:05:42 +00:00
|
|
|
// Treating `INFINITY` as `YGUndefined` (which equals `NAN`).
|
|
|
|
float availableWidth = _availableSize.width == INFINITY ? YGUndefined : _availableSize.width;
|
|
|
|
float availableHeight = _availableSize.height == INFINITY ? YGUndefined : _availableSize.height;
|
2016-03-21 10:20:49 +00:00
|
|
|
|
2017-02-21 16:43:34 +00:00
|
|
|
YGNodeCalculateLayout(self.yogaNode, availableWidth, availableHeight, _baseDirection);
|
2016-03-21 10:20:49 +00:00
|
|
|
|
|
|
|
NSMutableSet<RCTShadowView *> *viewsWithNewFrame = [NSMutableSet set];
|
2017-02-21 16:43:34 +00:00
|
|
|
[self applyLayoutNode:self.yogaNode viewsWithNewFrame:viewsWithNewFrame absolutePosition:CGPointZero];
|
2016-03-21 10:20:49 +00:00
|
|
|
return viewsWithNewFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|