react-native-navigation的迁移库

RNNSplitViewController.m 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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)onChildWillAppear {
  15. [_presenter applyOptions:self.resolveOptions];
  16. [((UIViewController<RNNParentProtocol> *)self.parentViewController) onChildWillAppear];
  17. }
  18. - (RNNNavigationOptions *)resolveOptions {
  19. return [(RNNNavigationOptions *)[self.getCurrentChild.resolveOptions.copy mergeOptions:self.options] withDefault:self.defaultOptions];
  20. }
  21. - (void)mergeOptions:(RNNNavigationOptions *)options {
  22. [_presenter mergeOptions:options currentOptions:self.options defaultOptions:self.defaultOptions];
  23. [((UIViewController<RNNLayoutProtocol> *)self.parentViewController) mergeOptions:options];
  24. }
  25. - (void)overrideOptions:(RNNNavigationOptions *)options {
  26. [self.options overrideOptions:options];
  27. }
  28. - (void)bindChildViewControllers:(NSArray<UIViewController<RNNLayoutProtocol> *> *)viewControllers {
  29. [self setViewControllers:viewControllers];
  30. UIViewController<UISplitViewControllerDelegate>* masterViewController = viewControllers[0];
  31. self.delegate = masterViewController;
  32. }
  33. -(void)viewWillAppear:(BOOL)animated{
  34. [super viewWillAppear:animated];
  35. }
  36. - (UIViewController *)getCurrentChild {
  37. return self.viewControllers[0];
  38. }
  39. - (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
  40. return [[self getCurrentChild] getCurrentLeaf];
  41. }
  42. @end