react-native-navigation的迁移库

RNNTabBarPresenter.m 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #import "RNNTabBarPresenter.h"
  2. #import "UITabBarController+RNNOptions.h"
  3. @implementation RNNTabBarPresenter
  4. - (void)applyOptionsOnSetViewControllers:(RNNNavigationOptions *)options {
  5. UITabBarController* tabBarController = self.bindedViewController;
  6. [tabBarController rnn_setCurrentTabIndex:[options.bottomTabs.currentTabIndex getWithDefaultValue:0]];
  7. }
  8. - (void)applyOptions:(RNNNavigationOptions *)options {
  9. UITabBarController* tabBarController = self.bindedViewController;
  10. [tabBarController rnn_setTabBarTestID:[options.bottomTabs.testID getWithDefaultValue:nil]];
  11. [tabBarController rnn_setTabBarBackgroundColor:[options.bottomTabs.backgroundColor getWithDefaultValue:nil]];
  12. [tabBarController rnn_setTabBarTranslucent:[options.bottomTabs.translucent getWithDefaultValue:NO]];
  13. [tabBarController rnn_setTabBarHideShadow:[options.bottomTabs.hideShadow getWithDefaultValue:NO]];
  14. [tabBarController rnn_setTabBarStyle:[RCTConvert UIBarStyle:[options.bottomTabs.barStyle getWithDefaultValue:@"default"]]];
  15. [tabBarController rnn_setTabBarVisible:[options.bottomTabs.visible getWithDefaultValue:YES]];
  16. }
  17. - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
  18. [super mergeOptions:newOptions currentOptions:currentOptions defaultOptions:defaultOptions];
  19. UITabBarController* tabBarController = self.bindedViewController;
  20. if (newOptions.bottomTabs.currentTabIndex.hasValue) {
  21. [tabBarController rnn_setCurrentTabIndex:newOptions.bottomTabs.currentTabIndex.get];
  22. [newOptions.bottomTabs.currentTabIndex consume];
  23. }
  24. if (newOptions.bottomTabs.currentTabId.hasValue) {
  25. [tabBarController rnn_setCurrentTabID:newOptions.bottomTabs.currentTabId.get];
  26. [newOptions.bottomTabs.currentTabId consume];
  27. }
  28. if (newOptions.bottomTabs.testID.hasValue) {
  29. [tabBarController rnn_setTabBarTestID:newOptions.bottomTabs.testID.get];
  30. }
  31. if (newOptions.bottomTabs.backgroundColor.hasValue) {
  32. [tabBarController rnn_setTabBarBackgroundColor:newOptions.bottomTabs.backgroundColor.get];
  33. }
  34. if (newOptions.bottomTabs.barStyle.hasValue) {
  35. [tabBarController rnn_setTabBarStyle:[RCTConvert UIBarStyle:newOptions.bottomTabs.barStyle.get]];
  36. }
  37. if (newOptions.bottomTabs.translucent.hasValue) {
  38. [tabBarController rnn_setTabBarTranslucent:newOptions.bottomTabs.translucent.get];
  39. }
  40. if (newOptions.bottomTabs.hideShadow.hasValue) {
  41. [tabBarController rnn_setTabBarHideShadow:newOptions.bottomTabs.hideShadow.get];
  42. }
  43. if (newOptions.bottomTabs.visible.hasValue) {
  44. [tabBarController rnn_setTabBarVisible:newOptions.bottomTabs.visible.get];
  45. }
  46. }
  47. @end