react-native-navigation的迁移库

RNNNavigationStackManager.m 845B

1234567891011121314151617181920212223242526272829303132
  1. #import "RNNNavigationStackManager.h"
  2. @implementation RNNNavigationStackManager {
  3. RNNStore *_store;
  4. }
  5. -(instancetype)initWithStore:(RNNStore*)store {
  6. self = [super init];
  7. _store = store;
  8. return self;
  9. }
  10. -(void)push:(UIViewController *)newTop onTop:(NSString *)containerId {
  11. UIViewController *vc = [_store findContainerForId:containerId];
  12. [[vc navigationController] pushViewController:newTop animated:true];
  13. }
  14. -(void)pop:(NSString *)containerId {
  15. UIViewController* vc = [_store findContainerForId:containerId];
  16. UINavigationController* nvc = [vc navigationController];
  17. if ([nvc topViewController] == vc) {
  18. [nvc popViewControllerAnimated:true];
  19. } else {
  20. NSMutableArray * vcs = nvc.viewControllers.mutableCopy;
  21. [vcs removeObject:vc];
  22. [nvc setViewControllers:vcs animated:true];
  23. }
  24. [_store removeContainer:containerId];
  25. }
  26. @end