react-native-navigation的迁移库

RNNSideMenuChildVC.m 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #import "RNNSideMenuChildVC.h"
  2. @interface RNNSideMenuChildVC ()
  3. @property (readwrite) RNNSideMenuChildType type;
  4. @property (nonatomic, retain) UIViewController<RNNParentProtocol> *child;
  5. @end
  6. @implementation RNNSideMenuChildVC
  7. - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options optionsResolver:(RNNParentOptionsResolver *)optionsResolver presenter:(RNNBasePresenter *)presenter type:(RNNSideMenuChildType)type {
  8. self = [self initWithLayoutInfo:layoutInfo childViewControllers:childViewControllers options:options optionsResolver:optionsResolver presenter:presenter];
  9. self.type = type;
  10. return self;
  11. }
  12. - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options optionsResolver:(RNNParentOptionsResolver *)optionsResolver presenter:(RNNBasePresenter *)presenter {
  13. self = [super init];
  14. self.presenter = presenter;
  15. self.options = options;
  16. self.layoutInfo = layoutInfo;
  17. self.optionsResolver = optionsResolver;
  18. [self bindChildViewControllers:childViewControllers];
  19. return self;
  20. }
  21. - (void)bindChildViewControllers:(NSArray<UIViewController<RNNParentProtocol> *> *)viewControllers {
  22. UIViewController<RNNParentProtocol>* child = viewControllers[0];
  23. self.child = child;
  24. [self addChildViewController:self.child];
  25. [self.child.view setFrame:self.view.bounds];
  26. [self.view addSubview:self.child.view];
  27. [self.view bringSubviewToFront:self.child.view];
  28. }
  29. - (UIViewController *)getLeafViewController {
  30. return [self.child getLeafViewController];
  31. }
  32. - (void)willMoveToParentViewController:(UIViewController *)parent {
  33. [_optionsResolver resolve:self with:self.childViewControllers];
  34. [_presenter present:self.options onViewControllerDidLoad:self];
  35. }
  36. - (void)mergeOptions:(RNNNavigationOptions *)options {
  37. [self.options mergeOptions:options overrideOptions:YES];
  38. [self.presenter present:self.options onViewControllerWillAppear:self];
  39. }
  40. - (UIStatusBarStyle)preferredStatusBarStyle {
  41. return self.child.preferredStatusBarStyle;
  42. }
  43. @end