react-native-navigation的迁移库

RNNSplitViewController.m 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #import "RNNSplitViewController.h"
  2. @implementation RNNSplitViewController
  3. - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions presenter:(RNNViewControllerPresenter *)presenter {
  4. self = [super init];
  5. self.presenter = presenter;
  6. [self.presenter bindViewController:self];
  7. self.defaultOptions = defaultOptions;
  8. self.options = options;
  9. self.layoutInfo = layoutInfo;
  10. self.navigationController.delegate = self;
  11. [self bindChildViewControllers:childViewControllers];
  12. return self;
  13. }
  14. - (void)willMoveToParentViewController:(UIViewController *)parent {
  15. if (parent) {
  16. [_presenter applyOptionsOnWillMoveToParentViewController:self.resolveOptions];
  17. }
  18. }
  19. - (void)onChildWillAppear {
  20. [_presenter applyOptions:self.resolveOptions];
  21. [((UIViewController<RNNParentProtocol> *)self.parentViewController) onChildWillAppear];
  22. }
  23. - (RNNNavigationOptions *)resolveOptions {
  24. return [(RNNNavigationOptions *)[self.getCurrentChild.resolveOptions.copy mergeOptions:self.options] withDefault:self.defaultOptions];
  25. }
  26. - (void)mergeOptions:(RNNNavigationOptions *)options {
  27. [_presenter mergeOptions:options currentOptions:self.options defaultOptions:self.defaultOptions];
  28. [((UIViewController<RNNLayoutProtocol> *)self.parentViewController) mergeOptions:options];
  29. }
  30. - (void)overrideOptions:(RNNNavigationOptions *)options {
  31. [self.options overrideOptions:options];
  32. }
  33. - (void)bindChildViewControllers:(NSArray<UIViewController<RNNLayoutProtocol> *> *)viewControllers {
  34. [self setViewControllers:viewControllers];
  35. UIViewController<UISplitViewControllerDelegate>* masterViewController = viewControllers[0];
  36. self.delegate = masterViewController;
  37. }
  38. -(void)viewWillAppear:(BOOL)animated{
  39. [super viewWillAppear:animated];
  40. }
  41. - (UIViewController *)getCurrentChild {
  42. return self.viewControllers[0];
  43. }
  44. - (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
  45. return [[self getCurrentChild] getCurrentLeaf];
  46. }
  47. @end