From 896d393d7a4dd7ba53e33760610a123036414573 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 30 Apr 2024 13:24:37 -0500 Subject: [PATCH] updated for focused Signed-off-by: Matt Bruce --- .../TextFields/InputField/InputField.swift | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index 62b361c6..f18a6224 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -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 {