fixed password link bug

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-05-10 17:23:04 -05:00
parent 6ad9156e13
commit d7fc65612f
3 changed files with 28 additions and 15 deletions

View File

@ -100,11 +100,11 @@ extension InputField {
func appendRules(_ inputField: InputField) {} func appendRules(_ inputField: InputField) {}
func textFieldDidBeginEditing(_ inputField: InputField, textField: UITextField) { func textFieldDidBeginEditing(_ inputField: InputField, textField: UITextField) { }
}
func textFieldDidEndEditing(_ inputField: InputField, textField: UITextField) { func textFieldDidEndEditing(_ inputField: InputField, textField: UITextField) {}
}
func textFieldDidChangeSelection(_ inputField: InputField, textField: UITextField) {}
func textField(_ inputField: InputField, textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { func textField(_ inputField: InputField, textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
return true return true

View File

@ -48,6 +48,20 @@ extension InputField {
minWidth = 62.0 minWidth = 62.0
super.updateView(inputField) super.updateView(inputField)
updateLink(inputField)
}
func updateLink(_ inputField: InputField) {
if let text = inputField.textField.text, !text.isEmpty {
inputField.actionTextLink.isHidden = false
} else {
inputField.actionTextLink.isHidden = true
}
}
override func textFieldDidChangeSelection(_ inputField: InputField, textField: UITextField) {
updateLink(inputField)
} }
} }

View File

@ -173,17 +173,6 @@ open class InputField: EntryFieldBase {
textField.heightAnchor.constraint(equalToConstant: 20).isActive = true textField.heightAnchor.constraint(equalToConstant: 20).isActive = true
textField.delegate = self textField.delegate = self
textField
.textPublisher
.sink { [weak self] newText in
guard let self else { return }
print("textPublisher newText: \(newText)")
if self.fieldType.handler().validateOnChange {
self.validate()
}
self.sendActions(for: .valueChanged)
}.store(in: &subscribers)
stackView.addArrangedSubview(successLabel) stackView.addArrangedSubview(successLabel)
stackView.setCustomSpacing(8, after: successLabel) stackView.setCustomSpacing(8, after: successLabel)
@ -338,6 +327,16 @@ extension InputField: UITextFieldDelegate {
validate() validate()
} }
public func textFieldDidChangeSelection(_ textField: UITextField) {
fieldType.handler().textFieldDidChangeSelection(self, textField: textField)
if fieldType.handler().validateOnChange {
validate()
} else {
setNeedsUpdate()
}
sendActions(for: .valueChanged)
}
public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
return fieldType.handler().textField(self, textField: textField, shouldChangeCharactersIn: range, replacementString: string) return fieldType.handler().textField(self, textField: textField, shouldChangeCharactersIn: range, replacementString: string)
} }