Skip to content

Commit d708c33

Browse files
authored
Merge pull request #6161 from woocommerce/issue/5765-usage-details-row-and-polish
Coupons: Add row for usage details and some polishing for coupon details screen
2 parents db6bd8e + b878b61 commit d708c33

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

WooCommerce/Classes/ViewRelated/Coupons/CouponDetails/CouponDetails.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct CouponDetails: View {
112112
ForEach(detailRows) { row in
113113
TitleAndValueRow(title: row.title,
114114
value: .content(row.content),
115-
selectable: true,
115+
selectable: false,
116116
action: row.action)
117117
.padding(.vertical, Constants.verticalSpacing)
118118
.padding(.horizontal, insets: geometry.safeAreaInsets)
@@ -122,6 +122,19 @@ struct CouponDetails: View {
122122
}
123123
}
124124
.background(Color(.listForeground))
125+
126+
Spacer().frame(height: Constants.margin)
127+
Divider()
128+
VStack {
129+
NavigationRow(content: {
130+
Text(Localization.usageDetails)
131+
.bodyStyle()
132+
}, action: {
133+
// TODO-5766: Add usage details screen
134+
}).padding(.horizontal, insets: geometry.safeAreaInsets)
135+
}
136+
.background(Color(.listForeground))
137+
Divider()
125138
}
126139
}
127140
.background(Color(.listBackground))
@@ -165,6 +178,7 @@ private extension CouponDetails {
165178
static let performance = NSLocalizedString("Performance", comment: "Title of the Performance section on Coupons Details screen")
166179
static let discountedOrders = NSLocalizedString("Discounted Orders", comment: "Title of the Discounted Orders label on Coupon Details screen")
167180
static let amount = NSLocalizedString("Amount", comment: "Title of the Amount label on Coupon Details screen")
181+
static let usageDetails = NSLocalizedString("Usage details", comment: "Title of the Usage details row in Coupon Details screen")
168182
}
169183

170184
struct DetailRow: Identifiable {

WooCommerce/Classes/ViewRelated/Coupons/CouponDetails/CouponDetailsViewModel.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ private extension CouponDetailsViewModel {
132132

133133
/// Localize content for the "Apply to" field. This takes into consideration different cases of apply rules:
134134
/// - When only specific products or categories are defined: Display "x Products" or "x Categories"
135-
/// - When specific products/categories and exceptions are defined: Display "x Products except y Categories" etc.
135+
/// - When specific products/categories and exceptions are defined: Display "x Products excl. y Categories" etc.
136136
/// - When both specific products and categories are defined: Display "x Products and y Categories"
137-
/// - When only exceptions are defined: Display "All except x Products" or "All except y Categories"
137+
/// - When only exceptions are defined: Display "All excl. x Products" or "All excl. y Categories"
138138
///
139139
func localizeApplyRules(productsCount: Int, excludedProductsCount: Int, categoriesCount: Int, excludedCategoriesCount: Int) -> String {
140140
let productText = String.pluralize(productsCount, singular: Localization.singleProduct, plural: Localization.multipleProducts)
@@ -198,8 +198,8 @@ private extension CouponDetailsViewModel {
198198
comment: "The number of category allowed for a coupon in plural form. " +
199199
"Reads like: 10 Categories"
200200
)
201-
static let allWithException = NSLocalizedString("All except %1$@", comment: "Exception rule for a coupon. Reads like: All except 2 Products")
202-
static let ruleWithException = NSLocalizedString("%1$@ except %2$@", comment: "Exception rule for a coupon. Reads like: 3 Products except 1 Category")
201+
static let allWithException = NSLocalizedString("All excl. %1$@", comment: "Exception rule for a coupon. Reads like: All excl. 2 Products")
202+
static let ruleWithException = NSLocalizedString("%1$@ excl. %2$@", comment: "Exception rule for a coupon. Reads like: 3 Products excl. 1 Category")
203203
static let combinedRules = NSLocalizedString("%1$@ and %2$@", comment: "Combined rule for a coupon. Reads like: 2 Products and 1 Category")
204204
}
205205
}

WooCommerce/WooCommerceTests/ViewRelated/Coupons/CouponDetailsViewModelTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ final class CouponDetailsViewModelTests: XCTestCase {
8787
let viewModel = CouponDetailsViewModel(coupon: sampleCoupon)
8888

8989
// Then
90-
let appliedTo = String(format: NSLocalizedString("%d Products except %d Category", comment: ""), 3, 1)
90+
let appliedTo = String(format: NSLocalizedString("%d Products excl. %d Category", comment: ""), 3, 1)
9191
XCTAssertEqual(viewModel.productsAppliedTo, appliedTo)
9292
}
9393

@@ -97,7 +97,7 @@ final class CouponDetailsViewModelTests: XCTestCase {
9797
let viewModel = CouponDetailsViewModel(coupon: sampleCoupon)
9898

9999
// Then
100-
let appliedTo = String(format: NSLocalizedString("%d Categories except %d Products", comment: ""), 3, 2)
100+
let appliedTo = String(format: NSLocalizedString("%d Categories excl. %d Products", comment: ""), 3, 2)
101101
XCTAssertEqual(viewModel.productsAppliedTo, appliedTo)
102102
}
103103

@@ -107,7 +107,7 @@ final class CouponDetailsViewModelTests: XCTestCase {
107107
let viewModel = CouponDetailsViewModel(coupon: sampleCoupon)
108108

109109
// Then
110-
let appliedTo = String(format: NSLocalizedString("All except %d Products", comment: ""), 2)
110+
let appliedTo = String(format: NSLocalizedString("All excl. %d Products", comment: ""), 2)
111111
XCTAssertEqual(viewModel.productsAppliedTo, appliedTo)
112112
}
113113

@@ -117,7 +117,7 @@ final class CouponDetailsViewModelTests: XCTestCase {
117117
let viewModel = CouponDetailsViewModel(coupon: sampleCoupon)
118118

119119
// Then
120-
let appliedTo = String(format: NSLocalizedString("All except %d Categories", comment: ""), 2)
120+
let appliedTo = String(format: NSLocalizedString("All excl. %d Categories", comment: ""), 2)
121121
XCTAssertEqual(viewModel.productsAppliedTo, appliedTo)
122122
}
123123

0 commit comments

Comments
 (0)