This repository has been archived by the owner on Feb 18, 2019. It is now read-only.
forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted rootview-specific shadowview logic into new class
Summary:It was hard to understand which parts of the shadowview API are designed to be called only on the root view, and which were applicable to any view. This diff extracts rootview-specific logic out into a new RCTRootShadowView class. Reviewed By: majak Differential Revision: D3063905 fb-gh-sync-id: ef890cddfd7625fbd4bf5454314b441acdb03ac8 shipit-source-id: ef890cddfd7625fbd4bf5454314b441acdb03ac8
- Loading branch information
1 parent
7d059a1
commit d033c45
Showing
12 changed files
with
131 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* 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.h" | ||
|
||
@interface RCTRootShadowView : RCTShadowView | ||
|
||
/** | ||
* Size flexibility type used to find size constraints. | ||
* Default to RCTRootViewSizeFlexibilityNone | ||
*/ | ||
@property (nonatomic, assign) RCTRootViewSizeFlexibility sizeFlexibility; | ||
|
||
/** | ||
* Calculate all views whose frame needs updating after layout has been calculated. | ||
* Returns a set contains the shadowviews that need updating. | ||
*/ | ||
- (NSSet<RCTShadowView *> *)collectViewsWithUpdatedFrames; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* 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" | ||
|
||
@implementation RCTRootShadowView | ||
|
||
- (void)applySizeConstraints | ||
{ | ||
switch (_sizeFlexibility) { | ||
case RCTRootViewSizeFlexibilityNone: | ||
break; | ||
case RCTRootViewSizeFlexibilityWidth: | ||
self.cssNode->style.dimensions[CSS_WIDTH] = CSS_UNDEFINED; | ||
break; | ||
case RCTRootViewSizeFlexibilityHeight: | ||
self.cssNode->style.dimensions[CSS_HEIGHT] = CSS_UNDEFINED; | ||
break; | ||
case RCTRootViewSizeFlexibilityWidthAndHeight: | ||
self.cssNode->style.dimensions[CSS_WIDTH] = CSS_UNDEFINED; | ||
self.cssNode->style.dimensions[CSS_HEIGHT] = CSS_UNDEFINED; | ||
break; | ||
} | ||
} | ||
|
||
- (NSSet<RCTShadowView *> *)collectViewsWithUpdatedFrames | ||
{ | ||
[self applySizeConstraints]; | ||
|
||
[self fillCSSNode:self.cssNode]; | ||
layoutNode(self.cssNode, CSS_UNDEFINED, CSS_UNDEFINED, CSS_DIRECTION_INHERIT); | ||
|
||
NSMutableSet<RCTShadowView *> *viewsWithNewFrame = [NSMutableSet set]; | ||
[self applyLayoutNode:self.cssNode viewsWithNewFrame:viewsWithNewFrame absolutePosition:CGPointZero]; | ||
return viewsWithNewFrame; | ||
} | ||
|
||
@end |
Oops, something went wrong.