Browse Source

fixed bottomTabs options with no stack

yogevbd 6 years ago
parent
commit
b8221b710f

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

@@ -2,7 +2,7 @@
2 2
 
3 3
 @interface RNNBackButtonOptions : RNNOptions
4 4
 
5
-@property (nonatomic, strong) NSDictionary* image;
5
+@property (nonatomic, strong) NSDictionary* icon;
6 6
 @property (nonatomic, strong) NSNumber* visible;
7 7
 @property (nonatomic, strong) NSString* title;
8 8
 @property (nonatomic, strong) NSString* transition;

+ 2
- 2
lib/ios/RNNBackButtonOptions.m View File

@@ -3,8 +3,8 @@
3 3
 @implementation RNNBackButtonOptions
4 4
 
5 5
 - (void)applyOn:(UIViewController *)viewController {
6
-	if (self.image) {
7
-		UIImage *image = self.image ? [RCTConvert UIImage:self.image] : nil;
6
+	if (self.icon) {
7
+		UIImage *image = self.icon ? [RCTConvert UIImage:self.icon] : nil;
8 8
 		[viewController.navigationController.navigationBar setBackIndicatorImage:image];
9 9
 		[viewController.navigationController.navigationBar setBackIndicatorTransitionMaskImage:image];
10 10
 	}

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

@@ -145,8 +145,8 @@
145 145
 
146 146
 	NSMutableArray* controllers = [NSMutableArray new];
147 147
 	for (NSDictionary *child in node.children) {
148
-		UIViewController* childVc = (UIViewController*)[self fromTree:child];
149
-		RNNRootViewController* rootView = (RNNRootViewController *)childVc.childViewControllers.firstObject;
148
+		UIViewController<RNNRootViewProtocol>* childVc = [self fromTree:child];
149
+		RNNRootViewController* rootView = (RNNRootViewController *)[childVc getLeafViewController];
150 150
 		[rootView applyTabBarItem];
151 151
 		
152 152
 		[controllers addObject:childVc];

+ 12
- 12
lib/ios/RNNNavigationController.m View File

@@ -8,32 +8,28 @@
8 8
 	return self.viewControllers.lastObject.supportedInterfaceOrientations;
9 9
 }
10 10
 
11
-- (UIViewController<RNNRootViewProtocol>*)getTopViewController {
12
-	return ((UIViewController<RNNRootViewProtocol>*)self.topViewController);
13
-}
14
-
15 11
 - (UINavigationController *)navigationController {
16 12
 	return self;
17 13
 }
18 14
 
19 15
 - (BOOL)isCustomViewController {
20
-	return [self.getTopViewController isCustomViewController];
16
+	return [self.getLeafViewController isCustomViewController];
21 17
 }
22 18
 
23 19
 - (void)mergeOptions:(RNNOptions *)options {
24
-	[self.getTopViewController mergeOptions:options];
20
+	[self.getLeafViewController mergeOptions:options];
25 21
 }
26 22
 
27 23
 - (UIStatusBarStyle)preferredStatusBarStyle {
28
-	return self.getTopViewController.preferredStatusBarStyle;
24
+	return self.getLeafViewController.preferredStatusBarStyle;
29 25
 }
30 26
 
31 27
 - (UIModalPresentationStyle)modalPresentationStyle {
32
-	return self.getTopViewController.modalPresentationStyle;
28
+	return self.getLeafViewController.modalPresentationStyle;
33 29
 }
34 30
 
35 31
 - (void)applyModalOptions {
36
-	[self.getTopViewController applyModalOptions];
32
+	[self.getLeafViewController applyModalOptions];
37 33
 }
38 34
 
39 35
 - (UIViewController *)popViewControllerAnimated:(BOOL)animated {
@@ -41,7 +37,7 @@
41 37
 }
42 38
 
43 39
 - (NSString *)componentId {
44
-	return _componentId ? _componentId : self.getTopViewController.componentId;
40
+	return _componentId ? _componentId : self.getLeafViewController.componentId;
45 41
 }
46 42
 
47 43
 - (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
@@ -53,11 +49,15 @@
53 49
 }
54 50
 
55 51
 - (RNNNavigationOptions *)options {
56
-	return self.getTopViewController.options;
52
+	return self.getLeafViewController.options;
53
+}
54
+
55
+- (UIViewController *)getLeafViewController {
56
+	return ((UIViewController<RNNRootViewProtocol>*)self.topViewController);
57 57
 }
58 58
 
59 59
 - (void)waitForReactViewRender:(BOOL)wait perform:(RNNReactViewReadyCompletionBlock)readyBlock {
60
-	[self.getTopViewController waitForReactViewRender:wait perform:readyBlock];
60
+	[self.getLeafViewController waitForReactViewRender:wait perform:readyBlock];
61 61
 }
62 62
 
63 63
 - (UIViewController *)childViewControllerForStatusBarStyle {

+ 4
- 0
lib/ios/RNNRootViewController.m View File

@@ -99,6 +99,10 @@
99 99
 	}
100 100
 }
101 101
 
102
+- (UIViewController *)getLeafViewController {
103
+	return self;
104
+}
105
+
102 106
 - (void)onReactViewReady:(RNNReactViewReadyCompletionBlock)readyBlock {
103 107
 	if (self.isCustomViewController) {
104 108
 		readyBlock();

+ 1
- 0
lib/ios/RNNRootViewProtocol.h View File

@@ -15,6 +15,7 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void);
15 15
 @required
16 16
 - (NSString *)componentId;
17 17
 - (void)waitForReactViewRender:(BOOL)wait perform:(RNNReactViewReadyCompletionBlock)readyBlock;
18
+- (UIViewController<RNNRootViewProtocol> *)getLeafViewController;
18 19
 
19 20
 @end
20 21
 

+ 4
- 0
lib/ios/RNNSideMenuChildVC.m View File

@@ -39,6 +39,10 @@
39 39
 	[self.child waitForReactViewRender:wait perform:readyBlock];
40 40
 }
41 41
 
42
+- (UIViewController *)getLeafViewController {
43
+	return self.child;
44
+}
45
+
42 46
 - (UIStatusBarStyle)preferredStatusBarStyle {
43 47
 	return self.child.preferredStatusBarStyle;
44 48
 }

+ 4
- 0
lib/ios/RNNSideMenuController.m View File

@@ -89,6 +89,10 @@
89 89
 	}
