fixed width issues

reset label color configs

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-05-22 16:28:44 -05:00
parent 2e2beee8c3
commit 44323a0a84

View File

@ -101,6 +101,13 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
/// This is set by a local method. /// This is set by a local method.
internal var bottomContainerView: UIView! internal var bottomContainerView: UIView!
//--------------------------------------------------
// MARK: - Constraints
//--------------------------------------------------
internal var widthConstraint: NSLayoutConstraint?
internal var trailingEqualsConstraint: NSLayoutConstraint?
internal var trailingLessThanEqualsConstraint: NSLayoutConstraint?
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Configuration Properties // MARK: - Configuration Properties
//-------------------------------------------------- //--------------------------------------------------
@ -228,11 +235,27 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
open override func setup() { open override func setup() {
super.setup() super.setup()
let layoutGuide = UILayoutGuide()
addLayoutGuide(layoutGuide)
layoutGuide
.pinTop()
.pinLeading()
.pinBottom()
trailingEqualsConstraint = layoutGuide.pinTrailing(anchor: trailingAnchor)
// width constraints
trailingLessThanEqualsConstraint = layoutGuide.pinTrailingLessThanOrEqualTo(anchor: trailingAnchor)?.deactivate()
widthConstraint = layoutGuide.widthAnchor.constraint(equalToConstant: 0).deactivate()
// Add mainStackView to the view // Add mainStackView to the view
addSubview(mainStackView) addSubview(mainStackView)
mainStackView.pinToSuperView() mainStackView.pinTop(anchor: layoutGuide.topAnchor)
mainStackView.pinLeading(anchor: layoutGuide.leadingAnchor)
mainStackView.pinBottom(anchor: layoutGuide.bottomAnchor)
mainStackView.pinTrailing(anchor: layoutGuide.trailingAnchor)
//add ContainerStackView //add ContainerStackView
//this is the horizontal stack that contains //this is the horizontal stack that contains
//InputContainer, Icons, Buttons //InputContainer, Icons, Buttons
@ -265,12 +288,18 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
// Initial position of the helper label // Initial position of the helper label
updateHelperTextPosition() updateHelperTextPosition()
// colorconfigs
titleLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
errorLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
helperLabel.textColorConfiguration = secondaryColorConfiguration.eraseToAnyColorable()
} }
/// Updates the UI /// Updates the UI
open override func updateView() { open override func updateView() {
super.updateView() super.updateView()
updateContainerView() updateContainerView()
updateContainerWidth()
updateTitleLabel() updateTitleLabel()
updateErrorLabel() updateErrorLabel()
updateHelperLabel() updateHelperLabel()
@ -411,7 +440,21 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
containerView.layer.borderWidth = VDSFormControls.borderWidth containerView.layer.borderWidth = VDSFormControls.borderWidth
containerView.layer.cornerRadius = VDSFormControls.borderRadius containerView.layer.cornerRadius = VDSFormControls.borderRadius
} }
internal func updateContainerWidth() {
widthConstraint?.deactivate()
trailingLessThanEqualsConstraint?.deactivate()
trailingEqualsConstraint?.deactivate()
if let width, width >= minWidth, width <= maxWidth {
widthConstraint?.constant = width
widthConstraint?.activate()
trailingLessThanEqualsConstraint?.activate()
} else {
trailingEqualsConstraint?.activate()
}
}
internal func updateHelperTextPosition() { internal func updateHelperTextPosition() {
titleLabel.removeFromSuperview() titleLabel.removeFromSuperview()