Browse Source

e2e overlay fix

yogevbd 6 years ago
parent
commit
17286fb55f
1 changed files with 10 additions and 4 deletions
  1. 10
    4
      lib/ios/RNNOverlayManager.m

+ 10
- 4
lib/ios/RNNOverlayManager.m View File

@@ -6,6 +6,7 @@
6 6
 	NSMutableDictionary* _overlayDict;
7 7
 	RNNStore* _store;
8 8
 	RNNOverlayWindow *_overlayWindow;
9
+	UIWindow *_previousWindow;
9 10
 }
10 11
 
11 12
 - (instancetype)initWithStore:(RNNStore *)store {
@@ -19,6 +20,7 @@
19 20
 
20 21
 - (void)showOverlay:(RNNRootViewController *)viewController completion:(RNNTransitionCompletionBlock)completion {
21 22
 	[self cacheOverlay:viewController];
23
+	_previousWindow = [UIApplication sharedApplication].keyWindow;
22 24
 	_overlayWindow = [[RNNOverlayWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
23 25
 	[_overlayWindow setWindowLevel:UIWindowLevelNormal];
24 26
 	[_overlayWindow setRootViewController:viewController];
@@ -30,6 +32,7 @@
30 32
 - (void)dismissOverlay:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
31 33
 	RNNRootViewController* viewController = [_overlayDict objectForKey:componentId];
32 34
 	if (viewController) {
35
+		[self detachOverlayWindow];
33 36
 		[self removeCachedOverlay:viewController];
34 37
 		completion();
35 38
 	} else {
@@ -44,12 +47,15 @@
44 47
 }
45 48
 
46 49
 - (void)removeCachedOverlay:(RNNRootViewController*)viewController {
47
-	[_overlayWindow setRootViewController:nil];
48
-	[_overlayWindow resignKeyWindow];
49
-	_overlayWindow = nil;
50
-	
51 50
 	[_overlayDict removeObjectForKey:viewController.componentId];
52 51
 	[_store removeComponent:viewController.componentId];
53 52
 }
54 53
 
54
+- (void)detachOverlayWindow {
55
+	[_overlayWindow setRootViewController:nil];
56
+	_overlayWindow = nil;
57
+	[_previousWindow makeKeyAndVisible];
58
+	_previousWindow = nil;
59
+}
60
+
55 61
 @end