yogevbd 6 years ago
parent
commit
058117ca24

+ 0
- 2
lib/ios/RNNBasePresenter.h View File

@@ -20,8 +20,6 @@
20 20
 
21 21
 - (void)presentOn:(UIViewController *)viewController;
22 22
 
23
-- (void)presentOnLoad:(UIViewController *)viewController;
24
-
25 23
 - (void)overrideOptions:(RNNNavigationOptions *)options;
26 24
 
27 25
 @end

+ 1
- 5
lib/ios/RNNBasePresenter.m View File

@@ -15,7 +15,7 @@
15 15
 }
16 16
 
17 17
 - (void)present:(RNNNavigationOptions *)options on:(UIViewController *)viewController {
18
-	
18
+	[options applyOn:viewController];
19 19
 }
20 20
 
21 21
 - (RNNNavigationOptions *)presentWithChildOptions:(RNNNavigationOptions *)childOptions on:(UIViewController *)viewController {
@@ -25,10 +25,6 @@
25 25
 	return options;
26 26
 }
27 27
 
28
-- (void)presentOnLoad:(UIViewController *)viewController {
29
-	
30
-}
31
-
32 28
 - (void)overrideOptions:(RNNNavigationOptions *)options {
33 29
 	[_options mergeOptions:options overrideOptions:YES];
34 30
 }

+ 6
- 2
lib/ios/RNNControllerFactory.m View File

@@ -181,14 +181,16 @@
181 181
 
182 182
 - (UIViewController<RNNParentProtocol> *)createSideMenu:(RNNLayoutNode*)node {
183 183
 	RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] initWithNode:node];
184
-
184
+	RNNNavigationOptions* options = [_optionsManager createOptions:node.data[@"options"]];
185
+	RNNBasePresenter* presenter = [[RNNBasePresenter alloc] initWithOptions:options];
186
+	
185 187
 	NSMutableArray* childrenVCs = [NSMutableArray new];
186 188
 	
187 189
 	for (NSDictionary *child in node.children) {
188 190
 		UIViewController *vc = [self fromTree:child];
189 191
 		[childrenVCs addObject:vc];
190 192
 	}
191
-	RNNSideMenuController *sideMenu = [[RNNSideMenuController alloc] initWithControllers:childrenVCs];
193
+	RNNSideMenuController *sideMenu = [[RNNSideMenuController alloc] initWithControllers:childrenVCs presenter:presenter];
192 194
 	sideMenu.layoutInfo = layoutInfo;
193 195
 	
194 196
 	return sideMenu;
@@ -197,7 +199,9 @@
197 199
 
198 200
 - (UIViewController<RNNParentProtocol> *)createSideMenuChild:(RNNLayoutNode*)node type:(RNNSideMenuChildType)type {
199 201
 	UIViewController<RNNParentProtocol>* child = [self fromTree:node.children[0]];
202
+	RNNNavigationOptions* options = [_optionsManager createOptions:node.data[@"options"]];
200 203
 	RNNSideMenuChildVC *sideMenuChild = [[RNNSideMenuChildVC alloc] initWithChild: child type:type];
204
+	sideMenuChild.presenter = [[RNNBasePresenter alloc] initWithOptions:options];
201 205
 	
202 206
 	return sideMenuChild;
203 207
 }

+ 0
- 3
lib/ios/RNNParentProtocol.h View File

@@ -6,9 +6,6 @@
6 6
 @required
7 7
 
8 8
 - (UIViewController<RNNLeafProtocol> *)getLeafViewController;
9
-
10
-@optional
11
-
12 9
 - (void)performOnChildWillAppear:(RNNNavigationOptions *)options;
13 10
 - (void)performOnChildLoad:(RNNNavigationOptions *)options;
14 11
 

+ 21
- 2
lib/ios/RNNSideMenu/MMDrawerController/MMDrawerController.m View File

@@ -21,6 +21,7 @@
21 21
 
22 22
 #import "MMDrawerController.h"
23 23
 #import "UIViewController+MMDrawerController.h"
24
+#import "RNNNavigationOptions.h"
24 25
 
25 26
 #import <QuartzCore/QuartzCore.h>
26 27
 
@@ -462,7 +463,7 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
462 463
     
463 464
     _centerViewController = centerViewController;
464 465
     
465
-    [self addChildViewController:self.centerViewController];
466
+	[self addChildViewController:self.centerViewController];
466 467
     [self.centerViewController.view setFrame:self.childControllerContainerView.bounds];
467 468
     [self.centerContainerView addSubview:self.centerViewController.view];
468 469
     [self.childControllerContainerView bringSubviewToFront:self.centerContainerView];
@@ -479,6 +480,24 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
479 480
     }
480 481
 }
481 482
 
