react-native-navigation的迁移库

RNNBottomTabsOptions.m 2.0KB

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.testID) {
  13. viewController.tabBarController.tabBar.accessibilityIdentifier = self.testID;
  14. }
  15. if (self.drawBehind) {
  16. if ([self.drawBehind boolValue]) {
  17. [viewController setExtendedLayoutIncludesOpaqueBars:YES];
  18. viewController.edgesForExtendedLayout |= UIRectEdgeBottom;
  19. } else {
  20. [viewController setExtendedLayoutIncludesOpaqueBars:NO];
  21. viewController.edgesForExtendedLayout &= ~UIRectEdgeBottom;
  22. }
  23. }
  24. if (self.backgroundColor) {
  25. viewController.tabBarController.tabBar.barTintColor = [RCTConvert UIColor:self.backgroundColor];
  26. } else {
  27. viewController.tabBarController.tabBar.barTintColor = nil;
  28. }
  29. if (self.barStyle) {
  30. viewController.tabBarController.tabBar.barStyle = [RCTConvert UIBarStyle:self.barStyle];
  31. } else {
  32. viewController.tabBarController.tabBar.barStyle = UIBarStyleDefault;
  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