react-native-navigation的迁移库

RNNSideMenuChildVC.m 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. - (void)bindChildViewController:(UIViewController<RNNLayoutProtocol>*)child {
  38. self.child = child;
  39. [self addChildViewController:self.child];
  40. [self.child.view setFrame:self.view.bounds];
  41. [self.view addSubview:self.child.view];
  42. [self.view bringSubviewToFront:self.child.view];
  43. }
  44. - (void)setWidth:(CGFloat)width {
  45. CGRect frame = self.child.view.frame;
  46. frame.size.width = width;
  47. self.child.view.frame = frame;
  48. }
  49. - (UIViewController *)getCurrentChild {
  50. return self.child;
  51. }
  52. - (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
  53. return [[self getCurrentChild] getCurrentLeaf];
  54. }
  55. - (UIStatusBarStyle)preferredStatusBarStyle {
  56. return self.child.preferredStatusBarStyle;
  57. }
  58. @end