Browse Source

Fix constants error when there is no bottomTabs loaded (#5706)

Yogev Ben David 4 years ago
parent
commit
2cd4752fa0

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

8
 }
8
 }
9
 
9
 
10
 + (CGFloat)topBarHeight {
10
 + (CGFloat)topBarHeight {
11
-	return [UIApplication .sharedApplication.delegate.window.rootViewController getTopBarHeight];
11
+	return [UIApplication.sharedApplication.delegate.window.rootViewController getTopBarHeight];
12
 }
12
 }
13
 
13
 
14
 + (CGFloat)statusBarHeight {
14
 + (CGFloat)statusBarHeight {
16
 }
16
 }
17
 
17
 
18
 + (CGFloat)bottomTabsHeight {
18
 + (CGFloat)bottomTabsHeight {
19
-	@try {
20
-		return CGRectGetHeight(((UITabBarController *) UIApplication.sharedApplication.windows[0].rootViewController).tabBar.frame);
21
-	} @catch (NSException *exception) {
22
-		return 0;
23
-	}
19
+	return [UIApplication.sharedApplication.delegate.window.rootViewController getBottomTabsHeight];
24
 }
20
 }
25
 
21
 
26
 @end
22
 @end

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

16
 	return self.selectedViewController;
16
 	return self.selectedViewController;
17
 }
17
 }
18
 
18
 
19
-- (CGFloat)getTopBarHeight {
20
-    for(UIViewController * child in [self childViewControllers]) {
21
-        CGFloat childTopBarHeight = [child getTopBarHeight];
22
-        if (childTopBarHeight > 0) return childTopBarHeight;
23
-    }
24
-    return [super getTopBarHeight];
19
+- (CGFloat)getBottomTabsHeight {
20
+    return self.tabBar.frame.size.height;
25
 }
21
 }
26
 
22
 
27
 - (void)setSelectedIndexByComponentID:(NSString *)componentID {
23
 - (void)setSelectedIndexByComponentID:(NSString *)componentID {

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

88
 	return nil;
88
 	return nil;
89
 }
89
 }
90
 
90
 
91
-- (CGFloat)getTopBarHeight {
92
-    return [[self getCurrentChild] getTopBarHeight];
93
-}
94
-
95
 -(void)updateSearchResultsForSearchController:(UISearchController *)searchController {
91
 -(void)updateSearchResultsForSearchController:(UISearchController *)searchController {
96
 	[self.eventEmitter sendOnSearchBarUpdated:self.layoutInfo.componentId
92
 	[self.eventEmitter sendOnSearchBarUpdated:self.layoutInfo.componentId
97
 										 text:searchController.searchBar.text
93
 										 text:searchController.searchBar.text

+ 3
- 1
lib/ios/RNNLayoutProtocol.h View File

21
 
21
 
22
 - (UIViewController<RNNLayoutProtocol> *)getCurrentChild;
22
 - (UIViewController<RNNLayoutProtocol> *)getCurrentChild;
23
 
23
 
24
-- (CGFloat) getTopBarHeight;
24
+- (CGFloat)getTopBarHeight;
25
+
26
+- (CGFloat)getBottomTabsHeight;
25
 
27
 
26
 - (void)mergeOptions:(RNNNavigationOptions *)options;
28
 - (void)mergeOptions:(RNNNavigationOptions *)options;
27
 
29
 

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

145
     return options;
145
     return options;
146
 }
146
 }
147
 
147
 
148
-- (CGFloat)getTopBarHeight {
149
-    for(UIViewController * child in [self childViewControllers]) {
150
-        CGFloat childTopBarHeight = [child getTopBarHeight];
151
-        if (childTopBarHeight > 0) return childTopBarHeight;
152
-    }
153
-    return [super getTopBarHeight];
154
-}
155
-
156
 @end
148
 @end

+ 14
- 0
lib/ios/UIViewController+LayoutProtocol.m View File

81
 }
81
 }
82
 
82
 
83
 - (CGFloat)getTopBarHeight {
83
 - (CGFloat)getTopBarHeight {
84
+    for(UIViewController * child in [self childViewControllers]) {
85
+        CGFloat childTopBarHeight = [child getTopBarHeight];
86
+        if (childTopBarHeight > 0) return childTopBarHeight;
87
+    }
88
+    
89
+    return 0;
90
+}
91
+
92
+- (CGFloat)getBottomTabsHeight {
93
+    for(UIViewController * child in [self childViewControllers]) {
94
+        CGFloat childBottomTabsHeight = [child getBottomTabsHeight];
95
+        if (childBottomTabsHeight > 0) return childBottomTabsHeight;
96
+    }
97
+    
84
     return 0;
98
     return 0;
85
 }
99
 }
86
 
100