483
+- (void)performOnChildWillAppear:(RNNNavigationOptions *)childOptions {
484
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildWillAppear:)]) {
485
+		[self.parentViewController performSelector:@selector(performOnChildWillAppear:) withObject:childOptions];
486
+	}
487
+}
488
+
489
+- (void)performOnChildLoad:(RNNNavigationOptions *)childOptions {
490
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildLoad:)]) {
491
+		[self.parentViewController performSelector:@selector(performOnChildLoad:) withObject:childOptions];
492
+	}
493
+}
494
+
495
+- (void)willMoveToParentViewController:(UIViewController *)parent {
496
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildLoad:)]) {
497
+		[self.parentViewController performSelector:@selector(performOnChildLoad:) withObject:nil];
498
+	}
499
+}
500
+
482 501
 -(void)setCenterViewController:(UIViewController *)newCenterViewController withCloseAnimation:(BOOL)animated completion:(void(^)(BOOL finished))completion{
483 502
     
484 503
     if(self.openSide == MMDrawerSideNone){
@@ -911,7 +930,7 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
911 930
     
912 931
     if(viewController){
913 932
         [self addChildViewController:viewController];
914
-        
933
+		
915 934
         if((self.openSide == drawerSide) &&
916 935
            [self.childControllerContainerView.subviews containsObject:self.centerContainerView]){
917 936
             [self.childControllerContainerView insertSubview:viewController.view belowSubview:self.centerContainerView];

+ 22
- 2
lib/ios/RNNSideMenuChildVC.m View File

@@ -20,12 +20,12 @@
20 20
 -(instancetype) initWithChild:(UIViewController<RNNParentProtocol>*)child type:(RNNSideMenuChildType)type {
21 21
 	self = [super init];
22 22
 	
23
-	self.child = child;	
23
+	self.child = child;
24 24
 	[self addChildViewController:self.child];
25 25
 	[self.child.view setFrame:self.view.bounds];
26 26
 	[self.view addSubview:self.child.view];
27 27
 	[self.view bringSubviewToFront:self.child.view];
28
-	
28
+
29 29
 	self.type = type;
30 30
 	
31 31
 	return self;
@@ -35,6 +35,26 @@
35 35
 	return [self.child getLeafViewController];
36 36
 }
37 37
 
38
+- (void)performOnChildWillAppear:(RNNNavigationOptions *)childOptions {
39
+	RNNNavigationOptions* combinedOptions = [_presenter presentWithChildOptions:childOptions on:self];
40
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildWillAppear:)]) {
41
+		[self.parentViewController performSelector:@selector(performOnChildWillAppear:) withObject:combinedOptions];
42
+	}
43
+}
44
+
45
+- (void)performOnChildLoad:(RNNNavigationOptions *)childOptions {
46
+	RNNNavigationOptions* combinedOptions = [_presenter presentWithChildOptions:childOptions on:self];
47
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildLoad:)]) {
48
+		[self.parentViewController performSelector:@selector(performOnChildLoad:) withObject:combinedOptions];
49
+	}
50
+}
51
+
52
+- (void)willMoveToParentViewController:(UIViewController *)parent {
53
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildLoad:)]) {
54
+		[self.parentViewController performSelector:@selector(performOnChildLoad:) withObject:_presenter.options];
55
+	}
56
+}
57
+
38 58
 - (UIStatusBarStyle)preferredStatusBarStyle {
39 59
 	return self.child.preferredStatusBarStyle;
40 60
 }

+ 1
- 1
lib/ios/RNNSideMenuController.h View File

@@ -21,7 +21,7 @@
21 21
 @property (nonatomic, retain) RNNLayoutInfo* layoutInfo;
22 22
 @property (nonatomic, retain) RNNBasePresenter* presenter;
23 23
 
24
--(instancetype)initWithControllers:(NSArray*)controllers;
24
+-(instancetype)initWithControllers:(NSArray*)controllers presenter:(RNNBasePresenter *)presenter;
25 25
 
26 26
 -(void)showSideMenu:(MMDrawerSide)side animated:(BOOL)animated;
27 27
 -(void)hideSideMenu:(MMDrawerSide)side animated:(BOOL)animated;

+ 22
- 1
lib/ios/RNNSideMenuController.m View File

@@ -21,9 +21,10 @@
21 21
 
22 22
 @implementation RNNSideMenuController
23 23
 
24
--(instancetype)initWithControllers:(NSArray*)controllers;
24
+-(instancetype)initWithControllers:(NSArray*)controllers presenter:(RNNBasePresenter *)presenter
25 25
 {
26 26
 	self = [super init];
27
+	self.presenter = presenter;
27 28
 	
28 29
 	[self setControllers:controllers];
29 30
 	
@@ -93,5 +94,25 @@
93 94
 	return [self.center getLeafViewController];
94 95
 }
95 96
 
