react-native-navigation的迁移库

RNNSplitViewController.m 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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;
  38. }
  39. @end