Selaa lähdekoodia

support multiple modals shows

Ran Greenberg 7 vuotta sitten
vanhempi
commit
7b36884e3b
2 muutettua tiedostoa jossa 14 lisäystä ja 3 poistoa
  1. 13
    2
      ios/RNNBridgeModule.m
  2. 1
    1
      playground/e2e/app.test.js

+ 13
- 2
ios/RNNBridgeModule.m Näytä tiedosto

@@ -49,14 +49,25 @@ RCT_EXPORT_METHOD(showModal:(NSDictionary*)layout)
49 49
 	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new] store:[RNN instance].store];
50 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 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 Näytä tiedosto

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