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