fixed width issues
reset label color configs Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
2e2beee8c3
commit
44323a0a84
@ -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,10 +235,26 @@ 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
|
||||||
@ -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()
|
||||||
@ -412,6 +441,20 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
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()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user