react-native-navigation的迁移库

RNNStackController.m 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. - (CGFloat)getTopBarHeight {
  17. return self.navigationBar.frame.size.height;
  18. }
  19. - (UINavigationController *)navigationController {
  20. return self;
  21. }
  22. - (UIStatusBarStyle)preferredStatusBarStyle {
  23. return [_presenter getStatusBarStyle:self.resolveOptions];
  24. }
  25. - (UIModalPresentationStyle)modalPresentationStyle {
  26. return self.getCurrentChild.modalPresentationStyle;
  27. }
  28. - (UIViewController *)popViewControllerAnimated:(BOOL)animated {
  29. if (self.viewControllers.count > 1) {
  30. UIViewController *controller = self.viewControllers[self.viewControllers.count - 2];
  31. if ([controller isKindOfClass:[RNNComponentViewController class]]) {
  32. RNNComponentViewController *rnnController = (RNNComponentViewController *)controller;
  33. [self.presenter applyOptionsBeforePopping:rnnController.resolveOptions];
  34. }
  35. }
  36. return [super popViewControllerAnimated:animated];
  37. }
  38. - (UIViewController *)childViewControllerForStatusBarStyle {
  39. return self.topViewController;
  40. }
  41. - (void)setTopBarBackgroundColor:(UIColor *)backgroundColor {
  42. [self.navigationBar rnn_setBackgroundColor:backgroundColor];
  43. }
  44. @end