Skip to content

Commit 944aad2

Browse files
committed
Bold the Total row label, always render Storage cost, trim DocC
- Splits the billingRow helper so only the label takes a weight override (labelWeight, mirroring the repo's .styleGuide(.body, weight: .bold) pattern). Using .bodyBold directly was ineffective because Text.styleGuide(_:) defaults weight to .regular and applies .fontWeight after the font, overriding the bold baked into the token. - Drops the Storage cost row's > 0 zero-suppression so it always renders within the billing section ($0.00 when zero), matching web's cart-summary always-render pattern alongside Estimated Tax and Total. - Strips task-anchored DocC sentences that just restated names or referenced callers, matching the repo's lean-comment style.
1 parent f6bcf47 commit 944aad2

4 files changed

Lines changed: 26 additions & 49 deletions

File tree

BitwardenShared/UI/Billing/PremiumPlan/PremiumPlanState.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ struct PremiumPlanState: Equatable {
6767
return Localizations.negativeX(formatCurrency(subscription.discount))
6868
}
6969

70-
/// The estimated tax label (e.g. "$4.55" or "$0.00"). Always renders when a
71-
/// subscription exists, mirroring web's cart-summary always-render behavior.
70+
/// The estimated tax label (e.g. "$4.55" or "$0.00").
7271
var estimatedTax: String {
7372
guard let subscription else { return "" }
7473
return formatCurrency(subscription.estimatedTax)
@@ -101,14 +100,9 @@ struct PremiumPlanState: Equatable {
101100
!discount.isEmpty
102101
}
103102

104-
/// Whether the storage cost row should be shown.
105-
var showStorageCost: Bool {
106-
(subscription?.storageCost ?? 0) > 0
107-
}
108-
109-
/// The storage cost label (e.g. "$4.00").
103+
/// The storage cost label (e.g. "$4.00" or "$0.00").
110104
var storageCostLabel: String {
111-
guard let subscription, subscription.storageCost > 0 else { return "" }
105+
guard let subscription else { return "" }
112106
return formatCurrency(subscription.storageCost)
113107
}
114108

@@ -122,8 +116,7 @@ struct PremiumPlanState: Equatable {
122116
return ""
123117
}
124118

125-
/// The total label (e.g. "$25.55 / year"). Mirrors web's cart-summary
126-
/// Total line, including the cadence suffix.
119+
/// The total label (e.g. "$25.55 / year").
127120
var totalLabel: String {
128121
guard let subscription else { return "" }
129122
return Localizations.xAmountPerCadence(

BitwardenShared/UI/Billing/PremiumPlan/PremiumPlanStateTests.swift

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -185,24 +185,6 @@ struct PremiumPlanStateTests {
185185
#expect(!state.showDiscount)
186186
}
187187

188-
// MARK: Tests - showStorageCost
189-
190-
/// `showStorageCost` is true when storage cost is greater than zero.
191-
@Test
192-
func showStorageCost_true() {
193-
var state = PremiumPlanState()
194-
state.subscription = .fixture(storageCost: 4)
195-
#expect(state.showStorageCost)
196-
}
197-
198-
/// `showStorageCost` is false when storage cost is zero.
199-
@Test
200-
func showStorageCost_false() {
201-
var state = PremiumPlanState()
202-
state.subscription = .fixture(storageCost: 0)
203-
#expect(!state.showStorageCost)
204-
}
205-
206188
// MARK: Tests - storageCostLabel
207189

208190
/// `storageCostLabel` returns the formatted storage cost.
@@ -213,11 +195,18 @@ struct PremiumPlanStateTests {
213195
#expect(state.storageCostLabel == "$8.00")
214196
}
215197

216-
/// `storageCostLabel` returns empty when storage cost is zero.
198+
/// `storageCostLabel` returns the formatted zero amount when storage cost is zero.
217199
@Test
218-
func storageCostLabel_noStorage() {
200+
func storageCostLabel_zero() {
219201
var state = PremiumPlanState()
220202
state.subscription = .fixture(storageCost: 0)
203+
#expect(state.storageCostLabel == "$0.00")
204+
}
205+
206+
/// `storageCostLabel` returns empty when subscription is nil.
207+
@Test
208+
func storageCostLabel_nil() {
209+
let state = PremiumPlanState()
221210
#expect(state.storageCostLabel.isEmpty)
222211
}
223212

BitwardenShared/UI/Billing/PremiumPlan/PremiumPlanView+ViewInspectorTests.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ class PremiumPlanViewTests: BitwardenTestCase {
8686
XCTAssertNotNil(button)
8787
}
8888

89-
/// The estimated tax row renders as $0.00 when tax is zero and the
90-
/// plan is active. Matches the canonical web cart-summary behavior.
89+
/// The estimated tax row renders as $0.00 when tax is zero and the plan is active.
9190
@MainActor
9291
func test_estimatedTax_visible_whenZero() throws {
9392
processor.state.planStatus = .active
@@ -116,8 +115,7 @@ class PremiumPlanViewTests: BitwardenTestCase {
116115
XCTAssertEqual(processor.effects.last, .managePlanTapped)
117116
}
118117

119-
/// The Total row is hidden when the plan is canceled (whole section
120-
/// suppressed by `showBillingDetails`).
118+
/// The Total row is hidden when the plan is canceled.
121119
@MainActor
122120
func test_totalRow_hidden_whenCanceled() throws {
123121
processor.state.planStatus = .canceled

BitwardenShared/UI/Billing/PremiumPlan/PremiumPlanView.swift

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,18 @@ struct PremiumPlanView: View {
4141

4242
// MARK: Private Views
4343

44-
/// The billing details section with rows for billing amount, storage cost, and discount.
44+
/// The billing details section with rows for billing amount, storage cost, and discount
4545
@ViewBuilder private var billingSection: some View {
4646
billingRow(
4747
label: Localizations.billingAmount,
4848
value: store.state.billingAmount,
4949
valueColor: Color(asset: SharedAsset.Colors.textPrimary),
5050
)
51-
if store.state.showStorageCost {
52-
billingRow(
53-
label: Localizations.storageCost,
54-
value: store.state.storageCostLabel,
55-
valueColor: Color(asset: SharedAsset.Colors.textPrimary),
56-
)
57-
}
51+
billingRow(
52+
label: Localizations.storageCost,
53+
value: store.state.storageCostLabel,
54+
valueColor: Color(asset: SharedAsset.Colors.textPrimary),
55+
)
5856
if store.state.showDiscount {
5957
billingRow(
6058
label: Localizations.discount,
@@ -71,7 +69,7 @@ struct PremiumPlanView: View {
7169
label: Localizations.total,
7270
value: store.state.totalLabel,
7371
valueColor: Color(asset: SharedAsset.Colors.textPrimary),
74-
font: .bodyBold,
72+
labelWeight: .bold,
7573
)
7674
}
7775

@@ -157,24 +155,23 @@ struct PremiumPlanView: View {
157155
/// - label: The label text displayed on the left.
158156
/// - value: The value text displayed on the right.
159157
/// - valueColor: The color to use for the value text.
160-
/// - font: The style guide font applied to both the label and the value. Defaults to `.body`;
161-
/// the Total row passes `.bodyBold` to match the design's emphasized total typography.
158+
/// - labelWeight: The font weight applied to the label.
162159
///
163160
private func billingRow(
164161
label: String,
165162
value: String,
166163
valueColor: Color,
167-
font: StyleGuideFont = .body,
164+
labelWeight: SwiftUI.Font.Weight = .regular,
168165
) -> some View {
169166
HStack {
170167
Text(label)
171-
.styleGuide(font)
168+
.styleGuide(.body, weight: labelWeight)
172169
.foregroundColor(Color(asset: SharedAsset.Colors.textSecondary))
173170

174171
Spacer()
175172

176173
Text(value)
177-
.styleGuide(font)
174+
.styleGuide(.body)
178175
.foregroundColor(valueColor)
179176
}
180177
.padding(.vertical, 20)

0 commit comments

Comments
 (0)