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.
|
/// UITextField shown in the InputField.
|
||||||
open var textField = UITextField().with {
|
open var textField = TextField().with {
|
||||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
$0.font = TextStyle.bodyLarge.font
|
$0.font = TextStyle.bodyLarge.font
|
||||||
}
|
}
|
||||||
@ -88,6 +88,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
|||||||
get { textField.text }
|
get { textField.text }
|
||||||
set {
|
set {
|
||||||
textField.text = newValue
|
textField.text = newValue
|
||||||
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,9 +164,9 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
|||||||
textField
|
textField
|
||||||
.textPublisher
|
.textPublisher
|
||||||
.sink { [weak self] newText in
|
.sink { [weak self] newText in
|
||||||
|
print("textPublisher newText: \(newText)")
|
||||||
self?.text = newText
|
self?.text = newText
|
||||||
self?.sendActions(for: .valueChanged)
|
self?.sendActions(for: .valueChanged)
|
||||||
if newText.isEmpty { self?.passwordActionType = .show }
|
|
||||||
}.store(in: &subscribers)
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
stackView.addArrangedSubview(successLabel)
|
stackView.addArrangedSubview(successLabel)
|
||||||
@ -251,12 +252,12 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func updateFieldType() {
|
open func updateFieldType() {
|
||||||
textField.isSecureTextEntry = false
|
|
||||||
|
|
||||||
var minWidth: CGFloat = 40.0
|
var minWidth: CGFloat = 40.0
|
||||||
var leftIconName: Icon.Name?
|
var leftIconName: Icon.Name?
|
||||||
var actionModel: InputField.TextLinkModel?
|
var actionModel: InputField.TextLinkModel?
|
||||||
var toolTipModel: Tooltip.TooltipModel?
|
var toolTipModel: Tooltip.TooltipModel?
|
||||||
|
var isSecureTextEntry = false
|
||||||
|
|
||||||
switch fieldType {
|
switch fieldType {
|
||||||
case .text:
|
case .text:
|
||||||
@ -271,7 +272,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
|||||||
case .password:
|
case .password:
|
||||||
let isHide = passwordActionType == .hide
|
let isHide = passwordActionType == .hide
|
||||||
let buttonText = isHide ? hidePasswordButtonText : showPasswordButtonText
|
let buttonText = isHide ? hidePasswordButtonText : showPasswordButtonText
|
||||||
let isSecureTextEntry = !isHide
|
isSecureTextEntry = !isHide
|
||||||
let nextPasswordActionType = passwordActionType.toggle()
|
let nextPasswordActionType = passwordActionType.toggle()
|
||||||
if let text, !text.isEmpty {
|
if let text, !text.isEmpty {
|
||||||
actionModel = .init(text: buttonText,
|
actionModel = .init(text: buttonText,
|
||||||
@ -279,7 +280,8 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
|||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
self.passwordActionType = nextPasswordActionType
|
self.passwordActionType = nextPasswordActionType
|
||||||
})
|
})
|
||||||
textField.isSecureTextEntry = isSecureTextEntry
|
} else {
|
||||||
|
passwordActionType = .show
|
||||||
}
|
}
|
||||||
minWidth = 62.0
|
minWidth = 62.0
|
||||||
|
|
||||||
@ -297,6 +299,9 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//textField
|
||||||
|
textField.isSecureTextEntry = isSecureTextEntry
|
||||||
|
|
||||||
//leftIcon
|
//leftIcon
|
||||||
leftIcon.surface = surface
|
leftIcon.surface = surface
|
||||||
leftIcon.color = iconColorConfiguration.getColor(self)
|
leftIcon.color = iconColorConfiguration.getColor(self)
|
||||||
@ -327,7 +332,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//tooltip
|
//tooltip
|
||||||
self.tooltipModel = toolTipModel
|
tooltipModel = toolTipModel
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -347,3 +352,22 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
|||||||
open var showPasswordButtonText: String = "Show" { didSet { setNeedsUpdate() } }
|
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