react-native-navigation的迁移库

RNNBasePresenter.m 1.6KB

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