Fixed that tap on label didn't lead to a change in focusTextField's value

This commit is contained in:
dankito 2020-11-05 00:51:58 +01:00
parent 079979aca4
commit c037308751
2 changed files with 6 additions and 8 deletions

View File

@ -18,7 +18,7 @@ struct LabelledUIKitTextField: View {
var focusOnStart = false
var focusNextTextFieldOnReturnKeyPress = false
var focusTextField: Binding<Bool> = .constant(false)
@State var focusTextField: Bool = false
var isFocusedChanged: ((Bool) -> Void)? = nil
@ -37,9 +37,7 @@ struct LabelledUIKitTextField: View {
HStack(alignment: .center) {
Text(label)
.onTapGesture {
DispatchQueue.main.async {
self.focusTextField.wrappedValue = true
}
self.focusTextField = true
}
Spacer()
@ -60,7 +58,7 @@ struct LabelledUIKitTextField: View {
UIKitTextField(placeholder, text: $text,
keyboardType: keyboardType, autocapitalizationType: autocapitalizationType, addDoneButton: addDoneButton,
isPasswordField: isPasswordField,
focusOnStart: focusOnStart, focusNextTextFieldOnReturnKeyPress: focusNextTextFieldOnReturnKeyPress, focusTextField: focusTextField,
focusOnStart: focusOnStart, focusNextTextFieldOnReturnKeyPress: focusNextTextFieldOnReturnKeyPress, focusTextField: $focusTextField,
isFocusedChanged: isFocusedChanged, textAlignment: .right, isUserInputEnabled: isUserInputEnabled,
actionOnReturnKeyPress: actionOnReturnKeyPress, textChanged: textChanged)
@ -78,7 +76,7 @@ struct LabelledUIKitTextField: View {
)
.onTapGesture {
DispatchQueue.main.async {
self.focusTextField.wrappedValue = true
self.focusTextField = true
}
}
}

View File

@ -44,7 +44,7 @@ struct AddAccountDialog: View {
Section(header: Text("Online banking login data")) {
LabelledUIKitTextField(label: "Online banking login name", text: $userName, placeholder: "Enter Online banking login name", autocapitalizationType: .none,
focusNextTextFieldOnReturnKeyPress: true, focusTextField: $focusLoginNameTextField, actionOnReturnKeyPress: handleReturnKeyPress)
focusNextTextFieldOnReturnKeyPress: true, focusTextField: focusLoginNameTextField, actionOnReturnKeyPress: handleReturnKeyPress)
BankCredentialsPasswordView($password, $savePassword, handleReturnKeyPress)
}