1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #import "RNNBottomTabsController.h"
-
- @implementation RNNBottomTabsController {
- NSUInteger _currentTabIndex;
- }
-
- - (id<UITabBarControllerDelegate>)delegate {
- return self;
- }
-
- - (void)viewDidLayoutSubviews {
- [self.presenter viewDidLayoutSubviews];
- }
-
- - (UIViewController *)getCurrentChild {
- return self.selectedViewController;
- }
-
- - (CGFloat)getBottomTabsHeight {
- return self.tabBar.frame.size.height;
- }
-
- - (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
|