Browse Source

Fixes overlay closes keyboard - #3892 (#4211)

Yogev Ben David 6 years ago
parent
commit
4527daff3d
No account linked to committer's email address

+ 1
- 13
lib/ios/RNNOverlayManager.m View File

17
 	viewController.view.backgroundColor = [UIColor clearColor];
17
 	viewController.view.backgroundColor = [UIColor clearColor];
18
 	[overlayWindow setWindowLevel:UIWindowLevelNormal];
18
 	[overlayWindow setWindowLevel:UIWindowLevelNormal];
19
 	[overlayWindow setRootViewController:viewController];
19
 	[overlayWindow setRootViewController:viewController];
20
-	[overlayWindow makeKeyAndVisible];
20
+	[overlayWindow setHidden:NO];
21
 }
21
 }
22
 
22
 
23
 - (void)dismissOverlay:(UIViewController*)viewController {
23
 - (void)dismissOverlay:(UIViewController*)viewController {
30
 - (void)detachOverlayWindow:(UIWindow *)overlayWindow {
30
 - (void)detachOverlayWindow:(UIWindow *)overlayWindow {
31
 	[overlayWindow setHidden:YES];
31
 	[overlayWindow setHidden:YES];
32
 	[overlayWindow setRootViewController:nil];
32
 	[overlayWindow setRootViewController:nil];
33
-	[overlayWindow resignKeyWindow];
34
-	[self assignKeyWindow];
35
 	[_overlayWindows removeObject:overlayWindow];
33
 	[_overlayWindows removeObject:overlayWindow];
36
 }
34
 }
37
 
35
 
38
-- (void)assignKeyWindow {
39
-	NSArray* windows = [[[UIApplication sharedApplication].windows reverseObjectEnumerator] allObjects];
40
-	for (UIWindow* window in windows) {
41
-		if (window.rootViewController) {
42
-			[window makeKeyAndVisible];
43
-			return;
44
-		}
45
-	}
46
-}
47
-
48
 - (UIWindow *)findWindowByRootViewController:(UIViewController *)viewController {
36
 - (UIWindow *)findWindowByRootViewController:(UIViewController *)viewController {
49
 	for (UIWindow* window in _overlayWindows) {
37
 	for (UIWindow* window in _overlayWindows) {
50
 		if ([window.rootViewController isEqual:viewController]) {
38
 		if ([window.rootViewController isEqual:viewController]) {

+ 52
- 40
lib/ios/ReactNativeNavigationTests/RNNOverlayManagerTest.m View File

17
 }
17
 }
18
 
18
 
19
 
19
 
20
-//- (void)testShowOverlayShouldAddWindowWithVCAsRoot {
21
-//	[_overlayManager showOverlay:_overlayVC];
22
-//	UIWindow* window = _overlayManager.overlayWindows.lastObject;
23
-//	XCTAssertTrue([window.rootViewController isEqual:_overlayVC]);
24
-//}
25
-//
26
-//- (void)testShowOverlayShouldAddVisibleWindow {
27
-//	[_overlayManager showOverlay:_overlayVC];
28
-//	UIWindow* window = _overlayManager.overlayWindows.lastObject;
29
-//	XCTAssertTrue(window.windowLevel == UIWindowLevelNormal);
30
-//	XCTAssertFalse(window.hidden);
31
-//}
32
-//
33
-//- (void)testDismissOverlayShouldCleanWindowRootVC {
34
-//	[_overlayManager showOverlay:_overlayVC];
35
-//	UIWindow* window = _overlayManager.overlayWindows.lastObject;
36
-//	[_overlayManager dismissOverlay:_overlayVC];
37
-//	XCTAssertNil(window.rootViewController);
38
-//}
39
-//
40
-//- (void)testDismissOverlayShouldHideWindow {
41
-//	[_overlayManager showOverlay:_overlayVC];
42
-//	UIWindow* window = _overlayManager.overlayWindows.lastObject;
43
-//	[_overlayManager dismissOverlay:_overlayVC];
44
-//	XCTAssertTrue(window.hidden);
45
-//}
46
-//
47
-//- (void)testDismissOverlayShouldRemoveOverlayWindow {
48
-//	[_overlayManager showOverlay:_overlayVC];
49
-//	UIWindow* window = _overlayManager.overlayWindows.lastObject;
50
-//	[_overlayManager dismissOverlay:_overlayVC];
51
-//	XCTAssertFalse([_overlayManager.overlayWindows containsObject:window]);
52
-//}
53
-//
54
-//- (void)testDismissOverlayShouldNotRemoveWrongVC {
55
-//	[_overlayManager showOverlay:_overlayVC];
56
-//	UIWindow* window = _overlayManager.overlayWindows.lastObject;
57
-//	[_overlayManager dismissOverlay:[UIViewController new]];
58
-//	XCTAssertTrue([_overlayManager.overlayWindows containsObject:window]);
59
-//}
20
+- (void)testShowOverlayShouldAddWindowWithVCAsRoot {
21
+	[_overlayManager showOverlay:_overlayVC];
22
+	UIWindow* window = _overlayManager.overlayWindows.lastObject;
23
+	XCTAssertTrue([window.rootViewController isEqual:_overlayVC]);
24
+}
25
+
26
+- (void)testShowOverlayShouldAddVisibleWindow {
27
+	[_overlayManager showOverlay:_overlayVC];
28
+	UIWindow* window = _overlayManager.overlayWindows.lastObject;
29
+	XCTAssertTrue(window.windowLevel == UIWindowLevelNormal);
30
+	XCTAssertFalse(window.hidden);
31
+}
32
+
33
+- (void)testShowOverlayShouldCreateTransparentView {
34
+	[_overlayManager showOverlay:_overlayVC];
35
+	UIWindow* window = _overlayManager.overlayWindows.lastObject;
36
+	XCTAssertTrue(window.rootViewController.view.backgroundColor == [UIColor clearColor]);
37
+}
38
+
39
+- (void)testShowOverlayShouldNotBeKeyWindow {
40
+	[_overlayManager showOverlay:_overlayVC];
41
+	UIWindow* window = _overlayManager.overlayWindows.lastObject;
42
+	XCTAssertFalse(window.keyWindow);
43
+}
44
+
45
+- (void)testDismissOverlayShouldCleanWindowRootVC {
46
+	[_overlayManager showOverlay:_overlayVC];
47
+	UIWindow* window = _overlayManager.overlayWindows.lastObject;
48
+	[_overlayManager dismissOverlay:_overlayVC];
49
+	XCTAssertNil(window.rootViewController);
50
+}
51
+
52
+- (void)testDismissOverlayShouldHideWindow {
53
+	[_overlayManager showOverlay:_overlayVC];
54
+	UIWindow* window = _overlayManager.overlayWindows.lastObject;
55
+	[_overlayManager dismissOverlay:_overlayVC];
56
+	XCTAssertTrue(window.hidden);
57
+}
58
+
59
+- (void)testDismissOverlayShouldRemoveOverlayWindow {
60
+	[_overlayManager showOverlay:_overlayVC];
61
+	UIWindow* window = _overlayManager.overlayWindows.lastObject;
62
+	[_overlayManager dismissOverlay:_overlayVC];
63
+	XCTAssertFalse([_overlayManager.overlayWindows containsObject:window]);
64
+}
65
+
66
+- (void)testDismissOverlayShouldNotRemoveWrongVC {
67
+	[_overlayManager showOverlay:_overlayVC];
68
+	UIWindow* window = _overlayManager.overlayWindows.lastObject;
69
+	[_overlayManager dismissOverlay:[UIViewController new]];
70
+	XCTAssertTrue([_overlayManager.overlayWindows containsObject:window]);
71
+}
60
 
72
 
61
 @end
73
 @end