react-native-navigation的迁移库

RNNSideMenuChildVC.m 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #import "RNNSideMenuChildVC.h"
  2. @interface RNNSideMenuChildVC ()
  3. @property (readwrite) RNNSideMenuChildType type;
  4. @property (nonatomic, retain) UIViewController<RNNLayoutProtocol> *child;
  5. @end
  6. @implementation RNNSideMenuChildVC
  7. - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions presenter:(RNNViewControllerPresenter *)presenter type:(RNNSideMenuChildType)type {
  8. self = [self initWithLayoutInfo:layoutInfo childViewControllers:childViewControllers options:options defaultOptions:defaultOptions presenter:presenter];
  9. self.type = type;
  10. return self;
  11. }
  12. - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions presenter:(RNNViewControllerPresenter *)presenter {
  13. self = [super init];
  14. self.child = childViewControllers[0];
  15. self.presenter = presenter;
  16. [self.presenter bindViewController:self];
  17. self.defaultOptions = defaultOptions;
  18. self.options = options;
  19. self.layoutInfo = layoutInfo;
  20. [self bindChildViewController:self.child];
  21. return self;
  22. }
  23. - (void)onChildWillAppear {
  24. [_presenter applyOptions:self.resolveOptions];
  25. [((UIViewController<RNNParentProtocol> *)self.parentViewController) onChildWillAppear];
  26. }
  27. - (RNNNavigationOptions *)resolveOptions {
  28. return [(RNNNavigationOptions *)[self.getCurrentChild.resolveOptions.copy mergeOptions:self.options] withDefault:self.defaultOptions];
  29. }
  30. - (void)mergeOptions:(RNNNavigationOptions *)options {
  31. [_presenter mergeOptions:options currentOptions:self.options defaultOptions:self.defaultOptions];
  32. [((UIViewController<RNNLayoutProtocol> *)self.parentViewController) mergeOptions:options];
  33. }
  34. - (void)overrideOptions:(RNNNavigationOptions *)options {
  35. [self.options overrideOptions:options];
  36. }
  37. - (UITabBarItem *)tabBarItem {
  38. return self.child.tabBarItem;
  39. }
  40. - (void)bindChildViewController:(UIViewController<RNNLayoutProtocol>*)child {
  41. self.child = child;
  42. [self addChildViewController:self.child];
  43. [self.child.view setFrame:self.view.bounds];
  44. [self.view addSubview:self.child.view];
  45. [self.view bringSubviewToFront:self.child.view];
  46. }
  47. - (UIViewController *)getCurrentChild {
  48. return self.child;
  49. }
  50. - (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
  51. return [[self getCurrentChild] getCurrentLeaf];
  52. }
  53. - (UIStatusBarStyle)preferredStatusBarStyle {
  54. return self.child.preferredStatusBarStyle;
  55. }
  56. @end