Ran Greenberg 7 years ago
parent
commit
37bf8666e0

+ 18
- 10
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
-	UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
53
-	while(root.presentedViewController) {
54
-		root = root.presentedViewController;
55
-	}
56
-	
52
+	UIViewController *root = [self topPresentedVC];
57
 	[root presentViewController:newVc animated:YES completion:^{
53
 	[root presentViewController:newVc animated:YES completion:^{
58
 		
54
 		
59
 	}];
55
 	}];
63
 {
59
 {
64
 	UIViewController *root = [[RNN instance].store findContainerForId:containerId];
60
 	UIViewController *root = [[RNN instance].store findContainerForId:containerId];
65
 	
61
 	
66
-	//	while(root.presentedViewController) {
67
-	//		root = root.presentedViewController;
68
-	//	}
69
 	if (root) {
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
 	}
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
 @end
92
 @end
85
 
93
 

+ 2
- 0
ios/RNNStore.h View File

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

+ 2
- 2
ios/ReactNativeNavigation.xcodeproj/project.pbxproj View File

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

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

71
     expect(elementByLabel('React Native Navigation!')).toBeVisible();
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
     elementByLabel('Show Modal').tap();
75
     elementByLabel('Show Modal').tap();
76
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
76
     expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
77
     elementByLabel('Show Modal').tap();
77
     elementByLabel('Show Modal').tap();

+ 3
- 0
playground/ios/playground.xcodeproj/project.pbxproj View File

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