Ran Greenberg vor 7 Jahren
Ursprung
Commit
37bf8666e0

+ 18
- 10
ios/RNNBridgeModule.m Datei anzeigen

@@ -49,11 +49,7 @@ 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
-	UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
53
-	while(root.presentedViewController) {
54
-		root = root.presentedViewController;
55
-	}
56
-	
52
+	UIViewController *root = [self topPresentedVC];
57 53
 	[root presentViewController:newVc animated:YES completion:^{
58 54
 		
59 55
 	}];
@@ -63,14 +59,18 @@ RCT_EXPORT_METHOD(dismissModal:(NSString*)containerId)
63 59
 {
64 60
 	UIViewController *root = [[RNN instance].store findContainerForId:containerId];
65 61
 	
66
-	//	while(root.presentedViewController) {
67
-	//		root = root.presentedViewController;
68
-	//	}
69 62
 	if (root) {
63
+		UIViewController *topVC = [self topPresentedVC];
70 64
 		
71
-		[root dismissViewControllerAnimated:YES completion:^{
65
+		if (root == topVC) {
66
+			[root dismissViewControllerAnimated:YES completion:nil];
67
+			[[RNN instance].store.modalToDismiss dismissViewControllerAnimated:YES completion:nil];
68
+			[RNN instance].store.modalToDismiss = nil;
72 69
 			
73
-		}];
70
+		}
71
+		else {
72
+			[RNN instance].store.modalToDismiss = root;
73
+		}
74 74
 	}
75 75
 }
76 76
 
@@ -81,5 +81,13 @@ RCT_EXPORT_METHOD(dismissModal:(NSString*)containerId)
81 81
 	}
82 82
 }
83 83
 
84
+-(UIViewController*)topPresentedVC {
85
+	UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
86
+	while(root.presentedViewController) {
87
+		root = root.presentedViewController;
88
+	}
89
+	return root;
90
+}
91
+
84 92
 @end
85 93
 

+ 2
- 0
ios/RNNStore.h Datei anzeigen

@@ -12,6 +12,8 @@
12 12
 
13 13
 @interface RNNStore : NSObject
14 14
 
15
+@property UIViewController *modalToDismiss;
16
+
15 17
 - (UIViewController*)findContainerForId:(NSString*)containerId;
16 18
 - (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId;
17 19
 - (void)removeContainer:(NSString*)containerId;

+ 2
- 2
ios/ReactNativeNavigation.xcodeproj/project.pbxproj Datei anzeigen

@@ -236,8 +236,6 @@
236 236
 				263905D51E4C94970023D7D3 /* RNNSideMenuController.m */,
237 237
 				263905E41E4CAC950023D7D3 /* RNNSideMenuChildVC.h */,
238 238
 				263905E51E4CAC950023D7D3 /* RNNSideMenuChildVC.m */,
239
-				268692801E5054F800E2C612 /* RNNStore.h */,
240
-				268692811E5054F800E2C612 /* RNNStore.m */,
241 239
 			);
242 240
 			name = Controllers;
243 241
 			sourceTree = "<group>";
@@ -260,6 +258,8 @@
260 258
 				7BA500741E2544B9001B9E1B /* ReactNativeNavigation.m */,
261 259
 				7BBFE55F1E253F97002A6182 /* RNN.h */,
262 260
 				7BBFE5601E253F97002A6182 /* RNN.m */,
261
+				268692801E5054F800E2C612 /* RNNStore.h */,
262
+				268692811E5054F800E2C612 /* RNNStore.m */,
263 263
 				7BD721F31E2D3AA100724059 /* Bridge */,
264 264
 				7B1E4C4B1E2D173700C3A525 /* Controllers */,
265 265
 				263905881E4C6F440023D7D3 /* RNNSideMenu */,

+ 1
- 1
playground/e2e/app.test.js Datei anzeigen

@@ -71,7 +71,7 @@ describe('app', () => {
71 71
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
72 72
   });
73 73
 
74
-  xit('dismiss modal by id', () => {
74
+  it('dismiss modal by id which is not the top most', () => {
75 75
     elementByLabel('Show Modal').tap();
76 76
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
77 77
     elementByLabel('Show Modal').tap();

+ 3
- 0
playground/ios/playground.xcodeproj/project.pbxproj Datei anzeigen

@@ -525,6 +525,7 @@
525 525
 				TargetAttributes = {
526 526
 					00E356ED1AD99517003FC87E = {
527 527
 						CreatedOnToolsVersion = 6.2;
528
+						ProvisioningStyle = Manual;
528 529
 						TestTargetID = 13B07F861A680F5B00A75B9A;
529 530
 					};
530 531
 					13B07F861A680F5B00A75B9A = {
@@ -877,6 +878,7 @@
877 878
 			isa = XCBuildConfiguration;
878 879
 			buildSettings = {
879 880
 				BUNDLE_LOADER = "$(TEST_HOST)";
881
+				DEVELOPMENT_TEAM = "";
880 882
 				GCC_PREPROCESSOR_DEFINITIONS = (
881 883
 					"DEBUG=1",
882 884
 					"$(inherited)",
@@ -896,6 +898,7 @@
896 898
 			buildSettings = {
897 899
 				BUNDLE_LOADER = "$(TEST_HOST)";
898 900
 				COPY_PHASE_STRIP = NO;
901
+				DEVELOPMENT_TEAM = "";
899 902
 				HEADER_SEARCH_PATHS = "${SRCROOT}/../node_modules/react-native-navigation/ios/**";
900 903
 				INFOPLIST_FILE = playgroundTests/Info.plist;
901 904
 				IPHONEOS_DEPLOYMENT_TARGET = 8.2;