|
@@ -3,7 +3,17 @@
|
3
|
3
|
#import "RNNRootViewController.h"
|
4
|
4
|
#define kTabBarHiddenDuration 0.3
|
5
|
5
|
|
6
|
|
-@implementation RNNTabBarController
|
|
6
|
+@implementation RNNTabBarController {
|
|
7
|
+ NSUInteger _currentTabIndex;
|
|
8
|
+ RNNEventEmitter *_eventEmitter;
|
|
9
|
+}
|
|
10
|
+
|
|
11
|
+- (instancetype)initWithEventEmitter:(id)eventEmitter {
|
|
12
|
+ self = [super init];
|
|
13
|
+ _eventEmitter = eventEmitter;
|
|
14
|
+ self.delegate = self;
|
|
15
|
+ return self;
|
|
16
|
+}
|
7
|
17
|
|
8
|
18
|
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
|
9
|
19
|
return self.selectedViewController.supportedInterfaceOrientations;
|
|
@@ -49,4 +59,16 @@
|
49
|
59
|
return ((UIViewController<RNNRootViewProtocol>*)self.selectedViewController).componentId;
|
50
|
60
|
}
|
51
|
61
|
|
|
62
|
+#pragma mark UITabBarControllerDelegate
|
|
63
|
+
|
|
64
|
+- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
|
|
65
|
+ if (tabBarController.selectedIndex == _currentTabIndex) {
|
|
66
|
+ [_eventEmitter sendOnNavigationEvent:@"bottomTabReselected" params:@{@"index": @(tabBarController.selectedIndex)}];
|
|
67
|
+ } else {
|
|
68
|
+ [_eventEmitter sendOnNavigationEvent:@"bottomTabSelected" params:@{@"index": @(tabBarController.selectedIndex)}];
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ _currentTabIndex = tabBarController.selectedIndex;
|
|
72
|
+}
|
|
73
|
+
|
52
|
74
|
@end
|