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
 	return self;
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
 	if (!rootViewId) {
18
 	if (!rootViewId) {
19
 		@throw [NSException exceptionWithName:@"MissingViewId" reason:@"Missing view id" userInfo:nil];
19
 		@throw [NSException exceptionWithName:@"MissingViewId" reason:@"Missing view id" userInfo:nil];
20
 	}
20
 	}
21
 	
21
 	
22
 	RNNReactView *view = [[RNNReactView alloc] initWithBridge:_bridge
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
 	return view;
27
 	return view;
27
 }
28
 }
28
 
29
 
29
 - (UIView*)createRootViewFromComponentOptions:(RNNComponentOptions*)componentOptions {
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
 - (UIView*)createRootViewFromComponentOptions:(RNNComponentOptions*)componentOptions reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
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
 @end
38
 @end

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

5
 
5
 
6
 @interface RNNReactView : RCTRootView <RCTRootViewDelegate>
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
 @property (nonatomic, copy) void (^rootViewDidChangeIntrinsicSize)(CGSize intrinsicSize);
10
 @property (nonatomic, copy) void (^rootViewDidChangeIntrinsicSize)(CGSize intrinsicSize);
11
 @property (nonatomic, copy) RNNReactViewReadyCompletionBlock reactViewReadyBlock;
11
 @property (nonatomic, copy) RNNReactViewReadyCompletionBlock reactViewReadyBlock;

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

4
 
4
 
5
 @implementation RNNReactView
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
 	self = [super initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
8
 	self = [super initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
9
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contentDidAppear:) name:RCTContentDidAppearNotification object:nil];
9
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contentDidAppear:) name:RCTContentDidAppearNotification object:nil];
10
 	 _reactViewReadyBlock = reactViewReadyBlock;
10
 	 _reactViewReadyBlock = reactViewReadyBlock;
11
+	[bridge.uiManager setAvailableSize:availableSize forRootView:self];
11
 	
12
 	
12
 	return self;
13
 	return self;
13
 }
14
 }

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

97
 	}
97
 	}
98
 	
98
 	
99
 	__block RNNReactViewReadyCompletionBlock readyBlockCopy = readyBlock;
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
 		[_presenter renderComponents:self.resolveOptions perform:^{
101
 		[_presenter renderComponents:self.resolveOptions perform:^{
102
 			if (readyBlockCopy) {
102
 			if (readyBlockCopy) {
103
 				readyBlockCopy();
103
 				readyBlockCopy();

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

5
 
5
 
6
 @protocol RNNRootViewCreator
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
 - (UIView*)createRootViewFromComponentOptions:(RNNComponentOptions*)componentOptions;
10
 - (UIView*)createRootViewFromComponentOptions:(RNNComponentOptions*)componentOptions;
11
 
11