97
+- (void)performOnChildWillAppear:(RNNNavigationOptions *)childOptions {
98
+	RNNNavigationOptions* combinedOptions = [_presenter presentWithChildOptions:childOptions on:self];
99
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildWillAppear:)]) {
100
+		[self.parentViewController performSelector:@selector(performOnChildWillAppear:) withObject:combinedOptions];
101
+	}
102
+}
103
+
104
+- (void)performOnChildLoad:(RNNNavigationOptions *)childOptions {
105
+	RNNNavigationOptions* combinedOptions = [_presenter presentWithChildOptions:childOptions on:self];
106
+		if ([self.parentViewController respondsToSelector:@selector(performOnChildLoad:)]) {
107
+		[self.parentViewController performSelector:@selector(performOnChildLoad:) withObject:combinedOptions];
108
+	}
109
+}
110
+
111
+- (void)willMoveToParentViewController:(UIViewController *)parent {
112
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildLoad:)]) {
113
+		[self.parentViewController performSelector:@selector(performOnChildLoad:) withObject:_presenter.options];
114
+	}
115
+}
116
+
96 117
 
97 118
 @end

+ 14
- 0
lib/ios/RNNSplitViewController.m View File

@@ -26,4 +26,18 @@
26 26
 	return self;
27 27
 }
28 28
 
29
+- (void)performOnChildLoad:(RNNNavigationOptions *)childOptions {
30
+	RNNNavigationOptions* combinedOptions = [_presenter presentWithChildOptions:childOptions on:self];
31
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildLoad:)]) {
32
+		[self.parentViewController performSelector:@selector(performOnChildLoad:) withObject:combinedOptions];
33
+	}
34
+}
35
+
36
+- (void)performOnChildWillAppear:(RNNNavigationOptions *)childOptions {
37
+	RNNNavigationOptions* combinedOptions = [_presenter presentWithChildOptions:childOptions on:self];
38
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildWillAppear:)]) {
39
+		[self.parentViewController performSelector:@selector(performOnChildWillAppear:) withObject:combinedOptions];
40
+	}
41
+}
42
+
29 43
 @end

+ 9
- 2
lib/ios/RNNTabBarController.m View File

@@ -16,9 +16,16 @@
16 16
 }
17 17
 
18 18
 - (void)performOnChildLoad:(RNNNavigationOptions *)childOptions {
19
-	[_presenter presentWithChildOptions:childOptions on:self];
19
+	RNNNavigationOptions* combinedOptions = [_presenter presentWithChildOptions:childOptions on:self];
20 20
 	if ([self.parentViewController respondsToSelector:@selector(performOnChildLoad:)]) {
21
-		[self.parentViewController performSelector:@selector(performOnChildLoad:) withObject:childOptions];
21
+		[self.parentViewController performSelector:@selector(performOnChildLoad:) withObject:combinedOptions];
22
+	}
23
+}
24
+
25
+- (void)performOnChildWillAppear:(RNNNavigationOptions *)childOptions {
26
+	RNNNavigationOptions* combinedOptions = [_presenter presentWithChildOptions:childOptions on:self];
27
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildWillAppear:)]) {
28
+		[self.parentViewController performSelector:@selector(performOnChildWillAppear:) withObject:combinedOptions];
22 29
 	}
23 30
 }
24 31
 

+ 14
- 0
lib/ios/RNNTopTabsViewController.m View File

@@ -78,4 +78,18 @@
78 78
 	return _currentViewController;
79 79
 }
80 80
 
81
+- (void)performOnChildLoad:(RNNNavigationOptions *)childOptions {
82
+	RNNNavigationOptions* combinedOptions = [_presenter presentWithChildOptions:childOptions on:self];
83
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildLoad:)]) {
84
+		[self.parentViewController performSelector:@selector(performOnChildLoad:) withObject:combinedOptions];
85
+	}
86
+}
87
+
88
+- (void)performOnChildWillAppear:(RNNNavigationOptions *)childOptions {
89
+	RNNNavigationOptions* combinedOptions = [_presenter presentWithChildOptions:childOptions on:self];
90
+	if ([self.parentViewController respondsToSelector:@selector(performOnChildWillAppear:)]) {
91
+		[self.parentViewController performSelector:@selector(performOnChildWillAppear:) withObject:combinedOptions];
92
+	}
93
+}
94
+
81 95
 @end

+ 1
- 1
playground/src/components/Bounds.js View File

@@ -11,4 +11,4 @@ module.exports = (props) => {
11 11
       {props.children}
12 12
     </View>
13 13
   );
14
-};
14
+};

+ 1
- 1
playground/src/screens/ComplexLayout.js View File

@@ -109,7 +109,7 @@ class ComplexLayout extends Component {
109 109
            ]
110 110
         }
111 111
       }
112
-    })
112
+    });
113 113
   }
114 114
 }
115 115