react-native-navigation的迁移库

RNNTabBarPresenter.m 2.4KB

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