yogevbd 6 years ago
parent
commit
bb6cbb5047

+ 8
- 0
e2e/OverlayTest.test.js View File

32
     await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
32
     await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
33
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
33
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
34
   });
34
   });
35
+
36
+  it('overlay should redraw after orientation change', async () => {
37
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
38
+    await elementById(testIDs.SHOW_OVERLAY_BUTTON).tap();
39
+    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
40
+    await device.setOrientation('landscape');
41
+    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
42
+  });
35
 });
43
 });

+ 4
- 0
lib/ios/RNNControllerFactory.m View File

191
 - (UIViewController<RNNRootViewProtocol> *)createOverlay:(NSDictionary*)layout {
191
 - (UIViewController<RNNRootViewProtocol> *)createOverlay:(NSDictionary*)layout {
192
 	UIViewController<RNNRootViewProtocol> *vc = [self fromTree:layout];
192
 	UIViewController<RNNRootViewProtocol> *vc = [self fromTree:layout];
193
 	RCTRootView* rootView = (RCTRootView*)vc.view;
193
 	RCTRootView* rootView = (RCTRootView*)vc.view;
194
+	[vc performOnRotation:^{
195
+		CGSize availableSize = UIApplication.sharedApplication.delegate.window.bounds.size;
196
+		[_bridge.uiManager setSize:availableSize forView:vc.view];
197
+	}];
194
 	rootView.backgroundColor = [UIColor clearColor];
198
 	rootView.backgroundColor = [UIColor clearColor];
195
 	CGSize availableSize = UIApplication.sharedApplication.delegate.window.bounds.size;
199
 	CGSize availableSize = UIApplication.sharedApplication.delegate.window.bounds.size;
196
 	rootView.frame = CGRectMake(0, 0, availableSize.width, availableSize.height);
200
 	rootView.frame = CGRectMake(0, 0, availableSize.width, availableSize.height);

+ 16
- 3
lib/ios/RNNRootViewController.m View File

10
 @property (nonatomic) BOOL _statusBarHidden;
10
 @property (nonatomic) BOOL _statusBarHidden;
11
 @property (nonatomic) BOOL isExternalComponent;
11
 @property (nonatomic) BOOL isExternalComponent;
12
 @property (nonatomic) BOOL _optionsApplied;
12
 @property (nonatomic) BOOL _optionsApplied;
13
+@property (nonatomic, copy) void (^rotationBlock)(void);
13
 @end
14
 @end
14
 
15
 
15
 @implementation RNNRootViewController
16
 @implementation RNNRootViewController
19
 			withComponentId:(NSString*)componentId
20
 			withComponentId:(NSString*)componentId
20
 			rootViewCreator:(id<RNNRootViewCreator>)creator
21
 			rootViewCreator:(id<RNNRootViewCreator>)creator
21
 			   eventEmitter:(RNNEventEmitter*)eventEmitter
22
 			   eventEmitter:(RNNEventEmitter*)eventEmitter
22
-		  isExternalComponent:(BOOL)isExternalComponent {
23
+		isExternalComponent:(BOOL)isExternalComponent {
23
 	self = [super init];
24
 	self = [super init];
24
 	self.componentId = componentId;
25
 	self.componentId = componentId;
25
 	self.componentName = name;
26
 	self.componentName = name;
28
 	self.animator = [[RNNAnimator alloc] initWithTransitionOptions:self.options.customTransition];
29
 	self.animator = [[RNNAnimator alloc] initWithTransitionOptions:self.options.customTransition];
29
 	self.creator = creator;
30
 	self.creator = creator;
30
 	self.isExternalComponent = isExternalComponent;
31
 	self.isExternalComponent = isExternalComponent;
31
-
32
+	
32
 	if (!self.isExternalComponent) {
33
 	if (!self.isExternalComponent) {
33
 		self.view = [creator createRootView:self.componentName rootViewId:self.componentId];
34
 		self.view = [creator createRootView:self.componentName rootViewId:self.componentId];
34
 	}
35
 	}
38
 												 name:RCTJavaScriptWillStartLoadingNotification
39
 												 name:RCTJavaScriptWillStartLoadingNotification
39
 											   object:nil];
40
 											   object:nil];
40
 	self.navigationController.delegate = self;
41
 	self.navigationController.delegate = self;
41
-
42
+	[[NSNotificationCenter defaultCenter] addObserver:self
43
+											 selector:@selector(orientationDidChange:)
44
+												 name:UIDeviceOrientationDidChangeNotification
45
+											   object:nil];
42
 	return self;
46
 	return self;
43
 }
47
 }
44
 
48
 
199
 	[self.options.topTab applyOn:self];
203
 	[self.options.topTab applyOn:self];
200
 }
204
 }
201
 
205
 
206
+- (void)performOnRotation:(void (^)(void))block {
207
+	_rotationBlock = block;
208
+}
209
+
210
+- (void)orientationDidChange:(NSNotification*)notification {
211
+	if (_rotationBlock) {
212
+		_rotationBlock();
213
+	}
214
+}
202
 
215
 
203
 /**
216
 /**
204
  *	fix for #877, #878
217
  *	fix for #877, #878

+ 1
- 0
lib/ios/RNNRootViewProtocol.h View File

6
 - (void)mergeOptions:(NSDictionary*)options;
6
 - (void)mergeOptions:(NSDictionary*)options;
7
 - (BOOL)isCustomViewController;
7
 - (BOOL)isCustomViewController;
8
 - (void)optionsUpdated;
8
 - (void)optionsUpdated;
9
+- (void)performOnRotation:(void (^)(void))block;
9
 
10
 
10
 @required
11
 @required
11
 - (BOOL)isCustomTransitioned;
12
 - (BOOL)isCustomTransitioned;