react-native-navigation的迁移库

RNNBottomTabsController.m 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #import "RNNBottomTabsController.h"
  2. @implementation RNNBottomTabsController {
  3. NSUInteger _currentTabIndex;
  4. }
  5. - (id<UITabBarControllerDelegate>)delegate {
  6. return self;
  7. }
  8. - (void)viewDidLayoutSubviews {
  9. [self.presenter viewDidLayoutSubviews];
  10. }
  11. - (UIViewController *)getCurrentChild {
  12. return self.selectedViewController;
  13. }
  14. - (CGFloat)getBottomTabsHeight {
  15. return self.tabBar.frame.size.height;
  16. }
  17. - (void)setSelectedIndexByComponentID:(NSString *)componentID {
  18. for (id child in self.childViewControllers) {
  19. UIViewController<RNNLayoutProtocol>* vc = child;
  20. if ([vc conformsToProtocol:@protocol(RNNLayoutProtocol)] && [vc.layoutInfo.componentId isEqualToString:componentID]) {
  21. [self setSelectedIndex:[self.childViewControllers indexOfObject:child]];
  22. }
  23. }
  24. }
  25. - (void)setSelectedIndex:(NSUInteger)selectedIndex {
  26. _currentTabIndex = selectedIndex;
  27. [super setSelectedIndex:selectedIndex];
  28. }
  29. - (UIStatusBarStyle)preferredStatusBarStyle {
  30. return [[self presenter] getStatusBarStyle:self.resolveOptions];
  31. }
  32. #pragma mark UITabBarControllerDelegate
  33. - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
  34. [self.eventEmitter sendBottomTabSelected:@(tabBarController.selectedIndex) unselected:@(_currentTabIndex)];
  35. _currentTabIndex = tabBarController.selectedIndex;
  36. }
  37. @end