Browse Source

Fixes initial screen size (#4781)

Yogev Ben David 5 years ago
parent
commit
e036743813
No account linked to committer's email address

+ 7
- 6
lib/ios/RNNReactRootViewCreator.m View File

@@ -14,24 +14,25 @@
14 14
 	return self;
15 15
 }
16 16
 
17
-- (RNNReactView*)createRootView:(NSString*)name rootViewId:(NSString*)rootViewId reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
17
+- (RNNReactView*)createRootView:(NSString*)name rootViewId:(NSString*)rootViewId availableSize:(CGSize)availableSize reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
18 18
 	if (!rootViewId) {
19 19
 		@throw [NSException exceptionWithName:@"MissingViewId" reason:@"Missing view id" userInfo:nil];
20 20
 	}
21 21
 	
22 22
 	RNNReactView *view = [[RNNReactView alloc] initWithBridge:_bridge
23
-														   moduleName:name
24
-													initialProperties:@{@"componentId": rootViewId}
25
-												  reactViewReadyBlock:reactViewReadyBlock];
23
+												   moduleName:name
24
+											initialProperties:@{@"componentId": rootViewId}
25
+												availableSize:availableSize
26
+										  reactViewReadyBlock:reactViewReadyBlock];
26 27
 	return view;
27 28
 }
28 29
 
29 30
 - (UIView*)createRootViewFromComponentOptions:(RNNComponentOptions*)componentOptions {
30
-	return [self createRootView:componentOptions.name.get rootViewId:componentOptions.componentId.get reactViewReadyBlock:nil];
31
+	return [self createRootView:componentOptions.name.get rootViewId:componentOptions.componentId.get availableSize:CGSizeZero reactViewReadyBlock:nil];
31 32
 }
32 33
 
33 34
 - (UIView*)createRootViewFromComponentOptions:(RNNComponentOptions*)componentOptions reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
34
-	return [self createRootView:componentOptions.name.get rootViewId:componentOptions.componentId.get reactViewReadyBlock:reactViewReadyBlock];
35
+	return [self createRootView:componentOptions.name.get rootViewId:componentOptions.componentId.get availableSize:CGSizeZero reactViewReadyBlock:reactViewReadyBlock];
35 36
 }
36 37
 
37 38
 @end

+ 1
- 1
lib/ios/RNNReactView.h View File

@@ -5,7 +5,7 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void);
5 5
 
6 6
 @interface RNNReactView : RCTRootView <RCTRootViewDelegate>
7 7
 
8
-- (instancetype)initWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initialProperties:(NSDictionary *)initialProperties reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock;
8
+- (instancetype)initWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initialProperties:(NSDictionary *)initialProperties availableSize:(CGSize)availableSize reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock;
9 9
 
10 10
 @property (nonatomic, copy) void (^rootViewDidChangeIntrinsicSize)(CGSize intrinsicSize);
11 11
 @property (nonatomic, copy) RNNReactViewReadyCompletionBlock reactViewReadyBlock;

+ 2
- 1
lib/ios/RNNReactView.m View File

@@ -4,10 +4,11 @@
4 4
 
5 5
 @implementation RNNReactView
6 6
 
7
-- (instancetype)initWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initialProperties:(NSDictionary *)initialProperties reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
7
+- (instancetype)initWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initialProperties:(NSDictionary *)initialProperties availableSize:(CGSize)availableSize reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
8 8
 	self = [super initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
9 9
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contentDidAppear:) name:RCTContentDidAppearNotification object:nil];
10 10
 	 _reactViewReadyBlock = reactViewReadyBlock;
11
+	[bridge.uiManager setAvailableSize:availableSize forRootView:self];
11 12
 	
12 13
 	return self;
13 14
 }

+ 1
- 1
lib/ios/RNNRootViewController.m View File

@@ -97,7 +97,7 @@
97 97
 	}
98 98
 	
99 99
 	__block RNNReactViewReadyCompletionBlock readyBlockCopy = readyBlock;
100
-	UIView* reactView = [_creator createRootView:self.layoutInfo.name rootViewId:self.layoutInfo.componentId reactViewReadyBlock:^{
100
+	UIView* reactView = [_creator createRootView:self.layoutInfo.name rootViewId:self.layoutInfo.componentId availableSize:[UIScreen mainScreen].bounds.size reactViewReadyBlock:^{
101 101
 		[_presenter renderComponents:self.resolveOptions perform:^{
102 102
 			if (readyBlockCopy) {
103 103
 				readyBlockCopy();

+ 1
- 1
lib/ios/RNNRootViewCreator.h View File

@@ -5,7 +5,7 @@
5 5
 
6 6
 @protocol RNNRootViewCreator
7 7
 
8
-- (RNNReactView*)createRootView:(NSString*)name rootViewId:(NSString*)rootViewId reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock;
8
+- (RNNReactView*)createRootView:(NSString*)name rootViewId:(NSString*)rootViewId availableSize:(CGSize)availableSize reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock;
9 9
 
10 10
 - (UIView*)createRootViewFromComponentOptions:(RNNComponentOptions*)componentOptions;
11 11