Implemented setting keyboard auto capitalization type

This commit is contained in:
dankito 2020-09-01 16:03:26 +02:00
parent 9dc6c0c5c0
commit 5f8e5463e5
7 changed files with 15 additions and 11 deletions

View File

@ -10,6 +10,7 @@ struct LabelledUIKitTextField: View {
var placeholder: String = "" var placeholder: String = ""
var keyboardType: UIKeyboardType = .default var keyboardType: UIKeyboardType = .default
var autocapitalizationType: UITextAutocapitalizationType = .sentences
var isPasswordField: Bool = false var isPasswordField: Bool = false
var focusOnStart = false var focusOnStart = false
@ -45,7 +46,7 @@ struct LabelledUIKitTextField: View {
Spacer() Spacer()
UIKitTextField(placeholder, text: $text, keyboardType: keyboardType, isPasswordField: isPasswordField, UIKitTextField(placeholder, text: $text, keyboardType: keyboardType, autocapitalizationType: autocapitalizationType, isPasswordField: isPasswordField,
focusOnStart: focusOnStart, focusNextTextFieldOnReturnKeyPress: focusNextTextFieldOnReturnKeyPress, focusTextField: focusTextFieldBinding, focusOnStart: focusOnStart, focusNextTextFieldOnReturnKeyPress: focusNextTextFieldOnReturnKeyPress, focusTextField: focusTextFieldBinding,
isFocussedChanged: isFocussedChanged, textAlignment: .right, isUserInputEnabled: isUserInputEnabled, isFocussedChanged: isFocussedChanged, textAlignment: .right, isUserInputEnabled: isUserInputEnabled,
actionOnReturnKeyPress: actionOnReturnKeyPress, textChanged: textChanged) actionOnReturnKeyPress: actionOnReturnKeyPress, textChanged: textChanged)

View File

@ -11,6 +11,7 @@ struct UIKitTextField: UIViewRepresentable {
private var placeholder: String private var placeholder: String
private var keyboardType: UIKeyboardType = .default private var keyboardType: UIKeyboardType = .default
private var autocapitalizationType: UITextAutocapitalizationType = .sentences
private var isPasswordField: Bool = false private var isPasswordField: Bool = false
private var focusOnStart = false private var focusOnStart = false
@ -27,8 +28,8 @@ struct UIKitTextField: UIViewRepresentable {
private var textChanged: ((String) -> Void)? = nil private var textChanged: ((String) -> Void)? = nil
init(_ titleKey: String, text: Binding<String>, keyboardType: UIKeyboardType = .default, isPasswordField: Bool = false, init(_ titleKey: String, text: Binding<String>, keyboardType: UIKeyboardType = .default, autocapitalizationType: UITextAutocapitalizationType = .sentences,
focusOnStart: Bool = false, focusNextTextFieldOnReturnKeyPress: Bool = false, focusTextField: Binding<Bool> = .constant(false), isPasswordField: Bool = false, focusOnStart: Bool = false, focusNextTextFieldOnReturnKeyPress: Bool = false, focusTextField: Binding<Bool> = .constant(false),
isFocussedChanged: ((Bool) -> Void)? = nil, isFocussedChanged: ((Bool) -> Void)? = nil,
textAlignment: NSTextAlignment = .natural, isUserInputEnabled: Bool = true, textAlignment: NSTextAlignment = .natural, isUserInputEnabled: Bool = true,
actionOnReturnKeyPress: (() -> Bool)? = nil, textChanged: ((String) -> Void)? = nil) { actionOnReturnKeyPress: (() -> Bool)? = nil, textChanged: ((String) -> Void)? = nil) {
@ -36,6 +37,7 @@ struct UIKitTextField: UIViewRepresentable {
_text = text _text = text
self.keyboardType = keyboardType self.keyboardType = keyboardType
self.autocapitalizationType = autocapitalizationType
self.isPasswordField = isPasswordField self.isPasswordField = isPasswordField
self.focusOnStart = focusOnStart self.focusOnStart = focusOnStart
@ -57,6 +59,7 @@ struct UIKitTextField: UIViewRepresentable {
textField.placeholder = placeholder.localize() textField.placeholder = placeholder.localize()
textField.keyboardType = keyboardType textField.keyboardType = keyboardType
textField.autocapitalizationType = autocapitalizationType
textField.isSecureTextEntry = isPasswordField textField.isSecureTextEntry = isPasswordField
textField.delegate = context.coordinator textField.delegate = context.coordinator

View File

@ -38,10 +38,10 @@ struct AddAccountDialog: View {
Section { Section {
LabelledUIKitTextField(label: "Online banking login name", text: $customerId, placeholder: "Enter Online banking login name", LabelledUIKitTextField(label: "Online banking login name", text: $customerId, placeholder: "Enter Online banking login name",
focusNextTextFieldOnReturnKeyPress: true, actionOnReturnKeyPress: handleReturnKeyPress) autocapitalizationType: .none, focusNextTextFieldOnReturnKeyPress: true, actionOnReturnKeyPress: handleReturnKeyPress)
LabelledUIKitTextField(label: "Online banking login password", text: $password, placeholder: "Enter Online banking login password", LabelledUIKitTextField(label: "Online banking login password", text: $password, placeholder: "Enter Online banking login password",
isPasswordField: true, actionOnReturnKeyPress: handleReturnKeyPress) autocapitalizationType: .none, isPasswordField: true, actionOnReturnKeyPress: handleReturnKeyPress)
} }
Section { Section {

View File

@ -31,7 +31,7 @@ struct BankAccountSettingsDialog: View {
var body: some View { var body: some View {
Form { Form {
Section { Section {
LabelledUIKitTextField(label: "Name", text: $displayName) LabelledUIKitTextField(label: "Name", text: $displayName, autocapitalizationType: .none)
} }
Section { Section {

View File

@ -53,9 +53,9 @@ struct BankSettingsDialog: View {
} }
Section(header: Text("Credentials")) { Section(header: Text("Credentials")) {
LabelledUIKitTextField(label: "Online banking login name", text: $customerId) LabelledUIKitTextField(label: "Online banking login name", text: $customerId, autocapitalizationType: .none)
LabelledUIKitTextField(label: "Online banking login password", text: $password, isPasswordField: true) LabelledUIKitTextField(label: "Online banking login password", text: $password, autocapitalizationType: .none, isPasswordField: true)
} }
Section { Section {

View File

@ -105,7 +105,7 @@ struct EnterTanDialog: View {
.padding(.vertical, 2) .padding(.vertical, 2)
Section { Section {
LabelledUIKitTextField(label: "Enter TAN:", text: $enteredTan, keyboardType: tanChallenge.tanProcedure.isNumericTan ? .numberPad : .default, actionOnReturnKeyPress: { LabelledUIKitTextField(label: "Enter TAN:", text: $enteredTan, keyboardType: tanChallenge.tanProcedure.isNumericTan ? .numberPad : .default, autocapitalizationType: .none, actionOnReturnKeyPress: {
if self.isRequiredDataEntered() { if self.isRequiredDataEntered() {
self.enteringTanDone() self.enteringTanDone()
return true return true

View File

@ -123,7 +123,7 @@ struct TransferMoneyDialog: View {
} }
} }
LabelledUIKitTextField(label: "Remittee IBAN", text: $remitteeIban, focusNextTextFieldOnReturnKeyPress: true, isFocussedChanged: validateRemitteeIbanOnFocusLost, LabelledUIKitTextField(label: "Remittee IBAN", text: $remitteeIban, autocapitalizationType: .allCharacters, focusNextTextFieldOnReturnKeyPress: true, isFocussedChanged: validateRemitteeIbanOnFocusLost,
actionOnReturnKeyPress: handleReturnKeyPress, textChanged: validateRemitteeIban) actionOnReturnKeyPress: handleReturnKeyPress, textChanged: validateRemitteeIban)
remitteeIbanValidationResult.map { validationError in remitteeIbanValidationResult.map { validationError in