@@ -197,17 +197,17 @@ private extension AnalyticsHubViewModel {
197197 leadingValue: StatsDataTextFormatter . createTotalRevenueText ( orderStats: currentPeriodStats,
198198 selectedIntervalIndex: nil ) ,
199199 leadingDelta: totalDelta. string,
200- leadingDeltaColor: Constants . deltaColor ( for : totalDelta. direction) ,
201- leadingDeltaTextColor: Constants . deltaTextColor ( for : totalDelta. direction) ,
200+ leadingDeltaColor: totalDelta. direction. deltaBackgroundColor ,
201+ leadingDeltaTextColor: totalDelta. direction. deltaTextColor ,
202202 leadingChartData: StatsIntervalDataParser . getChartData ( for: . totalRevenue, from: currentPeriodStats) ,
203- leadingChartColor: Constants . chartColor ( for : totalDelta. direction) ,
203+ leadingChartColor: totalDelta. direction. chartColor ,
204204 trailingTitle: Localization . RevenueCard. trailingTitle,
205205 trailingValue: StatsDataTextFormatter . createNetRevenueText ( orderStats: currentPeriodStats) ,
206206 trailingDelta: netDelta. string,
207- trailingDeltaColor: Constants . deltaColor ( for : netDelta. direction) ,
208- trailingDeltaTextColor: Constants . deltaTextColor ( for : netDelta. direction) ,
207+ trailingDeltaColor: netDelta. direction. deltaBackgroundColor ,
208+ trailingDeltaTextColor: netDelta. direction. deltaTextColor ,
209209 trailingChartData: StatsIntervalDataParser . getChartData ( for: . netRevenue, from: currentPeriodStats) ,
210- trailingChartColor: Constants . chartColor ( for : netDelta. direction) ,
210+ trailingChartColor: netDelta. direction. chartColor ,
211211 isRedacted: false ,
212212 showSyncError: showSyncError,
213213 syncErrorMessage: Localization . RevenueCard. noRevenue)
@@ -223,17 +223,17 @@ private extension AnalyticsHubViewModel {
223223 leadingValue: StatsDataTextFormatter . createOrderCountText ( orderStats: currentPeriodStats,
224224 selectedIntervalIndex: nil ) ,
225225 leadingDelta: ordersCountDelta. string,
226- leadingDeltaColor: Constants . deltaColor ( for : ordersCountDelta. direction) ,
227- leadingDeltaTextColor: Constants . deltaTextColor ( for : ordersCountDelta. direction) ,
226+ leadingDeltaColor: ordersCountDelta. direction. deltaBackgroundColor ,
227+ leadingDeltaTextColor: ordersCountDelta. direction. deltaTextColor ,
228228 leadingChartData: StatsIntervalDataParser . getChartData ( for: . orderCount, from: currentPeriodStats) ,
229- leadingChartColor: Constants . chartColor ( for : ordersCountDelta. direction) ,
229+ leadingChartColor: ordersCountDelta. direction. chartColor ,
230230 trailingTitle: Localization . OrderCard. trailingTitle,
231231 trailingValue: StatsDataTextFormatter . createAverageOrderValueText ( orderStats: currentPeriodStats) ,
232232 trailingDelta: orderValueDelta. string,
233- trailingDeltaColor: Constants . deltaColor ( for : orderValueDelta. direction) ,
234- trailingDeltaTextColor: Constants . deltaTextColor ( for : orderValueDelta. direction) ,
233+ trailingDeltaColor: orderValueDelta. direction. deltaBackgroundColor ,
234+ trailingDeltaTextColor: orderValueDelta. direction. deltaTextColor ,
235235 trailingChartData: StatsIntervalDataParser . getChartData ( for: . averageOrderValue, from: currentPeriodStats) ,
236- trailingChartColor: Constants . chartColor ( for : orderValueDelta. direction) ,
236+ trailingChartColor: orderValueDelta. direction. chartColor ,
237237 isRedacted: false ,
238238 showSyncError: showSyncError,
239239 syncErrorMessage: Localization . OrderCard. noOrders)
@@ -251,8 +251,8 @@ private extension AnalyticsHubViewModel {
251251
252252 return AnalyticsProductCardViewModel ( itemsSold: itemsSold,
253253 delta: itemsSoldDelta. string,
254- deltaBackgroundColor: Constants . deltaColor ( for : itemsSoldDelta. direction) ,
255- deltaTextColor: Constants . deltaTextColor ( for : itemsSoldDelta. direction) ,
254+ deltaBackgroundColor: itemsSoldDelta. direction. deltaBackgroundColor ,
255+ deltaTextColor: itemsSoldDelta. direction. deltaTextColor ,
256256 itemsSoldData: itemSoldRows ( from: itemsSoldStats) ,
257257 isRedacted: false ,
258258 showStatsError: showStatsError,
@@ -285,36 +285,6 @@ private extension AnalyticsHubViewModel {
285285private extension AnalyticsHubViewModel {
286286 enum Constants {
287287 static let maxNumberOfTopItemsSold = 5
288-
289- static func deltaColor( for direction: StatsDataTextFormatter . DeltaPercentage . Direction ) -> UIColor {
290- switch direction {
291- case . positive:
292- return . withColorStudio( . green, shade: . shade50)
293- case . negative:
294- return . withColorStudio( . red, shade: . shade40)
295- case . zero:
296- return . withColorStudio( . gray, shade: . shade0)
297- }
298- }
299- static func deltaTextColor( for direction: StatsDataTextFormatter . DeltaPercentage . Direction ) -> UIColor {
300- switch direction {
301- case . positive, . negative:
302- return . textInverted
303- case . zero:
304- return . text
305- }
306- }
307-
308- static func chartColor( for direction: StatsDataTextFormatter . DeltaPercentage . Direction ) -> UIColor {
309- switch direction {
310- case . positive:
311- return . withColorStudio( . green, shade: . shade50)
312- case . negative:
313- return . withColorStudio( . red, shade: . shade40)
314- case . zero:
315- return . withColorStudio( . gray, shade: . shade30)
316- }
317- }
318288 }
319289
320290 enum Localization {
0 commit comments