yogevbd 6 years ago
parent
commit
058117ca24

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

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

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

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

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

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

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

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

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

21
 
21
 
22
 #import "MMDrawerController.h"
22
 #import "MMDrawerController.h"
23
 #import "UIViewController+MMDrawerController.h"
23
 #import "UIViewController+MMDrawerController.h"
24
+#import "RNNNavigationOptions.h"
24
 
25
 
25
 #import <QuartzCore/QuartzCore.h>
26
 #import <QuartzCore/QuartzCore.h>
26
 
27
 
462
     
463
     
463
     _centerViewController = centerViewController;
464
     _centerViewController = centerViewController;
464
     
465
     
465
-    [self addChildViewController:self.centerViewController];
466
+	[self addChildViewController:self.centerViewController];
466
     [self.centerViewController.view setFrame:self.childControllerContainerView.bounds];
467
     [self.centerViewController.view setFrame:self.childControllerContainerView.bounds];
467
     [self.centerContainerView addSubview:self.centerViewController.view];
468
     [self.centerContainerView addSubview:self.centerViewController.view];
468
     [self.childControllerContainerView bringSubviewToFront:self.centerContainerView];
469
     [self.childControllerContainerView bringSubviewToFront:self.centerContainerView];
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
 -(void)setCenterViewController:(UIViewController *)newCenterViewController withCloseAnimation:(BOOL)animated completion:(void(^)(BOOL finished))completion{
501
 -(void)setCenterViewController:(UIViewController *)newCenterViewController withCloseAnimation:(BOOL)animated completion:(void(^)(BOOL finished))completion{
483
     
502
     
484
     if(self.openSide == MMDrawerSideNone){
503
     if(self.openSide == MMDrawerSideNone){
911
     
930
     
912
     if(viewController){
931
     if(viewController){
913
         [self addChildViewController:viewController];
932
         [self addChildViewController:viewController];
914
-        
933
+		
915
         if((self.openSide == drawerSide) &&
934
         if((self.openSide == drawerSide) &&
916
            [self.childControllerContainerView.subviews containsObject:self.centerContainerView]){
935
            [self.childControllerContainerView.subviews containsObject:self.centerContainerView]){
917
             [self.childControllerContainerView insertSubview:viewController.view belowSubview:self.centerContainerView];
936
             [self.childControllerContainerView insertSubview:viewController.view belowSubview:self.centerContainerView];

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

20
 -(instancetype) initWithChild:(UIViewController<RNNParentProtocol>*)child type:(RNNSideMenuChildType)type {
20
 -(instancetype) initWithChild:(UIViewController<RNNParentProtocol>*)child type:(RNNSideMenuChildType)type {
21
 	self = [super init];
21
 	self = [super init];
22
 	
22
 	
23
-	self.child = child;	
23
+	self.child = child;
24
 	[self addChildViewController:self.child];
24
 	[self addChildViewController:self.child];
25
 	[self.child.view setFrame:self.view.bounds];
25
 	[self.child.view setFrame:self.view.bounds];
26
 	[self.view addSubview:self.child.view];
26
 	[self.view addSubview:self.child.view];
27
 	[self.view bringSubviewToFront:self.child.view];
27
 	[self.view bringSubviewToFront:self.child.view];
28
-	
28
+
29
 	self.type = type;
29
 	self.type = type;
30
 	
30
 	
31
 	return self;
31
 	return self;
35
 	return [self.child getLeafViewController];
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
 - (UIStatusBarStyle)preferredStatusBarStyle {
58
 - (UIStatusBarStyle)preferredStatusBarStyle {
39
 	return self.child.preferredStatusBarStyle;
59
 	return self.child.preferredStatusBarStyle;
40
 }
60
 }

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

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

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

21
 
21
 
22
 @implementation RNNSideMenuController
22
 @implementation RNNSideMenuController
23
 
23
 
24
--(instancetype)initWithControllers:(NSArray*)controllers;
24
+-(instancetype)initWithControllers:(NSArray*)controllers presenter:(RNNBasePresenter *)presenter
25
 {
25
 {
26
 	self = [super init];
26
 	self = [super init];
27
+	self.presenter = presenter;
27
 	
28
 	
28
 	[self setControllers:controllers];
29
 	[self setControllers:controllers];
29
 	
30
 	
93
 	return [self.center getLeafViewController];
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
 @end
118
 @end

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

26
 	return self;
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
 @end
43
 @end

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

16
 }
16
 }
17
 
17
 
18
 - (void)performOnChildLoad:(RNNNavigationOptions *)childOptions {
18
 - (void)performOnChildLoad:(RNNNavigationOptions *)childOptions {
19
-	[_presenter presentWithChildOptions:childOptions on:self];
19
+	RNNNavigationOptions* combinedOptions = [_presenter presentWithChildOptions:childOptions on:self];
20
 	if ([self.parentViewController respondsToSelector:@selector(performOnChildLoad:)]) {
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
 	return _currentViewController;
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
 @end
95
 @end

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

11
       {props.children}
11
       {props.children}
12
     </View>
12
     </View>
13
   );
13
   );
14
-};
14
+};

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

109
            ]
109
            ]
110
         }
110
         }
111
       }
111
       }
112
-    })
112
+    });
113
   }
113
   }
114
 }
114
 }
115
 
115