Skip to content

Commit 78c667f

Browse files
committed
Adds AnalyticsProductCardViewModel
1 parent aa70ef7 commit 78c667f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Foundation
2+
import class UIKit.UIColor
3+
4+
/// Analytics Hub Product Card ViewModel.
5+
/// Used to transmit analytics products data.
6+
///
7+
struct AnalyticsProductCardViewModel {
8+
/// Items Sold Value
9+
///
10+
let itemsSold: String
11+
12+
/// Items Sold Delta
13+
///
14+
let delta: String
15+
16+
/// Delta background color.
17+
///
18+
let deltaBackgroundColor: UIColor
19+
}
20+
21+
/// Convenience extension to create an `AnalyticsReportCard` from a view model.
22+
///
23+
extension AnalyticsProductCard {
24+
init(viewModel: AnalyticsProductCardViewModel) {
25+
self.itemsSold = viewModel.itemsSold
26+
self.delta = viewModel.delta
27+
self.deltaBackgroundColor = viewModel.deltaBackgroundColor
28+
}
29+
}

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@
648648
26E7EE6C292D894100793045 /* AnalyticsReportCardViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E7EE6B292D894100793045 /* AnalyticsReportCardViewModel.swift */; };
649649
26E7EE6E29300E8100793045 /* AnalyticsProductCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E7EE6D29300E8100793045 /* AnalyticsProductCard.swift */; };
650650
26E7EE7029300F6200793045 /* DeltaTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E7EE6F29300F6200793045 /* DeltaTag.swift */; };
651+
26E7EE7229301EBC00793045 /* AnalyticsProductCardViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26E7EE7129301EBC00793045 /* AnalyticsProductCardViewModel.swift */; };
651652
26ED9660274328BC00FA00A1 /* SimplePaymentsSummaryViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26ED965F274328BC00FA00A1 /* SimplePaymentsSummaryViewModel.swift */; };
652653
26F65C9825DEDAF0008FAE29 /* GenerateVariationUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26F65C9725DEDAF0008FAE29 /* GenerateVariationUseCase.swift */; };
653654
26F65C9E25DEDE67008FAE29 /* GenerateVariationUseCaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26F65C9D25DEDE67008FAE29 /* GenerateVariationUseCaseTests.swift */; };
@@ -2627,6 +2628,7 @@
26272628
26E7EE6B292D894100793045 /* AnalyticsReportCardViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsReportCardViewModel.swift; sourceTree = "<group>"; };
26282629
26E7EE6D29300E8100793045 /* AnalyticsProductCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsProductCard.swift; sourceTree = "<group>"; };
26292630
26E7EE6F29300F6200793045 /* DeltaTag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeltaTag.swift; sourceTree = "<group>"; };
2631+
26E7EE7129301EBC00793045 /* AnalyticsProductCardViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsProductCardViewModel.swift; sourceTree = "<group>"; };
26302632
26ED965F274328BC00FA00A1 /* SimplePaymentsSummaryViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimplePaymentsSummaryViewModel.swift; sourceTree = "<group>"; };
26312633
26F65C9725DEDAF0008FAE29 /* GenerateVariationUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenerateVariationUseCase.swift; sourceTree = "<group>"; };
26322634
26F65C9D25DEDE67008FAE29 /* GenerateVariationUseCaseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenerateVariationUseCaseTests.swift; sourceTree = "<group>"; };
@@ -5282,6 +5284,7 @@
52825284
B60B5025292D308A00178C26 /* AnalyticsTimeRangeCard.swift */,
52835285
B6A10E9B292E5DEE00790797 /* AnalyticsTimeRangeCardViewModel.swift */,
52845286
26E7EE6D29300E8100793045 /* AnalyticsProductCard.swift */,
5287+
26E7EE7129301EBC00793045 /* AnalyticsProductCardViewModel.swift */,
52855288
);
52865289
path = "Analytics Hub";
52875290
sourceTree = "<group>";
@@ -10340,6 +10343,7 @@
1034010343
E1E649E92846188C0070B194 /* BetaFeature.swift in Sources */,
1034110344
0286B27B23C7051F003D784B /* ProductImagesCollectionViewController.swift in Sources */,
1034210345
E107FCE126C12B2700BAF51B /* InPersonPaymentsCountryNotSupported.swift in Sources */,
10346+
26E7EE7229301EBC00793045 /* AnalyticsProductCardViewModel.swift in Sources */,
1034310347
027A2E142513124E00DA6ACB /* Keychain+Entries.swift in Sources */,
1034410348
268EC45F26CEA50C00716F5C /* EditCustomerNote.swift in Sources */,
1034510349
4535EE7E281BE04A004212B4 /* CouponAmountInputFormatter.swift in Sources */,

0 commit comments

Comments
 (0)