react-native-navigation的迁移库

BottomTabsBasePresenter.m 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 setTabBarVisible:[withDefault.bottomTabs.visible getWithDefaultValue:YES] animated:[withDefault.bottomTabs.animate getWithDefaultValue:NO]];
  17. [bottomTabs.view setBackgroundColor:[withDefault.layout.backgroundColor getWithDefaultValue:nil]];
  18. [self applyBackgroundColor:[withDefault.bottomTabs.backgroundColor getWithDefaultValue:nil] translucent:[withDefault.bottomTabs.translucent getWithDefaultValue:NO]];
  19. [bottomTabs setTabBarHideShadow:[withDefault.bottomTabs.hideShadow getWithDefaultValue:NO]];
  20. [bottomTabs setTabBarStyle:[RCTConvert UIBarStyle:[withDefault.bottomTabs.barStyle getWithDefaultValue:@"default"]]];
  21. }
  22. - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions {
  23. [super mergeOptions:options resolvedOptions:currentOptions];
  24. UITabBarController *bottomTabs = self.tabBarController;
  25. if (options.bottomTabs.currentTabIndex.hasValue) {
  26. [bottomTabs setCurrentTabIndex:options.bottomTabs.currentTabIndex.get];
  27. [options.bottomTabs.currentTabIndex consume];
  28. }
  29. if (options.bottomTabs.currentTabId.hasValue) {
  30. [bottomTabs setCurrentTabID:options.bottomTabs.currentTabId.get];
  31. [options.bottomTabs.currentTabId consume];
  32. }
  33. if (options.bottomTabs.testID.hasValue) {
  34. [bottomTabs setTabBarTestID:options.bottomTabs.testID.get];
  35. }
  36. if (options.bottomTabs.backgroundColor.hasValue) {
  37. [self setTabBarBackgroundColor:options.bottomTabs.backgroundColor.get];
  38. }
  39. if (options.bottomTabs.barStyle.hasValue) {
  40. [bottomTabs setTabBarStyle:[RCTConvert UIBarStyle:options.bottomTabs.barStyle.get]];
  41. }
  42. if (options.bottomTabs.translucent.hasValue) {
  43. [bottomTabs setTabBarTranslucent:options.bottomTabs.translucent.get];
  44. }
  45. if (options.bottomTabs.hideShadow.hasValue) {
  46. [bottomTabs setTabBarHideShadow:options.bottomTabs.hideShadow.get];
  47. }
  48. if (options.bottomTabs.visible.hasValue) {
  49. if (options.bottomTabs.animate.hasValue) {
  50. [bottomTabs setTabBarVisible:options.bottomTabs.visible.get animated:[options.bottomTabs.animate getWithDefaultValue:NO]];
  51. } else {
  52. [bottomTabs setTabBarVisible:options.bottomTabs.visible.get animated:NO];
  53. }
  54. }
  55. if (options.layout.backgroundColor.hasValue) {
  56. [bottomTabs.view setBackgroundColor:options.layout.backgroundColor.get];
  57. }
  58. }
  59. - (UITabBarController *)tabBarController {
  60. return (UITabBarController *)self.boundViewController;
  61. }
  62. - (UITabBar *)tabBar {
  63. return self.tabBarController.tabBar;
  64. }
  65. - (void)applyBackgroundColor:(UIColor *)backgroundColor translucent:(BOOL)translucent {
  66. }
  67. - (void)setTabBarBackgroundColor:(UIColor *)backgroundColor {
  68. }
  69. - (void)setTabBarTranslucent:(BOOL)translucent {
  70. }
  71. @end