react-native-navigation的迁移库

RNNSideMenuChildVC.m 2.7KB

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.options mergeInOptions:self.getCurrentChild.resolveOptions.copy] 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. - (UIStatusBarStyle)preferredStatusBarStyle {
  56. return self.child.preferredStatusBarStyle;
  57. }
  58. @end