Browse Source

[V2][iOS] Additional mergeOptions BottomTab Support (#4704)

* Added missing mergeOptions for text, icon, selectedIcon, textColor, selectedTextColor, iconColor, selectedIconColor, badgeColor

* Minor changes
Rav Sispal 6 years ago
parent
commit
23626556cf
1 changed files with 89 additions and 6 deletions
  1. 89
    6
      lib/ios/RNNBasePresenter.m

+ 89
- 6
lib/ios/RNNBasePresenter.m View File

21
 }
21
 }
22
 
22
 
23
 - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
23
 - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
24
-	
24
+
25
 }
25
 }
26
 
26
 
27
 - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {
27
 - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {
28
 	UIViewController* viewController = self.bindedViewController;
28
 	UIViewController* viewController = self.bindedViewController;
29
-	if ((options.bottomTab.text.hasValue || options.bottomTab.icon.hasValue || options.bottomTab.selectedIcon.hasValue)) {
29
+
30
+	if (options.bottomTab.text.hasValue) {
31
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
32
+		viewController.tabBarItem = tabItem;
33
+	}
34
+
35
+	if (options.bottomTab.icon.hasValue) {
36
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
37
+		viewController.tabBarItem = tabItem;
38
+	}
39
+
40
+	if (options.bottomTab.selectedIcon.hasValue) {
41
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
42
+		viewController.tabBarItem = tabItem;
43
+	}
44
+
45
+	if (options.bottomTab.badgeColor.hasValue) {
46
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
47
+		viewController.tabBarItem = tabItem;
48
+	}
49
+
50
+	if (options.bottomTab.textColor.hasValue) {
51
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
52
+		viewController.tabBarItem = tabItem;
53
+	}
54
+
55
+	if (options.bottomTab.iconColor.hasValue) {
56
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
57
+		viewController.tabBarItem = tabItem;
58
+	}
59
+
60
+	if (options.bottomTab.selectedTextColor.hasValue) {
61
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
62
+		viewController.tabBarItem = tabItem;
63
+	}
64
+
65
+	if (options.bottomTab.selectedIconColor.hasValue) {
30
 		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
66
 		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
31
 		viewController.tabBarItem = tabItem;
67
 		viewController.tabBarItem = tabItem;
32
-		[options.bottomTab.text consume];
33
-		[options.bottomTab.icon consume];
34
-		[options.bottomTab.selectedIcon consume];
35
 	}
68
 	}
36
 }
69
 }
37
 
70
 
38
 - (void)applyOptions:(RNNNavigationOptions *)options {
71
 - (void)applyOptions:(RNNNavigationOptions *)options {
39
 	UIViewController* viewController = self.bindedViewController;
72
 	UIViewController* viewController = self.bindedViewController;
40
-	
73
+
41
 	if (options.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
74
 	if (options.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
42
 		[viewController rnn_setTabBarItemBadge:options.bottomTab.badge.get];
75
 		[viewController rnn_setTabBarItemBadge:options.bottomTab.badge.get];
43
 	}
76
 	}
77
+
78
+	if (options.bottomTab.badgeColor.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
79
+		[viewController rnn_setTabBarItemBadgeColor:options.bottomTab.badgeColor.get];
80
+	}
44
 }
81
 }
45
 
82
 
46
 - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
83
 - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
48
 	if (newOptions.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
85
 	if (newOptions.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
49
 		[viewController rnn_setTabBarItemBadge:newOptions.bottomTab.badge.get];
86
 		[viewController rnn_setTabBarItemBadge:newOptions.bottomTab.badge.get];
50
 	}
87
 	}
88
+
89
+	if (newOptions.bottomTab.badgeColor.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
90
+		[viewController rnn_setTabBarItemBadgeColor:newOptions.bottomTab.badgeColor.get];
91
+	}
92
+
93
+	if (newOptions.bottomTab.text.hasValue) {
94
+		RNNNavigationOptions* buttonsResolvedOptions = [(RNNNavigationOptions *)[currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
95
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
96
+		viewController.tabBarItem = tabItem;
97
+	}
98
+
99
+	if (newOptions.bottomTab.icon.hasValue) {
100
+		RNNNavigationOptions* buttonsResolvedOptions = [(RNNNavigationOptions *)[currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
101
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
102
+		viewController.tabBarItem = tabItem;
103
+	}
104
+
105
+	if (newOptions.bottomTab.selectedIcon.hasValue) {
106
+		RNNNavigationOptions* buttonsResolvedOptions = [(RNNNavigationOptions *)[currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
107
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
108
+		viewController.tabBarItem = tabItem;
109
+	}
110
+
111
+	if (newOptions.bottomTab.textColor.hasValue) {
112
+		RNNNavigationOptions* buttonsResolvedOptions = [(RNNNavigationOptions *)[currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
113
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
114
+		viewController.tabBarItem = tabItem;
115
+	}
116
+
117
+	if (newOptions.bottomTab.selectedTextColor.hasValue) {
118
+		RNNNavigationOptions* buttonsResolvedOptions = [(RNNNavigationOptions *)[currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
119
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
120
+		viewController.tabBarItem = tabItem;
121
+	}
122
+
123
+	if (newOptions.bottomTab.iconColor.hasValue) {
124
+		RNNNavigationOptions* buttonsResolvedOptions = [(RNNNavigationOptions *)[currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
125
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
126
+		viewController.tabBarItem = tabItem;
127
+	}
128
+
129
+	if (newOptions.bottomTab.selectedIconColor.hasValue) {
130
+		RNNNavigationOptions* buttonsResolvedOptions = [(RNNNavigationOptions *)[currentOptions overrideOptions:newOptions] withDefault:defaultOptions];
131
+		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:buttonsResolvedOptions.bottomTab];
132
+		viewController.tabBarItem = tabItem;
133
+	}
51
 }
134
 }
52
 
135
 
53
 
136