forked from wix/react-native-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRNNBasePresenter.m
42 lines (32 loc) · 1.61 KB
/
RNNBasePresenter.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#import "RNNBasePresenter.h"
#import "UIViewController+RNNOptions.h"
#import "RNNTabBarItemCreator.h"
@implementation RNNBasePresenter
- (void)bindViewController:(UIViewController *)bindedViewController {
_bindedViewController = bindedViewController;
}
- (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
}
- (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {
UIViewController* viewController = self.bindedViewController;
if ((options.bottomTab.text.hasValue || options.bottomTab.icon.hasValue || options.bottomTab.selectedIcon.hasValue)) {
UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
viewController.tabBarItem = tabItem;
[options.bottomTab.text consume];
[options.bottomTab.icon consume];
[options.bottomTab.selectedIcon consume];
}
}
- (void)applyOptions:(RNNNavigationOptions *)options {
UIViewController* viewController = self.bindedViewController;
if (options.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
[viewController rnn_setTabBarItemBadge:options.bottomTab.badge.get];
}
}
- (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
UIViewController* viewController = self.bindedViewController;
if (newOptions.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
[viewController rnn_setTabBarItemBadge:newOptions.bottomTab.badge.get];
}
}
@end