Merge branch 'mbruce/bugfix' of https://gitlab.verizon.com/BPHV_MIPS/vds_ios.git into mbruce/bugfix
This commit is contained in:
commit
1647e44e2f
@ -28,7 +28,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
public required init?(coder: NSCoder) {
|
public required init?(coder: NSCoder) {
|
||||||
super.init(coder: coder)
|
super.init(coder: coder)
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Enums
|
// MARK: - Enums
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -92,12 +92,6 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
/// This is the view that will be wrapped with the border for userInteraction.
|
|
||||||
/// The only subview of this view is the fieldStackView
|
|
||||||
internal var containerView = View().with {
|
|
||||||
$0.isAccessibilityElement = true
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This is set by a local method.
|
/// This is set by a local method.
|
||||||
internal var bottomContainerView: UIView!
|
internal var bottomContainerView: UIView!
|
||||||
|
|
||||||
@ -115,7 +109,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
internal var widthConstraint: NSLayoutConstraint?
|
internal var widthConstraint: NSLayoutConstraint?
|
||||||
internal var trailingEqualsConstraint: NSLayoutConstraint?
|
internal var trailingEqualsConstraint: NSLayoutConstraint?
|
||||||
internal var trailingLessThanEqualsConstraint: NSLayoutConstraint?
|
internal var trailingLessThanEqualsConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration Properties
|
// MARK: - Configuration Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -133,14 +127,14 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true)
|
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true)
|
||||||
$0.setSurfaceColors(VDSColor.elementsSecondaryOnlight, VDSColor.elementsSecondaryOndark, forDisabled: false)
|
$0.setSurfaceColors(VDSColor.elementsSecondaryOnlight, VDSColor.elementsSecondaryOndark, forDisabled: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var backgroundColorConfiguration = ControlColorConfiguration().with {
|
internal var backgroundColorConfiguration = ControlColorConfiguration().with {
|
||||||
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .normal)
|
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .normal)
|
||||||
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .disabled)
|
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .disabled)
|
||||||
$0.setSurfaceColors(VDSColor.feedbackErrorBackgroundOnlight, VDSColor.feedbackErrorBackgroundOndark, forState: .error)
|
$0.setSurfaceColors(VDSColor.feedbackErrorBackgroundOnlight, VDSColor.feedbackErrorBackgroundOndark, forState: .error)
|
||||||
$0.setSurfaceColors(VDSColor.feedbackErrorBackgroundOnlight, VDSColor.feedbackErrorBackgroundOndark, forState: [.error, .focused])
|
$0.setSurfaceColors(VDSColor.feedbackErrorBackgroundOnlight, VDSColor.feedbackErrorBackgroundOndark, forState: [.error, .focused])
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var borderColorConfiguration = ControlColorConfiguration().with {
|
internal var borderColorConfiguration = ControlColorConfiguration().with {
|
||||||
$0.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOndark, forState: .normal)
|
$0.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOndark, forState: .normal)
|
||||||
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOnlight, forState: .focused)
|
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOnlight, forState: .focused)
|
||||||
@ -155,7 +149,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled)
|
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled)
|
||||||
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .error)
|
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .error)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var readOnlyBorderColorConfiguration = ControlColorConfiguration().with {
|
internal var readOnlyBorderColorConfiguration = ControlColorConfiguration().with {
|
||||||
$0.setSurfaceColors(VDSFormControlsColor.borderReadonlyOnlight, VDSFormControlsColor.borderReadonlyOndark, forState: .normal)
|
$0.setSurfaceColors(VDSFormControlsColor.borderReadonlyOnlight, VDSFormControlsColor.borderReadonlyOndark, forState: .normal)
|
||||||
}
|
}
|
||||||
@ -163,8 +157,14 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open var onChangeSubscriber: AnyCancellable?
|
/// This is the view that will be wrapped with the border for userInteraction.
|
||||||
|
/// The only subview of this view is the fieldStackView
|
||||||
|
open var containerView = View().with {
|
||||||
|
$0.isAccessibilityElement = true
|
||||||
|
}
|
||||||
|
|
||||||
|
open var onChangeSubscriber: AnyCancellable?
|
||||||
|
|
||||||
open var titleLabel = Label().with {
|
open var titleLabel = Label().with {
|
||||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
$0.textStyle = .bodySmall
|
$0.textStyle = .bodySmall
|
||||||
@ -185,7 +185,9 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
$0.size = .medium
|
$0.size = .medium
|
||||||
$0.isAccessibilityElement = true
|
$0.isAccessibilityElement = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open var useRequiredRule: Bool = true { 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() } }
|
||||||
@ -195,7 +197,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
|
|
||||||
/// FormFieldValidator
|
/// FormFieldValidator
|
||||||
open var validator: (any FormFieldValidatorable)?
|
open var validator: (any FormFieldValidatorable)?
|
||||||
|
|
||||||
/// Override UIControl state to add the .error state if showError is true.
|
/// Override UIControl state to add the .error state if showError is true.
|
||||||
open override var state: UIControl.State {
|
open override var state: UIControl.State {
|
||||||
get {
|
get {
|
||||||
@ -214,17 +216,17 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open var errorText: String? { didSet { setNeedsUpdate() } }
|
open var errorText: String? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var tooltipModel: Tooltip.TooltipModel? { didSet { setNeedsUpdate() } }
|
open var tooltipModel: Tooltip.TooltipModel? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var transparentBackground: Bool = false { didSet { setNeedsUpdate() } }
|
open var transparentBackground: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var width: CGFloat? { didSet { setNeedsUpdate() } }
|
open var width: CGFloat? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var inputId: String? { didSet { setNeedsUpdate() } }
|
open var inputId: String? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// The text of this textField.
|
/// The text of this textField.
|
||||||
open var value: String? {
|
open var value: String? {
|
||||||
get { fatalError("must be read from subclass")}
|
get { fatalError("must be read from subclass")}
|
||||||
@ -235,21 +237,21 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
open var isRequired: Bool = false { didSet { setNeedsUpdate() } }
|
open var isRequired: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var isReadOnly: Bool = false { didSet { setNeedsUpdate() } }
|
open var isReadOnly: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var helperTextPlacement: HelperTextPlacement = .bottom {
|
open var helperTextPlacement: HelperTextPlacement = .bottom {
|
||||||
didSet {
|
didSet {
|
||||||
updateHelperTextPosition()
|
updateHelperTextPosition()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open var rules = [AnyRule<String>]()
|
open var rules = [AnyRule<String>]()
|
||||||
|
|
||||||
open var accessibilityHintText: String = "Double tap to open"
|
open var accessibilityHintText: String = "Double tap to open"
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Overrides
|
// MARK: - Overrides
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
|
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
|
||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
@ -371,7 +373,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
titleLabel.textStyle = .bodySmall
|
titleLabel.textStyle = .bodySmall
|
||||||
errorLabel.textStyle = .bodySmall
|
errorLabel.textStyle = .bodySmall
|
||||||
helperLabel.textStyle = .bodySmall
|
helperLabel.textStyle = .bodySmall
|
||||||
|
|
||||||
labelText = nil
|
labelText = nil
|
||||||
helperText = nil
|
helperText = nil
|
||||||
showError = false
|
showError = false
|
||||||
@ -389,19 +391,19 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
open override var canBecomeFirstResponder: Bool {
|
open override var canBecomeFirstResponder: Bool {
|
||||||
responder?.canBecomeFirstResponder ?? super.canBecomeFirstResponder
|
responder?.canBecomeFirstResponder ?? super.canBecomeFirstResponder
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func becomeFirstResponder() -> Bool {
|
open override func becomeFirstResponder() -> Bool {
|
||||||
responder?.becomeFirstResponder() ?? super.becomeFirstResponder()
|
responder?.becomeFirstResponder() ?? super.becomeFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
open override var canResignFirstResponder: Bool {
|
open override var canResignFirstResponder: Bool {
|
||||||
responder?.canResignFirstResponder ?? super.canResignFirstResponder
|
responder?.canResignFirstResponder ?? super.canResignFirstResponder
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func resignFirstResponder() -> Bool {
|
open override func resignFirstResponder() -> Bool {
|
||||||
responder?.resignFirstResponder() ?? super.resignFirstResponder()
|
responder?.resignFirstResponder() ?? super.resignFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Methods
|
// MARK: - Public Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -409,21 +411,21 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
open func getFieldContainer() -> UIView {
|
open func getFieldContainer() -> UIView {
|
||||||
fatalError("Subclass must return the view that contains the field/view the user will interact with.")
|
fatalError("Subclass must return the view that contains the field/view the user will interact with.")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Container for the area in which helper or error text presents.
|
/// Container for the area in which helper or error text presents.
|
||||||
open func getBottomContainer() -> UIView {
|
open func getBottomContainer() -> UIView {
|
||||||
return bottomContainerStackView
|
return bottomContainerStackView
|
||||||
}
|
}
|
||||||
|
|
||||||
open func validate(){
|
open func validate(){
|
||||||
updateRules()
|
updateRules()
|
||||||
validator = FormFieldValidator<EntryFieldBase>(field: self, rules: rules)
|
validator = FormFieldValidator<EntryFieldBase>(field: self, rules: rules)
|
||||||
validator?.validate()
|
validator?.validate()
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
open func updateTitleLabel() {
|
open func updateTitleLabel() {
|
||||||
|
|
||||||
//update the local vars for the label since we no
|
//update the local vars for the label since we no
|
||||||
//long have a model
|
//long have a model
|
||||||
var attributes: [any LabelAttributeModel] = []
|
var attributes: [any LabelAttributeModel] = []
|
||||||
@ -444,36 +446,43 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
if let tooltipModel {
|
if let tooltipModel {
|
||||||
attributes.append(TooltipLabelAttribute(surface: surface, model: tooltipModel, presenter: self))
|
attributes.append(TooltipLabelAttribute(surface: surface, model: tooltipModel, presenter: self))
|
||||||
}
|
}
|
||||||
|
|
||||||
//set the titleLabel
|
//set the titleLabel
|
||||||
titleLabel.text = updatedLabelText
|
titleLabel.text = updatedLabelText
|
||||||
titleLabel.attributes = attributes
|
titleLabel.attributes = attributes
|
||||||
titleLabel.surface = surface
|
titleLabel.surface = surface
|
||||||
titleLabel.isEnabled = isEnabled
|
titleLabel.isEnabled = isEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
open func updateErrorLabel(){
|
open func updateErrorLabel(){
|
||||||
if showError, let errorText {
|
|
||||||
errorLabel.text = errorText
|
/// always show the errorIcon if there is an error
|
||||||
errorLabel.surface = surface
|
if showError || hasInternalError {
|
||||||
errorLabel.isEnabled = isEnabled
|
|
||||||
errorLabel.isHidden = false
|
|
||||||
statusIcon.name = .error
|
|
||||||
statusIcon.surface = surface
|
|
||||||
statusIcon.isHidden = !isEnabled || state.contains(.focused)
|
|
||||||
} else if hasInternalError, let internalErrorText {
|
|
||||||
errorLabel.text = internalErrorText
|
|
||||||
errorLabel.surface = surface
|
|
||||||
errorLabel.isEnabled = isEnabled
|
|
||||||
errorLabel.isHidden = false
|
|
||||||
statusIcon.name = .error
|
statusIcon.name = .error
|
||||||
statusIcon.surface = surface
|
statusIcon.surface = surface
|
||||||
statusIcon.isHidden = !isEnabled || state.contains(.focused)
|
statusIcon.isHidden = !isEnabled || state.contains(.focused)
|
||||||
} else {
|
} else {
|
||||||
statusIcon.isHidden = true
|
statusIcon.isHidden = true
|
||||||
errorLabel.isHidden = true
|
|
||||||
}
|
}
|
||||||
statusIcon.color = iconColorConfiguration.getColor(self)
|
statusIcon.color = iconColorConfiguration.getColor(self)
|
||||||
|
|
||||||
|
// only show errorLabel if there is a message
|
||||||
|
var message: String?
|
||||||
|
if showError, let errorText {
|
||||||
|
message = errorText
|
||||||
|
} else if hasInternalError, let internalErrorText {
|
||||||
|
message = internalErrorText
|
||||||
|
}
|
||||||
|
|
||||||
|
if let message {
|
||||||
|
errorLabel.text = message
|
||||||
|
errorLabel.surface = surface
|
||||||
|
errorLabel.isEnabled = isEnabled
|
||||||
|
errorLabel.isHidden = false
|
||||||
|
} else {
|
||||||
|
errorLabel.isHidden = true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open func updateHelperLabel(){
|
open func updateHelperLabel(){
|
||||||
@ -515,7 +524,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
internal func updateRules() {
|
internal func updateRules() {
|
||||||
rules.removeAll()
|
rules.removeAll()
|
||||||
if self.isRequired {
|
if isRequired && useRequiredRule {
|
||||||
let rule = RequiredRule()
|
let rule = RequiredRule()
|
||||||
if let errorText, !errorText.isEmpty {
|
if let errorText, !errorText.isEmpty {
|
||||||
rule.errorMessage = errorText
|
rule.errorMessage = errorText
|
||||||
|
|||||||
@ -107,6 +107,9 @@ open class InputField: EntryFieldBase {
|
|||||||
$0.isAccessibilityElement = false
|
$0.isAccessibilityElement = false
|
||||||
$0.autocorrectionType = .no
|
$0.autocorrectionType = .no
|
||||||
$0.spellCheckingType = .no
|
$0.spellCheckingType = .no
|
||||||
|
$0.smartQuotesType = .no
|
||||||
|
$0.smartDashesType = .no
|
||||||
|
$0.smartInsertDeleteType = .no
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color configuration for the textField.
|
/// Color configuration for the textField.
|
||||||
|
|||||||
@ -47,6 +47,11 @@ open class TextField: UITextField, ViewProtocol, Errorable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
/// Set to true to hide the blinking textField cursor.
|
||||||
|
open var hideBlinkingCaret = false
|
||||||
|
open var enableClipboardActions: Bool = true
|
||||||
|
open var onDidDeleteBackwards: (() -> Void)?
|
||||||
|
|
||||||
/// Key of whether or not updateView() is called in setNeedsUpdate()
|
/// Key of whether or not updateView() is called in setNeedsUpdate()
|
||||||
open var shouldUpdateView: Bool = true
|
open var shouldUpdateView: Bool = true
|
||||||
|
|
||||||
@ -209,6 +214,23 @@ open class TextField: UITextField, ViewProtocol, Errorable {
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func caretRect(for position: UITextPosition) -> CGRect {
|
||||||
|
|
||||||
|
if hideBlinkingCaret {
|
||||||
|
return .zero
|
||||||
|
}
|
||||||
|
|
||||||
|
let caretRect = super.caretRect(for: position)
|
||||||
|
return CGRect(origin: caretRect.origin, size: CGSize(width: 1, height: caretRect.height))
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func deleteBackward() {
|
||||||
|
super.deleteBackward()
|
||||||
|
onDidDeleteBackwards?()
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { enableClipboardActions }
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Methods
|
// MARK: - Private Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -111,7 +111,9 @@ open class TextArea: EntryFieldBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
didSet {
|
didSet {
|
||||||
validate()
|
if textView.isFirstResponder {
|
||||||
|
validate()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,11 +45,7 @@ open class TextView: UITextView, ViewProtocol, Errorable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open var placeholder: String? {
|
open var placeholder: String? { didSet { setNeedsUpdate() } }
|
||||||
didSet {
|
|
||||||
placeholderLabel.text = placeholder
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open var placeholderLabel = Label().with {
|
open var placeholderLabel = Label().with {
|
||||||
$0.textColorConfiguration = ViewColorConfiguration().with {
|
$0.textColorConfiguration = ViewColorConfiguration().with {
|
||||||
@ -319,8 +315,9 @@ open class TextView: UITextView, ViewProtocol, Errorable {
|
|||||||
attributedText = nil
|
attributedText = nil
|
||||||
}
|
}
|
||||||
placeholderLabel.textStyle = textStyle
|
placeholderLabel.textStyle = textStyle
|
||||||
placeholderLabel.isHidden = !text.isEmpty
|
|
||||||
placeholderLabel.surface = surface
|
placeholderLabel.surface = surface
|
||||||
|
placeholderLabel.text = placeholder
|
||||||
|
placeholderLabel.isHidden = !text.isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user