yogevbd 6 years ago
parent
commit
bb6cbb5047

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

@@ -32,4 +32,12 @@ describe('Overlay', () => {
32 32
     await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
33 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,6 +191,10 @@
191 191
 - (UIViewController<RNNRootViewProtocol> *)createOverlay:(NSDictionary*)layout {
192 192
 	UIViewController<RNNRootViewProtocol> *vc = [self fromTree:layout];
193 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 198
 	rootView.backgroundColor = [UIColor clearColor];
195 199
 	CGSize availableSize = UIApplication.sharedApplication.delegate.window.bounds.size;
196 200
 	rootView.frame = CGRectMake(0, 0, availableSize.width, availableSize.height);

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

@@ -10,6 +10,7 @@
10 10
 @property (nonatomic) BOOL _statusBarHidden;
11 11
 @property (nonatomic) BOOL isExternalComponent;
12 12
 @property (nonatomic) BOOL _optionsApplied;
13
+@property (nonatomic, copy) void (^rotationBlock)(void);
13 14
 @end
14 15
 
15 16
 @implementation RNNRootViewController
@@ -19,7 +20,7 @@
19 20
 			withComponentId:(NSString*)componentId
20 21
 			rootViewCreator:(id<RNNRootViewCreator>)creator
21 22
 			   eventEmitter:(RNNEventEmitter*)eventEmitter
22
-		  isExternalComponent:(BOOL)isExternalComponent {
23
+		isExternalComponent:(BOOL)isExternalComponent {
23 24
 	self = [super init];
24 25
 	self.componentId = componentId;
25 26
 	self.componentName = name;
@@ -28,7 +29,7 @@
28 29
 	self.animator = [[RNNAnimator alloc] initWithTransitionOptions:self.options.customTransition];
29 30
 	self.creator = creator;
30 31
 	self.isExternalComponent = isExternalComponent;
31
-
32
+	
32 33
 	if (!self.isExternalComponent) {
33 34
 		self.view = [creator createRootView:self.componentName rootViewId:self.componentId];
34 35
 	}
@@ -38,7 +39,10 @@
38 39
 												 name:RCTJavaScriptWillStartLoadingNotification
39 40
 											   object:nil];
40 41
 	self.navigationController.delegate = self;
41
-
42
+	[[NSNotificationCenter defaultCenter] addObserver:self
43
+											 selector:@selector(orientationDidChange:)
44
+												 name:UIDeviceOrientationDidChangeNotification
45
+											   object:nil];
42 46
 	return self;
43 47
 }
44 48
 
@@ -199,6 +203,15 @@
199 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 217
  *	fix for #877, #878

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

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