123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #import "RNNTabBarController.h"
-
- @implementation RNNTabBarController {
- NSUInteger _currentTabIndex;
- }
-
- - (id<UITabBarControllerDelegate>)delegate {
- return self;
- }
-
- - (void)viewDidLayoutSubviews {
- [self.presenter viewDidLayoutSubviews];
- }
-
- - (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];
- }
-
- - (void)setSelectedIndexByComponentID:(NSString *)componentID {
- for (id child in self.childViewControllers) {
- UIViewController<RNNLayoutProtocol>* vc = child;
-
- if ([vc conformsToProtocol:@protocol(RNNLayoutProtocol)] && [vc.layoutInfo.componentId isEqualToString:componentID]) {
- [self setSelectedIndex:[self.childViewControllers indexOfObject:child]];
- }
- }
- }
-
- - (void)setSelectedIndex:(NSUInteger)selectedIndex {
- _currentTabIndex = selectedIndex;
- [super setSelectedIndex:selectedIndex];
- }
-
- - (UIStatusBarStyle)preferredStatusBarStyle {
- return [[self presenter] getStatusBarStyle:self.resolveOptions];
- }
-
- #pragma mark UITabBarControllerDelegate
-
- - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
- [self.eventEmitter sendBottomTabSelected:@(tabBarController.selectedIndex) unselected:@(_currentTabIndex)];
- _currentTabIndex = tabBarController.selectedIndex;
- }
-
- @end
|