Ran Greenberg 7 years ago
parent
commit
64cab21474

+ 4
- 11
ios/RNNBridgeModule.m View File

5
 #import "RNNReactRootViewCreator.h"
5
 #import "RNNReactRootViewCreator.h"
6
 #import "RNNStore.h"
6
 #import "RNNStore.h"
7
 #import "RNNModalManager.h"
7
 #import "RNNModalManager.h"
8
+#import "RNNNavigationStackManager.h"
8
 
9
 
9
 @implementation RNNBridgeModule
10
 @implementation RNNBridgeModule
10
 
11
 
31
 	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new] store:[RNN instance].store];
32
 	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new] store:[RNN instance].store];
32
 	UIViewController *newVc = [factory createLayoutAndSaveToStore:layout];
33
 	UIViewController *newVc = [factory createLayoutAndSaveToStore:layout];
33
 	UIViewController *vc = [[RNN instance].store findContainerForId:containerId];
34
 	UIViewController *vc = [[RNN instance].store findContainerForId:containerId];
34
-	
35
-	[[vc navigationController] pushViewController:newVc animated:true];
35
+
36
+	[[[RNNNavigationStackManager alloc] initWithStore:[RNN instance].store] push:newVc onTop:vc animated:YES];
36
 }
37
 }
37
 
38
 
38
 RCT_EXPORT_METHOD(pop:(NSString*)containerId)
39
 RCT_EXPORT_METHOD(pop:(NSString*)containerId)
39
 {
40
 {
40
 	[self assertReady];
41
 	[self assertReady];
41
 	UIViewController *vc = [[RNN instance].store findContainerForId:containerId];
42
 	UIViewController *vc = [[RNN instance].store findContainerForId:containerId];
42
-	
43
-	if([[vc navigationController] topViewController] == vc ) {
44
-		[[vc navigationController] popViewControllerAnimated:YES];
45
-	}
46
-	else {
47
-		NSMutableArray * vcs = [vc navigationController].viewControllers.mutableCopy;
48
-		[vcs removeObject:vc];
49
-		[[vc navigationController] setViewControllers:vcs animated:NO];
50
-	}
43
+	[[[RNNNavigationStackManager alloc] initWithStore:[RNN instance].store] pop:vc animated:YES];
51
 	[[RNN instance].store removeContainer:containerId];
44
 	[[RNN instance].store removeContainer:containerId];
52
 }
45
 }
53
 
46
 

+ 0
- 1
ios/RNNModalManager.h View File

6
 
6
 
7
 -(instancetype)initWithStore:(RNNStore*)store;
7
 -(instancetype)initWithStore:(RNNStore*)store;
8
 
8
 
9
-
10
 -(void)showModal:(UIViewController*)viewController;
9
 -(void)showModal:(UIViewController*)viewController;
11
 -(void)dismissModal:(NSString*)containerId;
10
 -(void)dismissModal:(NSString*)containerId;
12
 -(void)dismissAllModals;
11
 -(void)dismissAllModals;

+ 12
- 0
ios/RNNNavigationStackManager.h View File

1
+#import <Foundation/Foundation.h>
2
+#import <UIKit/UIKit.h>
3
+#import "RNNStore.h"
4
+
5
+@interface RNNNavigationStackManager : NSObject
6
+
7
+-(instancetype)initWithStore:(RNNStore*)store;
8
+
9
+-(void)push:(UIViewController*)newTop onTop:(UIViewController*)currentTop animated:(BOOL)animated;
10
+-(void)pop:(UIViewController*)vc animated:(BOOL)animated;
11
+
12
+@end

+ 39
- 0
ios/RNNNavigationStackManager.m View File

1
+#import "RNNNavigationStackManager.h"
2
+
3
+@interface RNNNavigationStackManager ()
4
+
5
+@property RNNStore *store;
6
+
7
+@end
8
+
9
+
10
+@implementation RNNNavigationStackManager
11
+
12
+
13
+-(instancetype)initWithStore:(RNNStore*)store {
14
+	self = [super init];
15
+	self.store = store;
16
+	return self;
17
+}
18
+
19
+-(void)push:(UIViewController*)newTop onTop:(UIViewController*)currentTop animated:(BOOL)animated{
20
+	
21
+	[[currentTop navigationController] pushViewController:newTop animated:animated];
22
+}
23
+
24
+
25
+-(void)pop:(UIViewController*)vc animated:(BOOL)animated{
26
+	
27
+	if([[vc navigationController] topViewController] == vc ) {
28
+		[[vc navigationController] popViewControllerAnimated:animated];
29
+	}
30
+	else {
31
+		NSMutableArray * vcs = [vc navigationController].viewControllers.mutableCopy;
32
+		[vcs removeObject:vc];
33
+		[[vc navigationController] setViewControllers:vcs animated:animated];
34
+	}
35
+}
36
+
37
+
38
+
39
+@end

+ 8
- 0
ios/ReactNativeNavigation.xcodeproj/project.pbxproj View File

9
 /* Begin PBXBuildFile section */
9
 /* Begin PBXBuildFile section */
10
 		261F0E641E6EC94900989DE2 /* RNNModalManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 261F0E621E6EC94900989DE2 /* RNNModalManager.h */; };
10
 		261F0E641E6EC94900989DE2 /* RNNModalManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 261F0E621E6EC94900989DE2 /* RNNModalManager.h */; };
11
 		261F0E651E6EC94900989DE2 /* RNNModalManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 261F0E631E6EC94900989DE2 /* RNNModalManager.m */; };
11
 		261F0E651E6EC94900989DE2 /* RNNModalManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 261F0E631E6EC94900989DE2 /* RNNModalManager.m */; };
