Skip to content

Commit 24dd090

Browse files
committed
Adds content for AnalyticsProductCard
1 parent ec2a618 commit 24dd090

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/Analytics Hub/AnalyticsProductCard.swift

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,60 @@ import SwiftUI
33
/// Products Card on the Analytics Hub
44
///
55
struct AnalyticsProductCard: View {
6+
7+
/// Items sold quantity. Needs to be formatted.
8+
///
9+
let itemsSold: String
10+
11+
/// Delta Tag Value. Needs to be formatted
12+
let delta: String
13+
14+
/// Delta Tag background color.
15+
let deltaBackgroundColor: UIColor
16+
617
var body: some View {
7-
Text("Empty")
18+
VStack(alignment: .leading) {
19+
20+
Text(Localization.title)
21+
.foregroundColor(Color(.text))
22+
.footnoteStyle()
23+
24+
Text(Localization.itemsSold)
25+
.headlineStyle()
26+
.padding(.top, Layout.titleSpacing)
27+
.padding(.bottom, Layout.columnSpacing)
28+
29+
HStack {
30+
Text(itemsSold)
31+
.titleStyle()
32+
.frame(maxWidth: .infinity, alignment: .leading)
33+
34+
DeltaTag(value: delta, backgroundColor: deltaBackgroundColor)
35+
}
36+
}
37+
.padding(Layout.cardPadding)
38+
}
39+
}
40+
41+
// MARK: Constants
42+
private extension AnalyticsProductCard {
43+
enum Localization {
44+
static let title = NSLocalizedString("Products", comment: "Title for the products card on the analytics hub screen.").localizedUppercase
45+
static let itemsSold = NSLocalizedString("Items Sold", comment: "Title for the items sold column on the products card on the analytics hub screen.")
46+
}
47+
48+
enum Layout {
49+
static let titleSpacing: CGFloat = 24
50+
static let cardPadding: CGFloat = 16
51+
static let columnSpacing: CGFloat = 10
852
}
953
}
1054

1155

1256
// MARK: Previews
1357
struct AnalyticsProductCardPreviews: PreviewProvider {
1458
static var previews: some View {
15-
AnalyticsProductCard()
59+
AnalyticsProductCard(itemsSold: "2,234", delta: "+23%", deltaBackgroundColor: .withColorStudio(.green, shade: .shade50))
1660
.previewLayout(.sizeThatFits)
1761
}
1862
}

0 commit comments

Comments
 (0)