react-native-navigation的迁移库

RNNStackController.m 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #import "RNNStackController.h"
  2. #import "RNNComponentViewController.h"
  3. @implementation RNNStackController {
  4. UIViewController* _presentedViewController;
  5. }
  6. - (instancetype)init {
  7. self = [super init];
  8. self.delegate = self;
  9. return self;
  10. }
  11. - (void)setDefaultOptions:(RNNNavigationOptions *)defaultOptions {
  12. [super setDefaultOptions:defaultOptions];
  13. [self.presenter setDefaultOptions:defaultOptions];
  14. }
  15. - (void)viewDidLayoutSubviews {
  16. [super viewDidLayoutSubviews];
  17. [self.presenter applyOptionsOnViewDidLayoutSubviews:self.resolveOptions];
  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. [self prepareForPop];
  30. return [super popViewControllerAnimated:animated];
  31. }
  32. - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
  33. if ([self.viewControllers indexOfObject:_presentedViewController] < 0) {
  34. [self sendScreenPoppedEvent:_presentedViewController];
  35. }
  36. _presentedViewController = viewController;
  37. }
  38. - (void)sendScreenPoppedEvent:(UIViewController *)poppedScreen {
  39. [self.eventEmitter sendScreenPoppedEvent:poppedScreen.layoutInfo.componentId];
  40. }
  41. - (void)prepareForPop {
  42. if (self.viewControllers.count > 1) {
  43. UIViewController *controller = self.viewControllers[self.viewControllers.count - 2];
  44. if ([controller isKindOfClass:[RNNComponentViewController class]]) {
  45. RNNComponentViewController *rnnController = (RNNComponentViewController *)controller;
  46. [self.presenter applyOptionsBeforePopping:rnnController.resolveOptions];
  47. }
  48. }
  49. }
  50. - (UIViewController *)childViewControllerForStatusBarStyle {
  51. return self.topViewController;
  52. }
  53. @end