Skip to content

Commit bfff991

Browse files
committed
Add modifiers to configure Bindinable textfield
1 parent 1c52f77 commit bfff991

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

WooCommerce/Classes/ViewRelated/Orders/Simple Payments/Amount/SimplePaymentsAmount.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ struct SimplePaymentsAmount: View {
100100

101101
// Amount Textfield
102102
BindableTextfield(viewModel.amountPlaceholder, text: $viewModel.amount)
103-
.font(.system(size: Layout.amountFontSize(scale: scale), weight: .bold, design: .default))
104-
.foregroundColor(Color(.text))
105-
.multilineTextAlignment(.center)
103+
.font(.systemFont(ofSize: Layout.amountFontSize(scale: scale), weight: .bold))
104+
.foregroundColor(.text)
105+
.textAlignment(.center)
106106
.keyboardType(.decimalPad)
107+
.fixedSize()
107108

108109
Spacer()
109110

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,37 @@ extension BindableTextfield {
8989
}
9090
}
9191
}
92+
93+
94+
// MARK: Modifiers
95+
96+
extension BindableTextfield {
97+
/// Updates the textfield font.
98+
///
99+
func font(_ font: UIFont) -> Self {
100+
var copy = self
101+
copy.font = font
102+
return copy
103+
}
104+
105+
/// Updates the textfield foreground color.
106+
func foregroundColor(_ color: UIColor) -> Self {
107+
var copy = self
108+
copy.foregroundColor = color
109+
return copy
110+
}
111+
112+
/// Updates the textfield text alignment.
113+
func textAlignment(_ alignment: NSTextAlignment) -> Self {
114+
var copy = self
115+
copy.textAlignment = alignment
116+
return copy
117+
}
118+
119+
/// Updates the textfield keyboard type.
120+
func keyboardType(_ type: UIKeyboardType) -> Self {
121+
var copy = self
122+
copy.keyboardType = type
123+
return copy
124+
}
125+
}

0 commit comments

Comments
 (0)