|
|
@@ -8,13 +8,14 @@
|
|
8
|
8
|
|
|
9
|
9
|
@interface RNNBasePresenter ()
|
|
10
|
10
|
@property(nonatomic, strong) RNNDotIndicatorPresenter* dotIndicatorPresenter;
|
|
|
11
|
+@property(nonatomic, strong) RNNNavigationOptions* defaultOptions;
|
|
11
|
12
|
@end
|
|
12
|
|
-
|
|
13
|
13
|
@implementation RNNBasePresenter
|
|
14
|
14
|
|
|
15
|
|
--(instancetype)init {
|
|
|
15
|
+-(instancetype)initWithDefaultOptions:(RNNNavigationOptions *)defaultOptions {
|
|
16
|
16
|
self = [super init];
|
|
17
|
|
- self.dotIndicatorPresenter = [RNNDotIndicatorPresenter new];
|
|
|
17
|
+ _defaultOptions = defaultOptions;
|
|
|
18
|
+ self.dotIndicatorPresenter = [[RNNDotIndicatorPresenter alloc] initWithDefaultOptions:_defaultOptions];
|
|
18
|
19
|
return self;
|
|
19
|
20
|
}
|
|
20
|
21
|
|
|
|
@@ -33,64 +34,66 @@
|
|
33
|
34
|
|
|
34
|
35
|
- (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {
|
|
35
|
36
|
UIViewController *viewController = self.boundViewController;
|
|
|
37
|
+ RNNNavigationOptions * withDefault = [options withDefault:_defaultOptions];
|
|
36
|
38
|
|
|
37
|
|
- if (options.bottomTab.text.hasValue) {
|
|
38
|
|
- UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
|
|
|
39
|
+ if (withDefault.bottomTab.text.hasValue) {
|
|
|
40
|
+ UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:withDefault.bottomTab];
|
|
39
|
41
|
viewController.tabBarItem = tabItem;
|
|
40
|
42
|
}
|
|
41
|
43
|
|
|
42
|
|
- if (options.bottomTab.icon.hasValue) {
|
|
43
|
|
- UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
|
|
|
44
|
+ if (withDefault.bottomTab.icon.hasValue) {
|
|
|
45
|
+ UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:withDefault.bottomTab];
|
|
44
|
46
|
viewController.tabBarItem = tabItem;
|
|
45
|
47
|
}
|
|
46
|
48
|
|
|
47
|
|
- if (options.bottomTab.selectedIcon.hasValue) {
|
|
48
|
|
- UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
|
|
|
49
|
+ if (withDefault.bottomTab.selectedIcon.hasValue) {
|
|
|
50
|
+ UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:withDefault.bottomTab];
|
|
49
|
51
|
viewController.tabBarItem = tabItem;
|
|
50
|
52
|
}
|
|
51
|
53
|
|
|
52
|
|
- if (options.bottomTab.badgeColor.hasValue) {
|
|
53
|
|
- UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
|
|
|
54
|
+ if (withDefault.bottomTab.badgeColor.hasValue) {
|
|
|
55
|
+ UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:withDefault.bottomTab];
|
|
54
|
56
|
viewController.tabBarItem = tabItem;
|
|
55
|
57
|
}
|
|
56
|
58
|
|
|
57
|
|
- if (options.bottomTab.textColor.hasValue) {
|
|
58
|
|
- UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
|
|
|
59
|
+ if (withDefault.bottomTab.textColor.hasValue) {
|
|
|
60
|
+ UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:withDefault.bottomTab];
|
|
59
|
61
|
viewController.tabBarItem = tabItem;
|
|
60
|
62
|
}
|
|
61
|
63
|
|
|
62
|
|
- if (options.bottomTab.iconColor.hasValue) {
|
|
63
|
|
- UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
|
|
|
64
|
+ if (withDefault.bottomTab.iconColor.hasValue) {
|
|
|
65
|
+ UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:withDefault.bottomTab];
|
|
64
|
66
|
viewController.tabBarItem = tabItem;
|
|
65
|
67
|
}
|
|
66
|
68
|
|
|
67
|
|
- if (options.bottomTab.selectedTextColor.hasValue) {
|
|
68
|
|
- UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
|
|
|
69
|
+ if (withDefault.bottomTab.selectedTextColor.hasValue) {
|
|
|
70
|
+ UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:withDefault.bottomTab];
|
|
69
|
71
|
viewController.tabBarItem = tabItem;
|
|
70
|
72
|
}
|
|
71
|
73
|
|
|
72
|
|
- if (options.bottomTab.selectedIconColor.hasValue) {
|
|
73
|
|
- UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
|
|
|
74
|
+ if (withDefault.bottomTab.selectedIconColor.hasValue) {
|
|
|
75
|
+ UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:withDefault.bottomTab];
|
|
74
|
76
|
viewController.tabBarItem = tabItem;
|
|
75
|
77
|
}
|
|
76
|
78
|
}
|
|
77
|
79
|
|
|
78
|
80
|
- (void)applyOptions:(RNNNavigationOptions *)options {
|
|
79
|
81
|
UIViewController *viewController = self.boundViewController;
|
|
|
82
|
+ RNNNavigationOptions * withDefault = [options withDefault:_defaultOptions];
|
|
80
|
83
|
|
|
81
|
|
- if (options.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
|
|
82
|
|
- [viewController rnn_setTabBarItemBadge:options.bottomTab];
|
|
|
84
|
+ if (withDefault.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
|
|
|
85
|
+ [viewController rnn_setTabBarItemBadge:withDefault.bottomTab.badge.get];
|
|
83
|
86
|
}
|
|
84
|
87
|
|
|
85
|
|
- if (options.bottomTab.badgeColor.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
|
|
86
|
|
- [viewController rnn_setTabBarItemBadgeColor:options.bottomTab.badgeColor.get];
|
|
|
88
|
+ if (withDefault.bottomTab.badgeColor.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
|
|
|
89
|
+ [viewController rnn_setTabBarItemBadgeColor:withDefault.bottomTab.badgeColor.get];
|
|
87
|
90
|
}
|
|
88
|
91
|
}
|
|
89
|
92
|
|
|
90
|
|
-- (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
|
|
|
93
|
+- (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions {
|
|
91
|
94
|
UIViewController *viewController = self.boundViewController;
|
|
92
|
95
|
if (newOptions.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
|
|
93
|
|
- [viewController rnn_setTabBarItemBadge:newOptions.bottomTab];
|
|
|
96
|
+ [viewController rnn_setTabBarItemBadge:newOptions.bottomTab.badge.get];
|
|
94
|
97
|
}
|
|
95
|
98
|
|
|
96
|
99
|
if (newOptions.bottomTab.badgeColor.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
|
|
|
@@ -102,43 +105,43 @@
|
|
102
|
105
|
}
|
|
103
|
106
|
|
|
104
|
107
|
if (newOptions.bottomTab.text.hasValue) {
|
|
105
|
|
- RNNNavigationOptions *buttonsResolvedOptions = [(RNNNavigationOptions *) [currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
|
|
|
108
|
+ RNNNavigationOptions *buttonsResolvedOptions = (RNNNavigationOptions *) [currentOptions overrideOptions:newOptions];
|
|
106
|
109
|
UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
|
|
107
|
110
|
viewController.tabBarItem = tabItem;
|
|
108
|
111
|
}
|
|
109
|
112
|
|
|
110
|
113
|
if (newOptions.bottomTab.icon.hasValue) {
|
|
111
|
|
- RNNNavigationOptions *buttonsResolvedOptions = [(RNNNavigationOptions *) [currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
|
|
|
114
|
+ RNNNavigationOptions *buttonsResolvedOptions = (RNNNavigationOptions *) [currentOptions overrideOptions:newOptions];
|
|
112
|
115
|
UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
|
|
113
|
116
|
viewController.tabBarItem = tabItem;
|
|
114
|
117
|
}
|
|
115
|
118
|
|
|
116
|
119
|
if (newOptions.bottomTab.selectedIcon.hasValue) {
|
|
117
|
|
- RNNNavigationOptions *buttonsResolvedOptions = [(RNNNavigationOptions *) [currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
|
|
|
120
|
+ RNNNavigationOptions *buttonsResolvedOptions = (RNNNavigationOptions *) [currentOptions overrideOptions:newOptions];
|
|
118
|
121
|
UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
|
|
119
|
122
|
viewController.tabBarItem = tabItem;
|
|
120
|
123
|
}
|
|
121
|
124
|
|
|
122
|
125
|
if (newOptions.bottomTab.textColor.hasValue) {
|
|
123
|
|
- RNNNavigationOptions *buttonsResolvedOptions = [(RNNNavigationOptions *) [currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
|
|
|
126
|
+ RNNNavigationOptions *buttonsResolvedOptions = (RNNNavigationOptions *) [currentOptions overrideOptions:newOptions];
|
|
124
|
127
|
UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
|
|
125
|
128
|
viewController.tabBarItem = tabItem;
|
|
126
|
129
|
}
|
|
127
|
130
|
|
|
128
|
131
|
if (newOptions.bottomTab.selectedTextColor.hasValue) {
|
|
129
|
|
- RNNNavigationOptions *buttonsResolvedOptions = [(RNNNavigationOptions *) [currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
|
|
|
132
|
+ RNNNavigationOptions *buttonsResolvedOptions = (RNNNavigationOptions *) [currentOptions overrideOptions:newOptions];
|
|
130
|
133
|
UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
|
|
131
|
134
|
viewController.tabBarItem = tabItem;
|
|
132
|
135
|
}
|
|
133
|
136
|
|
|
134
|
137
|
if (newOptions.bottomTab.iconColor.hasValue) {
|
|
135
|
|
- RNNNavigationOptions *buttonsResolvedOptions = [(RNNNavigationOptions *) [currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
|
|
|
138
|
+ RNNNavigationOptions *buttonsResolvedOptions = (RNNNavigationOptions *) [currentOptions overrideOptions:newOptions];
|
|
136
|
139
|
UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
|
|
137
|
140
|
viewController.tabBarItem = tabItem;
|
|
138
|
141
|
}
|
|
139
|
142
|
|
|
140
|
143
|
if (newOptions.bottomTab.selectedIconColor.hasValue) {
|
|
141
|
|
- RNNNavigationOptions *buttonsResolvedOptions = [(RNNNavigationOptions *) [currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
|
|
|
144
|
+ RNNNavigationOptions *buttonsResolvedOptions = (RNNNavigationOptions *) [currentOptions overrideOptions:newOptions];
|
|
142
|
145
|
UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
|
|
143
|
146
|
viewController.tabBarItem = tabItem;
|
|
144
|
147
|
}
|