react-native-navigation的迁移库

RNNBottomTabsOptions.m 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #import "RNNBottomTabsOptions.h"
  2. #import "RNNTabBarController.h"
  3. extern const NSInteger BLUR_TOPBAR_TAG;
  4. @implementation RNNBottomTabsOptions
  5. - (void)applyOn:(UIViewController *)viewController {
  6. if (self.currentTabIndex) {
  7. [viewController.tabBarController setSelectedIndex:[self.currentTabIndex unsignedIntegerValue]];
  8. }
  9. if (self.currentTabId) {
  10. [(RNNTabBarController*)viewController.tabBarController setSelectedIndexByComponentID:self.currentTabId];
  11. }
  12. if (self.visible) {
  13. [((RNNTabBarController *)viewController.tabBarController) setTabBarHidden:![self.visible boolValue] animated:[self.animate boolValue]];
  14. } else {
  15. [((RNNTabBarController *)viewController.tabBarController) setTabBarHidden:NO animated:NO];
  16. }
  17. if (self.testID) {
  18. viewController.tabBarController.tabBar.accessibilityIdentifier = self.testID;
  19. }
  20. if (self.drawBehind) {
  21. if ([self.drawBehind boolValue]) {
  22. [viewController setExtendedLayoutIncludesOpaqueBars:YES];
  23. viewController.edgesForExtendedLayout |= UIRectEdgeBottom;
  24. } else {
  25. [viewController setExtendedLayoutIncludesOpaqueBars:NO];
  26. viewController.edgesForExtendedLayout &= ~UIRectEdgeBottom;
  27. }
  28. }
  29. if (self.backgroundColor) {
  30. viewController.tabBarController.tabBar.barTintColor = [RCTConvert UIColor:self.backgroundColor];
  31. } else {
  32. viewController.tabBarController.tabBar.barTintColor = nil;
  33. }
  34. if (self.barStyle) {
  35. viewController.tabBarController.tabBar.barStyle = [RCTConvert UIBarStyle:self.barStyle];
  36. } else {
  37. viewController.tabBarController.tabBar.barStyle = UIBarStyleDefault;
  38. }
  39. if (self.translucent) {
  40. viewController.tabBarController.tabBar.translucent = [self.translucent boolValue];
  41. } else {
  42. viewController.tabBarController.tabBar.translucent = NO;
  43. }
  44. if (self.hideShadow) {
  45. viewController.tabBarController.tabBar.clipsToBounds = [self.hideShadow boolValue];
  46. }
  47. [self resetOptions];
  48. }
  49. -(UIFont *)tabBarTextFont {
  50. if (self.fontFamily) {
  51. return [UIFont fontWithName:self.fontFamily size:self.tabBarTextFontSizeValue];
  52. }
  53. else if (self.fontSize) {
  54. return [UIFont systemFontOfSize:self.tabBarTextFontSizeValue];
  55. }
  56. else {
  57. return nil;
  58. }
  59. }
  60. -(CGFloat)tabBarTextFontSizeValue {
  61. return self.fontSize ? [self.fontSize floatValue] : 10;
  62. }
  63. - (void)resetOptions {
  64. self.currentTabId = nil;
  65. self.currentTabIndex = nil;
  66. }
  67. @end