refactored out of entryfieldbase to inputfield since this is the only place it is needed.
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
5c44d25339
commit
2046897199
@ -876,7 +876,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EAC9258B2911C9DE00091998 /* EntryFieldBase.swift */,
|
||||
EA6642942BCEBF9500D81DC4 /* TextLinkModel.swift */,
|
||||
EAC925862911C9DE00091998 /* InputField */,
|
||||
EA985C21296E032000F2FF2E /* TextArea */,
|
||||
);
|
||||
@ -887,6 +886,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EAC925872911C9DE00091998 /* InputField.swift */,
|
||||
EA6642942BCEBF9500D81DC4 /* TextLinkModel.swift */,
|
||||
);
|
||||
path = InputField;
|
||||
sourceTree = "<group>";
|
||||
|
||||
@ -145,11 +145,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
open var icon: Icon = Icon().with {
|
||||
$0.size = .medium
|
||||
}
|
||||
|
||||
internal var actionTextLink = TextLink().with { $0.contentEdgeInsets = .top(-2) }
|
||||
|
||||
internal var actionTextLinkModel: TextLinkModel? { didSet { setNeedsUpdate() } }
|
||||
|
||||
|
||||
open var labelText: String? { didSet { setNeedsUpdate() } }
|
||||
|
||||
open var helperText: String? { didSet { setNeedsUpdate() } }
|
||||
@ -253,7 +249,6 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
//add the view to add input fields
|
||||
containerStackView.addArrangedSubview(controlContainerView)
|
||||
containerStackView.addArrangedSubview(icon)
|
||||
containerStackView.addArrangedSubview(actionTextLink)
|
||||
containerStackView.setCustomSpacing(VDSLayout.space3X, after: controlContainerView)
|
||||
|
||||
//get the container this is what show helper text, error text
|
||||
@ -320,16 +315,6 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
updateErrorLabel()
|
||||
updateHelperLabel()
|
||||
|
||||
if let actionTextLinkModel {
|
||||
actionTextLink.text = actionTextLinkModel.text
|
||||
actionTextLink.onClick = actionTextLinkModel.onClick
|
||||
actionTextLink.isHidden = false
|
||||
containerStackView.setCustomSpacing(VDSLayout.space2X, after: icon)
|
||||
} else {
|
||||
actionTextLink.isHidden = true
|
||||
containerStackView.setCustomSpacing(0, after: icon)
|
||||
}
|
||||
|
||||
backgroundColor = surface.color
|
||||
validator?.validate()
|
||||
internalErrorText = validator?.errorMessage
|
||||
|
||||
@ -77,6 +77,10 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
/// Representing the type of input.
|
||||
open var fieldType: FieldType = .text { didSet { setNeedsUpdate() } }
|
||||
|
||||
internal var actionTextLink = TextLink().with { $0.contentEdgeInsets = .top(-2) }
|
||||
|
||||
public var actionTextLinkModel: TextLinkModel? { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// The text of this TextField.
|
||||
private var _text: String?
|
||||
open var text: String? {
|
||||
@ -134,6 +138,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
/// If given, this will be shown if showSuccess if true.
|
||||
open var successText: String? { didSet { setNeedsUpdate() } }
|
||||
|
||||
@ -169,6 +174,8 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
stackView.addArrangedSubview(successLabel)
|
||||
stackView.setCustomSpacing(8, after: successLabel)
|
||||
|
||||
containerStackView.addArrangedSubview(actionTextLink)
|
||||
|
||||
successLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
||||
|
||||
backgroundColorConfiguration.setSurfaceColors(VDSColor.feedbackSuccessBackgroundOnlight, VDSColor.feedbackSuccessBackgroundOndark, forState: .success)
|
||||
@ -204,6 +211,16 @@ open class InputField: EntryFieldBase, UITextFieldDelegate {
|
||||
textField.isEnabled = isEnabled
|
||||
textField.textColor = textFieldTextColorConfiguration.getColor(self)
|
||||
|
||||
if let actionTextLinkModel {
|
||||
actionTextLink.text = actionTextLinkModel.text
|
||||
actionTextLink.onClick = actionTextLinkModel.onClick
|
||||
actionTextLink.isHidden = false
|
||||
containerStackView.setCustomSpacing(VDSLayout.space2X, after: icon)
|
||||
} else {
|
||||
actionTextLink.isHidden = true
|
||||
containerStackView.setCustomSpacing(0, after: icon)
|
||||
}
|
||||
|
||||
//show error or success
|
||||
if showError, let _ = errorText {
|
||||
successLabel.isHidden = true
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension EntryFieldBase {
|
||||
extension InputField {
|
||||
public struct TextLinkModel {
|
||||
|
||||
///Text that goes in the Tab
|
||||
Loading…
Reference in New Issue
Block a user