react-native-navigation的迁移库

BottomTabsBasePresenter.m 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #import "BottomTabsBasePresenter.h"
  2. @implementation BottomTabsBasePresenter
  3. - (void)applyOptionsOnInit:(RNNNavigationOptions *)options {
  4. [super applyOptionsOnInit:options];
  5. UITabBarController *bottomTabs = self.tabBarController;
  6. RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
  7. [bottomTabs setCurrentTabIndex:[withDefault.bottomTabs.currentTabIndex getWithDefaultValue:0]];
  8. if ([[withDefault.bottomTabs.titleDisplayMode getWithDefaultValue:@"alwaysShow"] isEqualToString:@"alwaysHide"]) {
  9. [bottomTabs centerTabItems];
  10. }
  11. }
  12. - (void)applyOptions:(RNNNavigationOptions *)options {
  13. UITabBarController *bottomTabs = self.tabBarController;
  14. RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
  15. [bottomTabs setTabBarTestID:[withDefault.bottomTabs.testID getWithDefaultValue:nil]];
  16. [bottomTabs.view setBackgroundColor:[withDefault.layout.backgroundColor getWithDefaultValue:nil]];
  17. [self applyBackgroundColor:[withDefault.bottomTabs.backgroundColor getWithDefaultValue:nil] translucent:[withDefault.bottomTabs.translucent getWithDefaultValue:NO]];
  18. [bottomTabs setTabBarHideShadow:[withDefault.bottomTabs.hideShadow getWithDefaultValue:NO]];
  19. [bottomTabs setTabBarStyle:[RCTConvert UIBarStyle:[withDefault.bottomTabs.barStyle getWithDefaultValue:@"default"]]];
  20. }
  21. - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions {
  22. [super mergeOptions:options resolvedOptions:currentOptions];
  23. UITabBarController *bottomTabs = self.tabBarController;
  24. if (options.bottomTabs.currentTabIndex.hasValue) {
  25. [bottomTabs setCurrentTabIndex:options.bottomTabs.currentTabIndex.get];
  26. [options.bottomTabs.currentTabIndex consume];
  27. }
  28. if (options.bottomTabs.currentTabId.hasValue) {
  29. [bottomTabs setCurrentTabID:options.bottomTabs.currentTabId.get];
  30. [options.bottomTabs.currentTabId consume];
  31. }
  32. if (options.bottomTabs.testID.hasValue) {
  33. [bottomTabs setTabBarTestID:options.bottomTabs.testID.get];
  34. }
  35. if (options.bottomTabs.backgroundColor.hasValue) {
  36. [self setTabBarBackgroundColor:options.bottomTabs.backgroundColor.get];
  37. }
  38. if (options.bottomTabs.barStyle.hasValue) {
  39. [bottomTabs setTabBarStyle:[RCTConvert UIBarStyle:options.bottomTabs.barStyle.get]];
  40. }
  41. if (options.bottomTabs.translucent.hasValue) {
  42. [bottomTabs setTabBarTranslucent:options.bottomTabs.translucent.get];
  43. }
  44. if (options.bottomTabs.hideShadow.hasValue) {
  45. [bottomTabs setTabBarHideShadow:options.bottomTabs.hideShadow.get];
  46. }
  47. if (options.bottomTabs.visible.hasValue) {
  48. if (options.bottomTabs.animate.hasValue) {
  49. [bottomTabs setTabBarVisible:options.bottomTabs.visible.get animated:[options.bottomTabs.animate getWithDefaultValue:NO]];
  50. } else {
  51. [bottomTabs setTabBarVisible:options.bottomTabs.visible.get animated:NO];
  52. }
  53. }
  54. if (options.layout.backgroundColor.hasValue) {
  55. [bottomTabs.view setBackgroundColor:options.layout.backgroundColor.get];
  56. }
  57. }
  58. - (UITabBarController *)tabBarController {
  59. return (UITabBarController *)self.boundViewController;
  60. }
  61. - (UITabBar *)tabBar {
  62. return self.tabBarController.tabBar;
  63. }
  64. - (void)applyBackgroundColor:(UIColor *)backgroundColor translucent:(BOOL)translucent {
  65. }
  66. - (void)setTabBarBackgroundColor:(UIColor *)backgroundColor {
  67. }
  68. - (void)setTabBarTranslucent:(BOOL)translucent {
  69. }
  70. @end