react-native-navigation的迁移库

RNNNavigationController.m 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #import "RNNNavigationController.h"
  2. #import "RNNModalAnimation.h"
  3. @implementation RNNNavigationController
  4. - (instancetype)initWithOptions:(RNNNavigationOptions *)options {
  5. self = [super init];
  6. if (self) {
  7. _options = options;
  8. }
  9. return self;
  10. }
  11. - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
  12. return self.viewControllers.lastObject.supportedInterfaceOrientations;
  13. }
  14. - (UINavigationController *)navigationController {
  15. return self;
  16. }
  17. - (UIStatusBarStyle)preferredStatusBarStyle {
  18. return self.getLeafViewController.preferredStatusBarStyle;
  19. }
  20. - (UIModalPresentationStyle)modalPresentationStyle {
  21. return self.getLeafViewController.modalPresentationStyle;
  22. }
  23. - (UIViewController *)popViewControllerAnimated:(BOOL)animated {
  24. if (self.viewControllers.count > 1) {
  25. UIViewController *controller = self.viewControllers[self.viewControllers.count - 2];
  26. if ([controller isKindOfClass:[RNNRootViewController class]]) {
  27. RNNRootViewController *rnnController = (RNNRootViewController *)controller;
  28. [rnnController.options applyOn:rnnController];
  29. }
  30. }
  31. return [super popViewControllerAnimated:animated];
  32. }
  33. - (NSString *)componentId {
  34. return _componentId ? _componentId : self.getLeafViewController.componentId;
  35. }
  36. - (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
  37. return [[RNNModalAnimation alloc] initWithScreenTransition:self.getLeafViewController.options.animations.showModal isDismiss:NO];
  38. }
  39. - (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
  40. return [[RNNModalAnimation alloc] initWithScreenTransition:self.getLeafViewController.options.animations.dismissModal isDismiss:YES];
  41. }
  42. - (UIViewController *)getLeafViewController {
  43. return ((UIViewController<RNNRootViewProtocol>*)self.topViewController);
  44. }
  45. - (UIViewController *)childViewControllerForStatusBarStyle {
  46. return self.topViewController;
  47. }
  48. - (void)applyTabBarItem {
  49. [self.options.bottomTab mergeOptions:((RNNNavigationOptions *)self.options.defaultOptions).bottomTab overrideOptions:NO];
  50. [self.options.bottomTab applyOn:self];
  51. [self.getLeafViewController.options.bottomTab mergeOptions:((RNNNavigationOptions *)self.getLeafViewController.options.defaultOptions).bottomTab overrideOptions:NO];
  52. [self.getLeafViewController.options.bottomTab applyOn:self];
  53. }
  54. @end