react-native-navigation的迁移库

RNNStackController.m 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #import "RNNStackController.h"
  2. #import "RNNComponentViewController.h"
  3. #import "UINavigationBar+utils.h"
  4. @implementation RNNStackController
  5. -(void)setDefaultOptions:(RNNNavigationOptions *)defaultOptions {
  6. [super setDefaultOptions:defaultOptions];
  7. [self.presenter setDefaultOptions:defaultOptions];
  8. }
  9. - (void)viewDidLayoutSubviews {
  10. [super viewDidLayoutSubviews];
  11. [self.presenter applyOptionsOnViewDidLayoutSubviews:self.resolveOptions];
  12. }
  13. - (UIViewController *)getCurrentChild {
  14. return self.topViewController;
  15. }
  16. - (UINavigationController *)navigationController {
  17. return self;
  18. }
  19. - (UIStatusBarStyle)preferredStatusBarStyle {
  20. return [_presenter getStatusBarStyle:self.resolveOptions];
  21. }
  22. - (UIModalPresentationStyle)modalPresentationStyle {
  23. return self.getCurrentChild.modalPresentationStyle;
  24. }
  25. - (UIViewController *)popViewControllerAnimated:(BOOL)animated {
  26. if (self.viewControllers.count > 1) {
  27. UIViewController *controller = self.viewControllers[self.viewControllers.count - 2];
  28. if ([controller isKindOfClass:[RNNComponentViewController class]]) {
  29. RNNComponentViewController *rnnController = (RNNComponentViewController *)controller;
  30. [self.presenter applyOptionsBeforePopping:rnnController.resolveOptions];
  31. }
  32. }
  33. return [super popViewControllerAnimated:animated];
  34. }
  35. - (UIViewController *)childViewControllerForStatusBarStyle {
  36. return self.topViewController;
  37. }
  38. - (void)setTopBarBackgroundColor:(UIColor *)backgroundColor {
  39. [self.navigationBar rnn_setBackgroundColor:backgroundColor];
  40. }
  41. @end