Преглед изворни кода

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

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

* Minor changes
Rav Sispal пре 5 година
родитељ
комит
23626556cf
1 измењених фајлова са 89 додато и 6 уклоњено
  1. 89
    6
      lib/ios/RNNBasePresenter.m

+ 89
- 6
lib/ios/RNNBasePresenter.m Прегледај датотеку

@@ -21,26 +21,63 @@
21 21
 }
22 22
 
23 23
 - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
24
-	
24
+
25 25
 }
26 26
 
27 27
 - (void)applyOptionsOnWillMoveToParentViewController:(RNNNavigationOptions *)options {
28 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 66
 		UITabBarItem* tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:options.bottomTab];
31 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 71
 - (void)applyOptions:(RNNNavigationOptions *)options {
39 72
 	UIViewController* viewController = self.bindedViewController;
40
-	
73
+
41 74
 	if (options.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
42 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 83
 - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
@@ -48,6 +85,52 @@
48 85
 	if (newOptions.bottomTab.badge.hasValue && [viewController.parentViewController isKindOfClass:[UITabBarController class]]) {
49 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