updated for focused

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-04-30 13:24:37 -05:00
parent 2241f6d131
commit 896d393d7a

View File

@ -14,7 +14,7 @@ import Combine
/// Specialized input fields capture credit card numbers, inline actions, passwords, phone numbers,
/// dates and security codes in their correct formats.
@objc(VDSInputField)
open class InputField: EntryFieldBase, UITextFieldDelegate {
open class InputField: EntryFieldBase {
//--------------------------------------------------
// MARK: - Initializers
@ -127,7 +127,11 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
var state = super.state
if showSuccess {
state.insert(.success)
} else if textField.isFirstResponder && !showError && !hasInternalError {
state.insert(.focused)
}
return state
}
}
@ -160,7 +164,8 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
controlStackView.addArrangedSubview(leftIcon)
controlStackView.addArrangedSubview(textField)
textField.delegate = self
textField.heightAnchor.constraint(equalToConstant: 20).isActive = true
textField
.textPublisher
@ -373,6 +378,16 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
open var showPasswordButtonText: String = "Show" { didSet { setNeedsUpdate() } }
}
extension InputField: UITextFieldDelegate {
public func textFieldDidBeginEditing(_ textField: UITextField) {
setNeedsUpdate()
}
public func textFieldDidEndEditing(_ textField: UITextField) {
setNeedsUpdate()
}
}
public class TextField: UITextField {
open override var isSecureTextEntry: Bool {