12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
-
- #import "RNNTabBarController.h"
-
- #define kTabBarHiddenDuration 0.3
-
- @implementation RNNTabBarController {
- NSUInteger _currentTabIndex;
- RNNEventEmitter *_eventEmitter;
- }
-
- - (instancetype)initWithEventEmitter:(id)eventEmitter {
- self = [super init];
- _eventEmitter = eventEmitter;
- self.delegate = self;
- return self;
- }
-
- - (void)performOnChildLoad:(RNNNavigationOptions *)childOptions {
- [_presenter presentWithChildOptions:childOptions on:self];
- if ([self.parentViewController respondsToSelector:@selector(performOnChildLoad:)]) {
- [self.parentViewController performSelector:@selector(performOnChildLoad:) withObject:childOptions];
- }
- }
-
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
- return self.selectedViewController.supportedInterfaceOrientations;
- }
-
- - (void)setSelectedIndexByComponentID:(NSString *)componentID {
- for (id child in self.childViewControllers) {
- UIViewController<RNNParentProtocol>* vc = child;
-
- if ([vc.layoutInfo.componentId isEqualToString:componentID]) {
- [self setSelectedIndex:[self.childViewControllers indexOfObject:child]];
- }
- }
- }
-
- - (void)setSelectedIndex:(NSUInteger)selectedIndex {
- _currentTabIndex = selectedIndex;
- [super setSelectedIndex:selectedIndex];
- }
-
- - (UIViewController *)getLeafViewController {
- return ((UIViewController<RNNParentProtocol>*)self.selectedViewController).getLeafViewController;
- }
-
- - (UIStatusBarStyle)preferredStatusBarStyle {
- return ((UIViewController<RNNParentProtocol>*)self.selectedViewController).preferredStatusBarStyle;
- }
-
- - (void)setViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers {
- [super setViewControllers:viewControllers];
- }
-
- #pragma mark UITabBarControllerDelegate
-
- - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
- [_eventEmitter sendBottomTabSelected:@(tabBarController.selectedIndex) unselected:@(_currentTabIndex)];
- _currentTabIndex = tabBarController.selectedIndex;
- }
-
- @end
|