diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Analytics Hub/AnalyticsHubViewModel.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Analytics Hub/AnalyticsHubViewModel.swift index 6eef390b127..1d119ee7b3d 100644 --- a/WooCommerce/Classes/ViewRelated/Dashboard/Analytics Hub/AnalyticsHubViewModel.swift +++ b/WooCommerce/Classes/ViewRelated/Dashboard/Analytics Hub/AnalyticsHubViewModel.swift @@ -1,5 +1,6 @@ import Foundation import Yosemite +import class UIKit.UIColor /// Main View Model for the Analytics Hub. /// @@ -24,27 +25,27 @@ final class AnalyticsHubViewModel: ObservableObject { /// Revenue Card ViewModel /// - @Published var revenueCard = AnalyticsReportCardViewModel(title: "REVENUE", - leadingTitle: "Total Sales", - leadingValue: "$3.234", - leadingDelta: "+23%", - leadingDeltaColor: .withColorStudio(.green, shade: .shade50), - trailingTitle: "Net Sales", - trailingValue: "$2.324", - trailingDelta: "-4%", - trailingDeltaColor: .withColorStudio(.red, shade: .shade40)) + @Published var revenueCard = AnalyticsReportCardViewModel(title: Localization.RevenueCard.title, + leadingTitle: Localization.RevenueCard.leadingTitle, + leadingValue: Constants.placeholderValue, + leadingDelta: Constants.placeholderDelta.string, + leadingDeltaColor: Constants.deltaColor(for: Constants.placeholderDelta.direction), + trailingTitle: Localization.RevenueCard.trailingTitle, + trailingValue: Constants.placeholderValue, + trailingDelta: Constants.placeholderDelta.string, + trailingDeltaColor: Constants.deltaColor(for: Constants.placeholderDelta.direction)) /// Orders Card ViewModel /// - @Published var ordersCard = AnalyticsReportCardViewModel(title: "ORDERS", - leadingTitle: "Total Orders", - leadingValue: "145", - leadingDelta: "+36%", - leadingDeltaColor: .withColorStudio(.green, shade: .shade50), - trailingTitle: "Average Order Value", - trailingValue: "$57,99", - trailingDelta: "-16%", - trailingDeltaColor: .withColorStudio(.red, shade: .shade40)) + @Published var ordersCard = AnalyticsReportCardViewModel(title: Localization.OrderCard.title, + leadingTitle: Localization.OrderCard.leadingTitle, + leadingValue: Constants.placeholderValue, + leadingDelta: Constants.placeholderDelta.string, + leadingDeltaColor: Constants.deltaColor(for: Constants.placeholderDelta.direction), + trailingTitle: Localization.OrderCard.trailingTitle, + trailingValue: Constants.placeholderValue, + trailingDelta: Constants.placeholderDelta.string, + trailingDeltaColor: Constants.deltaColor(for: Constants.placeholderDelta.direction)) // MARK: Private data @@ -97,3 +98,33 @@ private extension AnalyticsHubViewModel { } } } + +// MARK: - Constants +private extension AnalyticsHubViewModel { + enum Constants { + static let placeholderValue = "-" + static let placeholderDelta = StatsDataTextFormatter.createDeltaPercentage(from: 0.0, to: 0.0) + static func deltaColor(for direction: StatsDataTextFormatter.DeltaPercentage.Direction) -> UIColor { + switch direction { + case .positive: + return .withColorStudio(.green, shade: .shade50) + case .negative, .zero: + return .withColorStudio(.red, shade: .shade40) + } + } + } + + enum Localization { + enum RevenueCard { + static let title = NSLocalizedString("REVENUE", comment: "Title for revenue analytics section in the Analytics Hub") + static let leadingTitle = NSLocalizedString("Total Sales", comment: "Label for total sales (gross revenue) in the Analytics Hub") + static let trailingTitle = NSLocalizedString("Net Sales", comment: "Label for net sales (net revenue) in the Analytics Hub") + } + + enum OrderCard { + static let title = NSLocalizedString("ORDERS", comment: "Title for order analytics section in the Analytics Hub") + static let leadingTitle = NSLocalizedString("Total Orders", comment: "Label for total number of orders in the Analytics Hub") + static let trailingTitle = NSLocalizedString("Average Order Value", comment: "Label for average value of orders in the Analytics Hub") + } + } +}