fixed bug with isSecureTextEntry
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
68d21296a7
commit
39107082e7
@ -63,7 +63,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
}
|
||||
|
||||
/// UITextField shown in the InputField.
|
||||
open var textField = UITextField().with {
|
||||
open var textField = TextField().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.font = TextStyle.bodyLarge.font
|
||||
}
|
||||
@ -88,6 +88,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
get { textField.text }
|
||||
set {
|
||||
textField.text = newValue
|
||||
setNeedsUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,9 +164,9 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
textField
|
||||
.textPublisher
|
||||
.sink { [weak self] newText in
|
||||
print("textPublisher newText: \(newText)")
|
||||
self?.text = newText
|
||||
self?.sendActions(for: .valueChanged)
|
||||
if newText.isEmpty { self?.passwordActionType = .show }
|
||||
}.store(in: &subscribers)
|
||||
|
||||
stackView.addArrangedSubview(successLabel)
|
||||
@ -251,13 +252,13 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
}
|
||||
|
||||
open func updateFieldType() {
|
||||
textField.isSecureTextEntry = false
|
||||
|
||||
var minWidth: CGFloat = 40.0
|
||||
var leftIconName: Icon.Name?
|
||||
var actionModel: InputField.TextLinkModel?
|
||||
var toolTipModel: Tooltip.TooltipModel?
|
||||
|
||||
var isSecureTextEntry = false
|
||||
|
||||
switch fieldType {
|
||||
case .text:
|
||||
break
|
||||
@ -271,7 +272,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
case .password:
|
||||
let isHide = passwordActionType == .hide
|
||||
let buttonText = isHide ? hidePasswordButtonText : showPasswordButtonText
|
||||
let isSecureTextEntry = !isHide
|
||||
isSecureTextEntry = !isHide
|
||||
let nextPasswordActionType = passwordActionType.toggle()
|
||||
if let text, !text.isEmpty {
|
||||
actionModel = .init(text: buttonText,
|
||||
@ -279,7 +280,8 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
guard let self else { return }
|
||||
self.passwordActionType = nextPasswordActionType
|
||||
})
|
||||
textField.isSecureTextEntry = isSecureTextEntry
|
||||
} else {
|
||||
passwordActionType = .show
|
||||
}
|
||||
minWidth = 62.0
|
||||
|
||||
@ -297,6 +299,9 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
|
||||
}
|
||||
|
||||
//textField
|
||||
textField.isSecureTextEntry = isSecureTextEntry
|
||||
|
||||
//leftIcon
|
||||
leftIcon.surface = surface
|
||||
leftIcon.color = iconColorConfiguration.getColor(self)
|
||||
@ -327,7 +332,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
}
|
||||
|
||||
//tooltip
|
||||
self.tooltipModel = toolTipModel
|
||||
tooltipModel = toolTipModel
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -347,3 +352,22 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
open var showPasswordButtonText: String = "Show" { didSet { setNeedsUpdate() } }
|
||||
}
|
||||
|
||||
public class TextField: UITextField {
|
||||
|
||||
open override var isSecureTextEntry: Bool {
|
||||
didSet {
|
||||
if isFirstResponder {
|
||||
_ = becomeFirstResponder()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override func becomeFirstResponder() -> Bool {
|
||||
let success = super.becomeFirstResponder()
|
||||
if isSecureTextEntry, let text {
|
||||
self.text?.removeAll()
|
||||
insertText(text)
|
||||
}
|
||||
return success
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user