react-native-navigation的迁移库

RNNSideMenuChildVC.m 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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)renderTreeAndWait:(BOOL)wait perform:(RNNReactViewReadyCompletionBlock)readyBlock {
  38. [self.getCurrentChild renderTreeAndWait:wait perform:readyBlock];
  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. - (void)setWidth:(CGFloat)width {
  48. CGRect frame = self.child.view.frame;
  49. frame.size.width = width;
  50. self.child.view.frame = frame;
  51. }
  52. - (UIViewController *)getCurrentChild {
  53. return self.child;
  54. }
  55. - (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
  56. return [[self getCurrentChild] getCurrentLeaf];
  57. }
  58. - (UIStatusBarStyle)preferredStatusBarStyle {
  59. return self.child.preferredStatusBarStyle;
  60. }
  61. @end