90 90
 }
91 91
 
92
+- (UIViewController *)getLeafViewController {
93
+	return self.center;
94
+}
95
+
92 96
 - (void)mergeOptions:(RNNOptions *)options {
93 97
 	[self.center mergeOptions:options];
94 98
 }

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

@@ -33,6 +33,10 @@
33 33
 - (void)optionsUpdated {
34 34
 }
35 35
 
36
+- (UIViewController *)getLeafViewController {
37
+	return self;
38
+}
39
+
36 40
 - (void)waitForReactViewRender:(BOOL)wait perform:(RNNReactViewReadyCompletionBlock)readyBlock {
37 41
 	readyBlock();
38 42
 }

+ 4
- 0
lib/ios/RNNTabBarController.m View File

@@ -53,6 +53,10 @@
53 53
 	return [((UIViewController<RNNRootViewProtocol>*)self.selectedViewController) options];
54 54
 }
55 55
 
56
+- (UIViewController *)getLeafViewController {
57
+	return ((UIViewController<RNNRootViewProtocol>*)self.selectedViewController);
58
+}
59
+
56 60
 - (NSString *)componentId {
57 61
 	return ((UIViewController<RNNRootViewProtocol>*)self.selectedViewController).componentId;
58 62
 }

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

@@ -76,8 +76,14 @@
76 76
 	return _currentViewController.componentId;
77 77
 }
78 78
 
79
+#pragma mark RNNRootViewProtocol
80
+
79 81
 - (void)waitForReactViewRender:(BOOL)wait perform:(RNNReactViewReadyCompletionBlock)readyBlock {
80 82
 	[_currentViewController waitForReactViewRender:wait perform:readyBlock];
81 83
 }
82 84
 
85
+- (UIViewController *)getLeafViewController {
86
+	return _currentViewController;
87
+}
88
+
83 89
 @end