Size flexibility modes for RCTRootView

Reviewed By: javache

Differential Revision: D2526355

fb-gh-sync-id: 095a43bc01f883fdfdad3a086a35682c20c05597
This commit is contained in:
Pawel Sienkowski
2015-10-26 15:39:04 -07:00
committed by facebook-github-bot-7
parent 3a92f2017f
commit 46803f0617
6 changed files with 78 additions and 12 deletions

View File

@@ -11,6 +11,20 @@
#import "RCTBridge.h"
/**
* This enum is used to define size flexibility type of the root view.
* If a dimension is flexible, the view will recalculate that dimension
* so the content fits. Recalculations are performed when the root's frame,
* size flexibility mode or content size changes. After a recalculation,
* TODO:<DelegateName> will be called with the new size passed as an argument.
*/
typedef NS_ENUM(NSInteger, RCTRootViewSizeFlexibility) {
RCTRootViewSizeFlexibilityNone = 0,
RCTRootViewSizeFlexibilityWidth,
RCTRootViewSizeFlexibilityHeight,
RCTRootViewSizeFlexibilityWidthAndHeight,
};
/**
* This notification is sent when the first subviews are added to the root view
* after the application has loaded. This is used to hide the `loadingView`, and
@@ -71,6 +85,11 @@ extern NSString *const RCTContentDidAppearNotification;
*/
@property (nonatomic, strong) Class executorClass;
/**
* The size flexibility mode of the root view.
*/
@property (nonatomic, assign) RCTRootViewSizeFlexibility sizeFlexibility;
/**
* The backing view controller of the root view.
*/

View File

@@ -72,6 +72,7 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat
_initialProperties = [initialProperties copy];
_loadingViewFadeDelay = 0.25;
_loadingViewFadeDuration = 0.25;
_sizeFlexibility = RCTRootViewSizeFlexibilityNone;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(javaScriptDidLoad:)
@@ -189,6 +190,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
args:@[moduleName, appParameters]];
}
- (void)setSizeFlexibility:(RCTRootViewSizeFlexibility)sizeFlexibility
{
_sizeFlexibility = sizeFlexibility;
[self setNeedsLayout];
}
- (void)layoutSubviews
{
[super layoutSubviews];