Implemented that login name text field gets focused when a bank has been selected
This commit is contained in:
parent
c2a9f9f44a
commit
f6f28890a7
|
@ -18,14 +18,7 @@ struct LabelledUIKitTextField: View {
|
|||
var focusOnStart = false
|
||||
var focusNextTextFieldOnReturnKeyPress = false
|
||||
|
||||
@State var focusTextField: Bool = false
|
||||
|
||||
private var focusTextFieldBinding: Binding<Bool> {
|
||||
Binding<Bool>(
|
||||
get: { self.focusTextField },
|
||||
set: { self.focusTextField = $0 }
|
||||
)
|
||||
}
|
||||
var focusTextField: Binding<Bool> = .constant(false)
|
||||
|
||||
var isFocusedChanged: ((Bool) -> Void)? = nil
|
||||
|
||||
|
@ -45,7 +38,7 @@ struct LabelledUIKitTextField: View {
|
|||
Text(label)
|
||||
.onTapGesture {
|
||||
DispatchQueue.main.async {
|
||||
self.focusTextField = true
|
||||
self.focusTextField.wrappedValue = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +60,7 @@ struct LabelledUIKitTextField: View {
|
|||
UIKitTextField(placeholder, text: $text,
|
||||
keyboardType: keyboardType, autocapitalizationType: autocapitalizationType, addDoneButton: addDoneButton,
|
||||
isPasswordField: isPasswordField,
|
||||
focusOnStart: focusOnStart, focusNextTextFieldOnReturnKeyPress: focusNextTextFieldOnReturnKeyPress, focusTextField: focusTextFieldBinding,
|
||||
focusOnStart: focusOnStart, focusNextTextFieldOnReturnKeyPress: focusNextTextFieldOnReturnKeyPress, focusTextField: focusTextField,
|
||||
isFocusedChanged: isFocusedChanged, textAlignment: .right, isUserInputEnabled: isUserInputEnabled,
|
||||
actionOnReturnKeyPress: actionOnReturnKeyPress, textChanged: textChanged)
|
||||
|
||||
|
@ -85,7 +78,7 @@ struct LabelledUIKitTextField: View {
|
|||
)
|
||||
.onTapGesture {
|
||||
DispatchQueue.main.async {
|
||||
self.focusTextField = true
|
||||
self.focusTextField.wrappedValue = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ struct AddAccountDialog: View {
|
|||
|
||||
@State private var userName = ""
|
||||
@State private var password = ""
|
||||
|
||||
@State private var focusLoginNameTextField: Bool = false
|
||||
|
||||
|
||||
@State private var isTryingToAddAccount = false
|
||||
|
@ -38,8 +40,8 @@ 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, actionOnReturnKeyPress: handleReturnKeyPress)
|
||||
LabelledUIKitTextField(label: "Online banking login name", text: $userName, placeholder: "Enter Online banking login name", autocapitalizationType: .none,
|
||||
focusNextTextFieldOnReturnKeyPress: true, focusTextField: $focusLoginNameTextField, actionOnReturnKeyPress: handleReturnKeyPress)
|
||||
|
||||
LabelledUIKitTextField(label: "Online banking login password", text: $password, placeholder: "Enter Online banking login password",
|
||||
autocapitalizationType: .none, isPasswordField: true, actionOnReturnKeyPress: handleReturnKeyPress)
|
||||
|
@ -58,6 +60,13 @@ struct AddAccountDialog: View {
|
|||
}
|
||||
|
||||
}
|
||||
.onAppear {
|
||||
if bank != nil {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { // wait till animation for hiding SelectBankDialog is fully done
|
||||
self.focusLoginNameTextField = true
|
||||
}
|
||||
}
|
||||
}
|
||||
.alert(message: $errorMessage)
|
||||
.fixKeyboardCoversLowerPart()
|
||||
.showNavigationBarTitle("Add account")
|
||||
|
|
Loading…
Reference in New Issue