react-native-navigation的迁移库

RNNTabBarPresenter.m 2.4KB

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