1234567891011121314151617181920212223242526272829303132 |
- #import "RNNNavigationStackManager.h"
-
- @implementation RNNNavigationStackManager {
- RNNStore *_store;
- }
-
- -(instancetype)initWithStore:(RNNStore*)store {
- self = [super init];
- _store = store;
- return self;
- }
-
- -(void)push:(UIViewController *)newTop onTop:(NSString *)containerId {
- UIViewController *vc = [_store findContainerForId:containerId];
- [[vc navigationController] pushViewController:newTop animated:true];
- }
-
- -(void)pop:(NSString *)containerId {
- UIViewController* vc = [_store findContainerForId:containerId];
- UINavigationController* nvc = [vc navigationController];
- if ([nvc topViewController] == vc) {
- [nvc popViewControllerAnimated:true];
- } else {
- NSMutableArray * vcs = nvc.viewControllers.mutableCopy;
- [vcs removeObject:vc];
- [nvc setViewControllers:vcs animated:true];
- }
- [_store removeContainer:containerId];
- }
-
- @end
|