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. [child setTabBarItemBadge:[withDefault.bottomTab.badge getWithDefaultValue:[NSNull null]]];
  14. [child setTabBarItemBadgeColor:[withDefault.bottomTab.badgeColor getWithDefaultValue:nil]];
  15. [self createTabBarItem:child bottomTabOptions:withDefault.bottomTab];
  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.badge.hasValue) [child setTabBarItemBadge:options.bottomTab.badge.get];
  20. if (options.bottomTab.badgeColor.hasValue) [child setTabBarItemBadgeColor:options.bottomTab.badgeColor.get];
  21. if (options.bottomTab.hasValue) [self createTabBarItem:child bottomTabOptions:withDefault.bottomTab];
  22. }
  23. - (void)createTabBarItem:(UIViewController *)child bottomTabOptions:(RNNBottomTabOptions *)bottomTabOptions {
  24. child.tabBarItem = [RNNTabBarItemCreator updateTabBarItem:child.tabBarItem bottomTabOptions:bottomTabOptions];
  25. }
  26. @end