react-native-navigation的迁移库

RNNStackController.m 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #import "RNNStackController.h"
  2. #import "RNNComponentViewController.h"
  3. #import "UIViewController+Utils.h"
  4. #import "StackControllerDelegate.h"
  5. @implementation RNNStackController {
  6. UIViewController* _presentedViewController;
  7. StackControllerDelegate* _stackDelegate;
  8. }
  9. - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo creator:(id<RNNComponentViewCreator>)creator options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions presenter:(RNNBasePresenter *)presenter eventEmitter:(RNNEventEmitter *)eventEmitter childViewControllers:(NSArray *)childViewControllers {
  10. self = [super initWithLayoutInfo:layoutInfo creator:creator options:options defaultOptions:defaultOptions presenter:presenter eventEmitter:eventEmitter childViewControllers:childViewControllers];
  11. _stackDelegate = [[StackControllerDelegate alloc] initWithEventEmitter:self.eventEmitter];
  12. self.delegate = _stackDelegate;
  13. return self;
  14. }
  15. - (void)setDefaultOptions:(RNNNavigationOptions *)defaultOptions {
  16. [super setDefaultOptions:defaultOptions];
  17. [self.presenter setDefaultOptions:defaultOptions];
  18. }
  19. - (void)viewDidLayoutSubviews {
  20. [super viewDidLayoutSubviews];
  21. [self.presenter applyOptionsOnViewDidLayoutSubviews:self.resolveOptions];
  22. }
  23. - (void)mergeChildOptions:(RNNNavigationOptions *)options child:(UIViewController *)child {
  24. if (child.isLastInStack) {
  25. [self.presenter mergeOptions:options resolvedOptions:self.resolveOptions];
  26. }
  27. [self.parentViewController mergeChildOptions:options child:child];
  28. }
  29. - (UIStatusBarStyle)preferredStatusBarStyle {
  30. return [_presenter getStatusBarStyle:self.resolveOptions];
  31. }
  32. - (UIModalPresentationStyle)modalPresentationStyle {
  33. return self.getCurrentChild.modalPresentationStyle;
  34. }
  35. - (UIViewController *)popViewControllerAnimated:(BOOL)animated {
  36. [self prepareForPop];
  37. return [super popViewControllerAnimated:animated];
  38. }
  39. - (void)prepareForPop {
  40. if (self.viewControllers.count > 1) {
  41. UIViewController *controller = self.viewControllers[self.viewControllers.count - 2];
  42. if ([controller isKindOfClass:[RNNComponentViewController class]]) {
  43. RNNComponentViewController *rnnController = (RNNComponentViewController *)controller;
  44. [self.presenter applyOptionsBeforePopping:rnnController.resolveOptions];
  45. }
  46. }
  47. }
  48. - (UIViewController *)childViewControllerForStatusBarStyle {
  49. return self.topViewController;
  50. }
  51. @end