12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #import "RNNSplitViewController.h"
-
- @implementation RNNSplitViewController
-
- - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions presenter:(RNNViewControllerPresenter *)presenter {
- self = [super init];
-
- self.presenter = presenter;
- [self.presenter bindViewController:self];
-
- self.defaultOptions = defaultOptions;
- self.options = options;
- self.layoutInfo = layoutInfo;
-
- self.navigationController.delegate = self;
-
- [self bindChildViewControllers:childViewControllers];
-
- return self;
- }
-
- - (void)onChildWillAppear {
- [_presenter applyOptions:self.resolveOptions];
- [((UIViewController<RNNParentProtocol> *)self.parentViewController) onChildWillAppear];
- }
-
- - (RNNNavigationOptions *)resolveOptions {
- return [(RNNNavigationOptions *)[self.getCurrentChild.resolveOptions.copy mergeOptions:self.options] withDefault:self.defaultOptions];
- }
-
- - (void)mergeOptions:(RNNNavigationOptions *)options {
- [_presenter mergeOptions:options currentOptions:self.options defaultOptions:self.defaultOptions];
- [((UIViewController<RNNLayoutProtocol> *)self.parentViewController) mergeOptions:options];
- }
-
- - (void)overrideOptions:(RNNNavigationOptions *)options {
- [self.options overrideOptions:options];
- }
-
- - (void)bindChildViewControllers:(NSArray<UIViewController<RNNLayoutProtocol> *> *)viewControllers {
- [self setViewControllers:viewControllers];
- UIViewController<UISplitViewControllerDelegate>* masterViewController = viewControllers[0];
- self.delegate = masterViewController;
- }
-
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- }
-
- - (UIViewController *)getCurrentChild {
- return self;
- }
-
- @end
|