Skip to content

Commit 4aed3d8

Browse files
committed
Update TitleAndTextFieldRow to have configurable fonts and colors
1 parent d626b52 commit 4aed3d8

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

WooCommerce/Classes/ViewRelated/Coupons/Add and Edit Coupons/AddEditCoupon.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ struct AddEditCoupon: View {
106106
editable: true,
107107
fieldAlignment: .leading,
108108
keyboardType: .decimalPad,
109-
contentColor: viewModel.amountFieldColor,
109+
titleColor: viewModel.amountFieldColor,
110+
valueColor: viewModel.amountFieldColor,
110111
inputFormatter: CouponAmountInputFormatter()) { beginningEditing in
111112
if !beginningEditing {
112113
viewModel.validatePercentageAmountInput(withWarning: true)

WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/TitleAndTextFieldRow.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ struct TitleAndTextFieldRow: View {
1212
private let editable: Bool
1313
private let fieldAlignment: TextAlignment
1414
private let inputFormatter: UnitInputFormatter?
15-
private let contentColor: Color
15+
private let titleColor: Color
16+
private let titleFont: Font
17+
private let valueColor: Color
18+
private let valueFont: Font
1619
private let minHeight: CGFloat
1720
private let horizontalPadding: CGFloat
1821

@@ -33,7 +36,10 @@ struct TitleAndTextFieldRow: View {
3336
fieldAlignment: TextAlignment = .trailing,
3437
keyboardType: UIKeyboardType = .default,
3538
autocapitalization: TextInputAutocapitalization = .sentences,
36-
contentColor: Color = Color(.label),
39+
titleColor: Color = Color(.label),
40+
titleFont: Font = .body,
41+
valueColor: Color = Color(.label),
42+
valueFont: Font = .body,
3743
inputFormatter: UnitInputFormatter? = nil,
3844
minHeight: CGFloat = Constants.height,
3945
horizontalPadding: CGFloat = Constants.padding,
@@ -47,7 +53,10 @@ struct TitleAndTextFieldRow: View {
4753
self.fieldAlignment = fieldAlignment
4854
self.keyboardType = keyboardType
4955
self.autocapitalization = autocapitalization
50-
self.contentColor = contentColor
56+
self.titleColor = titleColor
57+
self.titleFont = titleFont
58+
self.valueColor = valueColor
59+
self.valueFont = valueFont
5160
self.inputFormatter = inputFormatter
5261
self.minHeight = minHeight
5362
self.horizontalPadding = horizontalPadding
@@ -57,29 +66,31 @@ struct TitleAndTextFieldRow: View {
5766
var body: some View {
5867
AdaptiveStack(horizontalAlignment: .leading, spacing: Constants.spacing) {
5968
Text(title)
60-
.foregroundColor(contentColor)
61-
.bodyStyle()
69+
.foregroundColor(titleColor)
6270
.lineLimit(1)
71+
.font(titleFont)
6372
.fixedSize()
6473
.modifier(MaxWidthModifier())
6574
.frame(width: titleWidth, alignment: .leading)
6675
HStack {
6776
TextField(placeholder, text: $text, onEditingChanged: onEditingChanged ?? { _ in })
68-
.foregroundColor(contentColor)
77+
.foregroundColor(valueColor)
6978
.onChange(of: text) { _, newValue in
7079
text = formatText(newValue)
7180
}
7281
.onAppear {
7382
text = formatText(text)
7483
}
7584
.multilineTextAlignment(fieldAlignment)
76-
.font(.body)
85+
.font(valueFont)
7786
.keyboardType(keyboardType)
7887
.disabled(!editable)
7988
.textInputAutocapitalization(autocapitalization)
8089
if let symbol = symbol {
8190
Text(symbol)
8291
.bodyStyle()
92+
.font(valueFont)
93+
.foregroundColor(valueColor)
8394
}
8495
}
8596
}

0 commit comments

Comments
 (0)