react-native-navigation的迁移库

RNNBasePresenter.m 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #import "RNNBasePresenter.h"
  2. #import "UIViewController+RNNOptions.h"
  3. #import "RNNTabBarItemCreator.h"
  4. #import "RNNReactComponentManager.h"
  5. @interface RNNBasePresenter ()
  6. @property (nonatomic, strong) RNNReactComponentManager* componentManager;
  7. @end
  8. @implementation RNNBasePresenter
  9. - (instancetype)initWithComponentManager:(RNNReactComponentManager *)componentManager {
  10. self = [super init];
  11. self.componentManager = componentManager;
  12. return self;
  13. }
  14. - (void)bindViewController:(UIViewController *)bindedViewController {
  15. _bindedViewController = bindedViewController;
  16. }
  17. - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
  18. }
  19. - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {
  20. UIViewController* viewController = self.bindedViewController;
  21. if ((options.bottomTab.text.hasValue || options.bottomTab.icon.hasValue || options.bottomTab.selectedIcon.hasValue)) {
  22. UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
  23. viewController.tabBarItem = tabItem;
  24. [options.bottomTab.text consume];
  25. [options.bottomTab.icon consume];
  26. [options.bottomTab.selectedIcon consume];
  27. }
  28. }
  29. - (void)applyOptions:(RNNNavigationOptions *)options {
  30. UIViewController* viewController = self.bindedViewController;
  31. if (options.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
  32. [viewController rnn_setTabBarItemBadge:options.bottomTab.badge.get];
  33. }
  34. }
  35. - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
  36. UIViewController* viewController = self.bindedViewController;
  37. if (newOptions.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
  38. [viewController rnn_setTabBarItemBadge:newOptions.bottomTab.badge.get];
  39. }
  40. }
  41. @end