Removed unused (unusable) focus() and clearFocus()
This commit is contained in:
parent
9074689523
commit
38da439888
|
@ -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()
|
||||||
}
|
}
|
||||||
|
@ -72,15 +65,6 @@ struct UIKitTextField: UIViewRepresentable {
|
||||||
func makeCoordinator() -> UIKitTextField.Coordinator {
|
func makeCoordinator() -> UIKitTextField.Coordinator {
|
||||||
return Coordinator(text: $text, focusNextTextFieldOnReturnKeyPress: focusNextTextFieldOnReturnKeyPress, actionOnReturnKeyPress: actionOnReturnKeyPress, textChanged: textChanged)
|
return Coordinator(text: $text, focusNextTextFieldOnReturnKeyPress: focusNextTextFieldOnReturnKeyPress, actionOnReturnKeyPress: actionOnReturnKeyPress, textChanged: textChanged)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func focus() -> Bool {
|
|
||||||
return textField?.becomeFirstResponder() ?? false
|
|
||||||
}
|
|
||||||
|
|
||||||
func clearFocus() -> Bool {
|
|
||||||
return textField?.resignFirstResponder() ?? false
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Coordinator: NSObject, UITextFieldDelegate {
|
class Coordinator: NSObject, UITextFieldDelegate {
|
||||||
|
|
Loading…
Reference in New Issue