Removed unused (unusable) focus() and clearFocus()

This commit is contained in:
dankito 2020-08-03 20:21:49 +02:00
parent 9074689523
commit 38da439888
1 changed files with 0 additions and 16 deletions

View File

@ -20,9 +20,6 @@ struct UIKitTextField: UIViewRepresentable {
private var textChanged: ((String) -> Void)? = nil private var textChanged: ((String) -> Void)? = nil
@State private var textField: UITextField? = nil
init(_ titleKey: String, text: Binding<String>, keyboardType: UIKeyboardType = .default, isPasswordField: Bool = false, init(_ titleKey: String, text: Binding<String>, keyboardType: UIKeyboardType = .default, isPasswordField: Bool = false,
focusOnStart: Bool = false, focusNextTextFieldOnReturnKeyPress: Bool = false, actionOnReturnKeyPress: (() -> Bool)? = nil, textChanged: ((String) -> Void)? = nil) { focusOnStart: Bool = false, focusNextTextFieldOnReturnKeyPress: Bool = false, actionOnReturnKeyPress: (() -> Bool)? = nil, textChanged: ((String) -> Void)? = nil) {
self.placeHolder = titleKey self.placeHolder = titleKey
@ -53,10 +50,6 @@ struct UIKitTextField: UIViewRepresentable {
Self.NextTagId = Self.NextTagId + 1 // unbelievable, there's no ++ operator Self.NextTagId = Self.NextTagId + 1 // unbelievable, there's no ++ operator
textField.tag = Self.NextTagId textField.tag = Self.NextTagId
DispatchQueue.main.async { // to not update state on view updates (and i only need @State as structs cannot be modified)
self.textField = textField
}
if focusOnStart { if focusOnStart {
textField.becomeFirstResponder() textField.becomeFirstResponder()
} }
@ -74,15 +67,6 @@ struct UIKitTextField: UIViewRepresentable {
} }
func focus() -> Bool {
return textField?.becomeFirstResponder() ?? false
}
func clearFocus() -> Bool {
return textField?.resignFirstResponder() ?? false
}
class Coordinator: NSObject, UITextFieldDelegate { class Coordinator: NSObject, UITextFieldDelegate {
@Binding private var text: String @Binding private var text: String