Browse Source

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

Yogev Ben David 5 years ago
parent
commit
2cd4752fa0

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

@@ -8,7 +8,7 @@
8 8
 }
9 9
 
10 10
 + (CGFloat)topBarHeight {
11
-	return [UIApplication .sharedApplication.delegate.window.rootViewController getTopBarHeight];
11
+	return [UIApplication.sharedApplication.delegate.window.rootViewController getTopBarHeight];
12 12
 }
13 13
 
14 14
 + (CGFloat)statusBarHeight {
@@ -16,11 +16,7 @@
16 16
 }
17 17
 
18 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 22
 @end

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

@@ -16,12 +16,8 @@
16 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 23
 - (void)setSelectedIndexByComponentID:(NSString *)componentID {

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

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

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

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

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

@@ -145,12 +145,4 @@
145 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 148
 @end

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

@@ -81,6 +81,20 @@
81 81
 }
82 82
 
83 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 98
     return 0;
85 99
 }
86 100