react-native-navigation的迁移库

RNNTabBarPresenter.m 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #import "RNNTabBarPresenter.h"
  2. #import "UITabBarController+RNNOptions.h"
  3. @implementation RNNTabBarPresenter
  4. - (void)applyOptionsOnInit:(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] animated:[options.bottomTabs.animate getWithDefaultValue:NO]];
  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. if (newOptions.bottomTabs.animate.hasValue) {
  45. [tabBarController rnn_setTabBarVisible:newOptions.bottomTabs.visible.get animated:[newOptions.bottomTabs.animate getWithDefaultValue:NO]];
  46. } else {
  47. [tabBarController rnn_setTabBarVisible:newOptions.bottomTabs.visible.get animated:NO];
  48. }
  49. }
  50. }
  51. @end