Skip to content

Commit

Permalink
Fix constants error when there is no bottomTabs loaded (#5706)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogevbd authored and guyca committed Dec 1, 2019
1 parent 5b7ddec commit 2cd4752
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
8 changes: 2 additions & 6 deletions lib/ios/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ + (NSDictionary *)getConstants {
}

+ (CGFloat)topBarHeight {
return [UIApplication .sharedApplication.delegate.window.rootViewController getTopBarHeight];
return [UIApplication.sharedApplication.delegate.window.rootViewController getTopBarHeight];
}

+ (CGFloat)statusBarHeight {
return [UIApplication sharedApplication].statusBarFrame.size.height;
}

+ (CGFloat)bottomTabsHeight {
@try {
return CGRectGetHeight(((UITabBarController *) UIApplication.sharedApplication.windows[0].rootViewController).tabBar.frame);
} @catch (NSException *exception) {
return 0;
}
return [UIApplication.sharedApplication.delegate.window.rootViewController getBottomTabsHeight];
}

@end
8 changes: 2 additions & 6 deletions lib/ios/RNNBottomTabsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ - (UIViewController *)getCurrentChild {
return self.selectedViewController;
}

- (CGFloat)getTopBarHeight {
for(UIViewController * child in [self childViewControllers]) {
CGFloat childTopBarHeight = [child getTopBarHeight];
if (childTopBarHeight > 0) return childTopBarHeight;
}
return [super getTopBarHeight];
- (CGFloat)getBottomTabsHeight {
return self.tabBar.frame.size.height;
}

- (void)setSelectedIndexByComponentID:(NSString *)componentID {
Expand Down
4 changes: 0 additions & 4 deletions lib/ios/RNNComponentViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ - (UIViewController *)getCurrentChild {
return nil;
}

- (CGFloat)getTopBarHeight {
return [[self getCurrentChild] getTopBarHeight];
}

-(void)updateSearchResultsForSearchController:(UISearchController *)searchController {
[self.eventEmitter sendOnSearchBarUpdated:self.layoutInfo.componentId
text:searchController.searchBar.text
Expand Down
4 changes: 3 additions & 1 deletion lib/ios/RNNLayoutProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void);

- (UIViewController<RNNLayoutProtocol> *)getCurrentChild;

- (CGFloat) getTopBarHeight;
- (CGFloat)getTopBarHeight;

- (CGFloat)getBottomTabsHeight;

- (void)mergeOptions:(RNNNavigationOptions *)options;

Expand Down
8 changes: 0 additions & 8 deletions lib/ios/RNNSideMenuController.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,4 @@ - (RNNNavigationOptions *)resolveOptions {
return options;
}

- (CGFloat)getTopBarHeight {
for(UIViewController * child in [self childViewControllers]) {
CGFloat childTopBarHeight = [child getTopBarHeight];
if (childTopBarHeight > 0) return childTopBarHeight;
}
return [super getTopBarHeight];
}

@end
14 changes: 14 additions & 0 deletions lib/ios/UIViewController+LayoutProtocol.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ - (UIViewController *)getCurrentChild {
}

- (CGFloat)getTopBarHeight {
for(UIViewController * child in [self childViewControllers]) {
CGFloat childTopBarHeight = [child getTopBarHeight];
if (childTopBarHeight > 0) return childTopBarHeight;
}

return 0;
}

- (CGFloat)getBottomTabsHeight {
for(UIViewController * child in [self childViewControllers]) {
CGFloat childBottomTabsHeight = [child getBottomTabsHeight];
if (childBottomTabsHeight > 0) return childBottomTabsHeight;
}

return 0;
}

Expand Down

0 comments on commit 2cd4752

Please sign in to comment.