react-native-navigation的迁移库

RNNSideMenuChildVC.m 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 presenter:(RNNViewControllerPresenter *)presenter type:(RNNSideMenuChildType)type {
  8. self = [self initWithLayoutInfo:layoutInfo childViewControllers:childViewControllers options:options presenter:presenter];
  9. self.type = type;
  10. return self;
  11. }
  12. - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options presenter:(RNNViewControllerPresenter *)presenter {
  13. self = [super init];
  14. self.child = childViewControllers[0];
  15. self.presenter = presenter;
  16. [self.presenter bindViewController:self];
  17. self.options = options;
  18. self.layoutInfo = layoutInfo;
  19. [self bindChildViewController:self.child];
  20. return self;
  21. }
  22. - (void)onChildWillAppear {
  23. [_presenter applyOptions:self.resolveOptions];
  24. [((UIViewController<RNNParentProtocol> *)self.parentViewController) onChildWillAppear];
  25. }
  26. - (RNNNavigationOptions *)resolveOptions {
  27. return (RNNNavigationOptions *)[self.getCurrentChild.resolveOptions.copy mergeOptions:self.options];
  28. }
  29. - (void)mergeOptions:(RNNNavigationOptions *)options {
  30. [_presenter mergeOptions:options resolvedOptions:self.resolveOptions];
  31. [((UIViewController<RNNLayoutProtocol> *)self.parentViewController) mergeOptions:options];
  32. }
  33. - (UITabBarItem *)tabBarItem {
  34. return super.tabBarItem ? super.tabBarItem : self.child.tabBarItem;
  35. }
  36. - (void)bindChildViewController:(UIViewController<RNNParentProtocol>*)child {
  37. self.child = child;
  38. [self addChildViewController:self.child];
  39. [self.child.view setFrame:self.view.bounds];
  40. [self.view addSubview:self.child.view];
  41. [self.view bringSubviewToFront:self.child.view];
  42. }
  43. - (UIViewController *)getCurrentChild {
  44. return [self.child getCurrentChild];
  45. }
  46. - (UIStatusBarStyle)preferredStatusBarStyle {
  47. return self.child.preferredStatusBarStyle;
  48. }
  49. @end