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