react-native-navigation的迁移库

RNNBottomTabsOptions.m 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.translucent) {
  35. viewController.tabBarController.tabBar.translucent = [self.translucent boolValue];
  36. } else {
  37. viewController.tabBarController.tabBar.translucent = NO;
  38. }
  39. if (self.hideShadow) {
  40. viewController.tabBarController.tabBar.clipsToBounds = [self.hideShadow boolValue];
  41. }
  42. [self resetOptions];
  43. }
  44. -(UIFont *)tabBarTextFont {
  45. if (self.fontFamily) {
  46. return [UIFont fontWithName:self.fontFamily size:self.tabBarTextFontSizeValue];
  47. }
  48. else if (self.fontSize) {
  49. return [UIFont systemFontOfSize:self.tabBarTextFontSizeValue];
  50. }
  51. else {
  52. return nil;
  53. }
  54. }
  55. -(CGFloat)tabBarTextFontSizeValue {
  56. return self.fontSize ? [self.fontSize floatValue] : 10;
  57. }
  58. - (void)resetOptions {
  59. self.currentTabId = nil;
  60. self.currentTabIndex = nil;
  61. }
  62. @end