react-native-navigation的迁移库

BottomTabPresenter.m 1.8KB

123456789101112131415161718192021222324252627282930313233343536
  1. #import "BottomTabPresenter.h"
  2. #import "RNNTabBarItemCreator.h"
  3. #import "UIViewController+RNNOptions.h"
  4. #import "UIViewController+LayoutProtocol.h"
  5. @implementation BottomTabPresenter
  6. - (void)applyOptions:(RNNNavigationOptions *)options child:(UIViewController *)child {
  7. RNNNavigationOptions * withDefault = [options withDefault:self.defaultOptions];
  8. [child setTabBarItemBadge:[withDefault.bottomTab.badge getWithDefaultValue:[NSNull null]]];
  9. [child setTabBarItemBadgeColor:[withDefault.bottomTab.badgeColor getWithDefaultValue:nil]];
  10. }
  11. - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options child:(UIViewController *)child {
  12. RNNNavigationOptions * withDefault = [options withDefault:self.defaultOptions];
  13. [self createTabBarItem:child bottomTabOptions:withDefault.bottomTab];
  14. [child setTabBarItemBadge:[withDefault.bottomTab.badge getWithDefaultValue:[NSNull null]]];
  15. [child setTabBarItemBadgeColor:[withDefault.bottomTab.badgeColor getWithDefaultValue:nil]];
  16. }
  17. - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions child:(UIViewController *)child {
  18. RNNNavigationOptions* withDefault = (RNNNavigationOptions *) [[resolvedOptions withDefault:self.defaultOptions] overrideOptions:options];
  19. if (options.bottomTab.hasValue) [self createTabBarItem:child bottomTabOptions:withDefault.bottomTab];
  20. if (options.bottomTab.badge.hasValue) [child setTabBarItemBadge:options.bottomTab.badge.get];
  21. if (options.bottomTab.badgeColor.hasValue) [child setTabBarItemBadgeColor:options.bottomTab.badgeColor.get];
  22. }
  23. - (void)createTabBarItem:(UIViewController *)child bottomTabOptions:(RNNBottomTabOptions *)bottomTabOptions {
  24. child.tabBarItem = [RNNTabBarItemCreator createTabBarItem:bottomTabOptions mergeItem:child.tabBarItem];
  25. }
  26. @end