12
+		261F0E6A1E6F028A00989DE2 /* RNNNavigationStackManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 261F0E681E6F028A00989DE2 /* RNNNavigationStackManager.h */; };
13
+		261F0E6B1E6F028A00989DE2 /* RNNNavigationStackManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 261F0E691E6F028A00989DE2 /* RNNNavigationStackManager.m */; };
12
 		263905AE1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 2639058A1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h */; };
14
 		263905AE1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 2639058A1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h */; };
13
 		263905AF1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 2639058B1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m */; };
15
 		263905AF1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 2639058B1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m */; };
14
 		263905B01E4C6F440023D7D3 /* MMDrawerController+Subclass.h in Headers */ = {isa = PBXBuildFile; fileRef = 2639058C1E4C6F440023D7D3 /* MMDrawerController+Subclass.h */; };
16
 		263905B01E4C6F440023D7D3 /* MMDrawerController+Subclass.h in Headers */ = {isa = PBXBuildFile; fileRef = 2639058C1E4C6F440023D7D3 /* MMDrawerController+Subclass.h */; };
84
 /* Begin PBXFileReference section */
86
 /* Begin PBXFileReference section */
85
 		261F0E621E6EC94900989DE2 /* RNNModalManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNModalManager.h; sourceTree = "<group>"; };
87
 		261F0E621E6EC94900989DE2 /* RNNModalManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNModalManager.h; sourceTree = "<group>"; };
86
 		261F0E631E6EC94900989DE2 /* RNNModalManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNModalManager.m; sourceTree = "<group>"; };
88
 		261F0E631E6EC94900989DE2 /* RNNModalManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNModalManager.m; sourceTree = "<group>"; };
89
+		261F0E681E6F028A00989DE2 /* RNNNavigationStackManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNNavigationStackManager.h; sourceTree = "<group>"; };
90
+		261F0E691E6F028A00989DE2 /* RNNNavigationStackManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNNavigationStackManager.m; sourceTree = "<group>"; };
87
 		2639058A1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerBarButtonItem.h; sourceTree = "<group>"; };
91
 		2639058A1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerBarButtonItem.h; sourceTree = "<group>"; };
88
 		2639058B1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerBarButtonItem.m; sourceTree = "<group>"; };
92
 		2639058B1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerBarButtonItem.m; sourceTree = "<group>"; };
89
 		2639058C1E4C6F440023D7D3 /* MMDrawerController+Subclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MMDrawerController+Subclass.h"; sourceTree = "<group>"; };
93
 		2639058C1E4C6F440023D7D3 /* MMDrawerController+Subclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MMDrawerController+Subclass.h"; sourceTree = "<group>"; };
227
 			children = (
231
 			children = (
228
 				261F0E621E6EC94900989DE2 /* RNNModalManager.h */,
232
 				261F0E621E6EC94900989DE2 /* RNNModalManager.h */,
229
 				261F0E631E6EC94900989DE2 /* RNNModalManager.m */,
233
 				261F0E631E6EC94900989DE2 /* RNNModalManager.m */,
234
+				261F0E681E6F028A00989DE2 /* RNNNavigationStackManager.h */,
235
+				261F0E691E6F028A00989DE2 /* RNNNavigationStackManager.m */,
230
 				26916C941E4B9CCC00D13680 /* RNNRootViewCreator.h */,
236
 				26916C941E4B9CCC00D13680 /* RNNRootViewCreator.h */,
231
 				26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */,
237
 				26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */,
232
 				26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */,
238
 				26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */,
291
 			isa = PBXHeadersBuildPhase;
297
 			isa = PBXHeadersBuildPhase;
292
 			buildActionMask = 2147483647;
298
 			buildActionMask = 2147483647;
293
 			files = (
299
 			files = (
300
+				261F0E6A1E6F028A00989DE2 /* RNNNavigationStackManager.h in Headers */,
294
 				26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */,
301
 				26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */,
295
 				263905B01E4C6F440023D7D3 /* MMDrawerController+Subclass.h in Headers */,
302
 				263905B01E4C6F440023D7D3 /* MMDrawerController+Subclass.h in Headers */,
296
 				7B1126A41E2D2B6C00F9B03B /* ReactNativeNavigation.h in Headers */,
303
 				7B1126A41E2D2B6C00F9B03B /* ReactNativeNavigation.h in Headers */,
387
 				263905C51E4C6F440023D7D3 /* SidebarFacebookAnimation.m in Sources */,
394
 				263905C51E4C6F440023D7D3 /* SidebarFacebookAnimation.m in Sources */,
388
 				7BEF0D191E437684003E96B0 /* RNNRootViewController.m in Sources */,
395
 				7BEF0D191E437684003E96B0 /* RNNRootViewController.m in Sources */,
389
 				263905C31E4C6F440023D7D3 /* SidebarAnimation.m in Sources */,
396
 				263905C31E4C6F440023D7D3 /* SidebarAnimation.m in Sources */,
397
+				261F0E6B1E6F028A00989DE2 /* RNNNavigationStackManager.m in Sources */,
390
 				263905BF1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.m in Sources */,
398
 				263905BF1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.m in Sources */,
391
 				7B1126A01E2D263F00F9B03B /* RNNEventEmitter.m in Sources */,
399
 				7B1126A01E2D263F00F9B03B /* RNNEventEmitter.m in Sources */,
392
 				263905CB1E4C6F440023D7D3 /* SidebarLuvocracyAnimation.m in Sources */,
400
 				263905CB1E4C6F440023D7D3 /* SidebarLuvocracyAnimation.m in Sources */,