Browse Source

support multiple modals shows

Ran Greenberg 7 years ago
parent
commit
7b36884e3b
2 changed files with 14 additions and 3 deletions
  1. 13
    2
      ios/RNNBridgeModule.m
  2. 1
    1
      playground/e2e/app.test.js

+ 13
- 2
ios/RNNBridgeModule.m View File

49
 	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new] store:[RNN instance].store];
49
 	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new] store:[RNN instance].store];
50
 	UIViewController *newVc = [factory createLayoutAndSaveToStore:layout];
50
 	UIViewController *newVc = [factory createLayoutAndSaveToStore:layout];
51
 	
51
 	
52
-	[UIApplication.sharedApplication.delegate.window.rootViewController presentViewController:newVc animated:YES completion:^{
52
+	UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
53
+	while(root.presentedViewController) {
54
+		root = root.presentedViewController;
55
+	}
56
+	
57
+	[root presentViewController:newVc animated:YES completion:^{
53
 		
58
 		
54
 	}];
59
 	}];
55
 }
60
 }
56
 
61
 
57
 RCT_EXPORT_METHOD(dismissModal:(NSString*)containerId)
62
 RCT_EXPORT_METHOD(dismissModal:(NSString*)containerId)
58
 {
63
 {
59
-	[UIApplication.sharedApplication.delegate.window.rootViewController dismissViewControllerAnimated:YES completion:^{
64
+	UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
65
+	while(root.presentedViewController) {
66
+		root = root.presentedViewController;
67
+	}
68
+
69
+	
70
+	[root dismissViewControllerAnimated:YES completion:^{
60
 		
71
 		
61
 	}];
72
 	}];
62
 }
73
 }

+ 1
- 1
playground/e2e/app.test.js View File

51
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
51
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
52
   });
52
   });
53
 
53
 
54
-  xit('show multiple modals', () => {
54
+  it('show multiple modals', () => {
55
     elementByLabel('Show Modal').tap();
55
     elementByLabel('Show Modal').tap();
56
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
56
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
57
     elementByLabel('Show Modal').tap();
57
     elementByLabel('Show Modal').tap();