removed min/max, you only need width + calculations
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
3859c8eeb7
commit
18090871ee
@ -106,8 +106,6 @@ open class DropdownSelect: EntryFieldBase {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Constraints
|
// MARK: - Constraints
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
internal var maxWidthConstraint: NSLayoutConstraint?
|
|
||||||
internal var minWidthConstraint: NSLayoutConstraint?
|
|
||||||
internal var inlineWidthConstraint: NSLayoutConstraint?
|
internal var inlineWidthConstraint: NSLayoutConstraint?
|
||||||
internal var titleLabelWidthConstraint: NSLayoutConstraint?
|
internal var titleLabelWidthConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
@ -123,9 +121,7 @@ open class DropdownSelect: EntryFieldBase {
|
|||||||
/// 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()
|
||||||
minWidthConstraint = containerView.widthGreaterThanEqualTo(constant: containerSize.width)
|
|
||||||
maxWidthConstraint = containerView.width(constant: containerSize.width)
|
|
||||||
|
|
||||||
titleLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
titleLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||||
titleLabel.setContentHuggingPriority(.required, for: .horizontal)
|
titleLabel.setContentHuggingPriority(.required, for: .horizontal)
|
||||||
titleLabelWidthConstraint = titleLabel.width(constant: 0)
|
titleLabelWidthConstraint = titleLabel.width(constant: 0)
|
||||||
@ -196,17 +192,11 @@ open class DropdownSelect: EntryFieldBase {
|
|||||||
selectedOptionLabel.isEnabled = isEnabled
|
selectedOptionLabel.isEnabled = isEnabled
|
||||||
|
|
||||||
//set the width constraints
|
//set the width constraints
|
||||||
if let width, width > minWidth {
|
let maxwidth = frame.size.width
|
||||||
|
if let width, width > minWidth && width < maxwidth {
|
||||||
widthConstraint?.constant = width
|
widthConstraint?.constant = width
|
||||||
widthConstraint?.isActive = true
|
|
||||||
minWidthConstraint?.isActive = false
|
|
||||||
maxWidthConstraint?.isActive = false
|
|
||||||
} else {
|
} else {
|
||||||
minWidthConstraint?.constant = minWidth
|
widthConstraint?.constant = maxwidth >= minWidth ? maxwidth : minWidth
|
||||||
maxWidthConstraint?.constant = frame.width
|
|
||||||
widthConstraint?.isActive = false
|
|
||||||
minWidthConstraint?.isActive = true
|
|
||||||
maxWidthConstraint?.isActive = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -210,10 +210,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
addSubview(stackView)
|
addSubview(stackView)
|
||||||
|
|
||||||
//create the wrapping view
|
//create the wrapping view
|
||||||
heightConstraint = containerView.heightAnchor.constraint(greaterThanOrEqualToConstant: containerSize.height)
|
heightConstraint = containerView.heightGreaterThanEqualTo(constant: containerSize.height)
|
||||||
heightConstraint?.priority = .defaultHigh
|
|
||||||
heightConstraint?.isActive = true
|
|
||||||
|
|
||||||
widthConstraint = containerView.width(constant: 0)
|
widthConstraint = containerView.width(constant: 0)
|
||||||
|
|
||||||
let leftStackView = UIStackView().with {
|
let leftStackView = UIStackView().with {
|
||||||
|
|||||||
@ -32,8 +32,6 @@ open class TextArea: EntryFieldBase {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Properties
|
// MARK: - Private Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
internal var maxWidthConstraint: NSLayoutConstraint?
|
|
||||||
internal var minWidthConstraint: NSLayoutConstraint?
|
|
||||||
internal var textViewHeightConstraint: NSLayoutConstraint?
|
internal var textViewHeightConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
internal var inputFieldStackView: UIStackView = {
|
internal var inputFieldStackView: UIStackView = {
|
||||||
@ -140,8 +138,6 @@ open class TextArea: EntryFieldBase {
|
|||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
fieldStackView.pinToSuperView(.uniform(VDSFormControls.spaceInset))
|
fieldStackView.pinToSuperView(.uniform(VDSFormControls.spaceInset))
|
||||||
minWidthConstraint = containerView.widthGreaterThanEqualTo(constant: containerSize.width)
|
|
||||||
maxWidthConstraint = containerView.width(constant: containerSize.width)
|
|
||||||
|
|
||||||
textView.isScrollEnabled = true
|
textView.isScrollEnabled = true
|
||||||
textView.autocorrectionType = .no
|
textView.autocorrectionType = .no
|
||||||
@ -173,10 +169,6 @@ open class TextArea: EntryFieldBase {
|
|||||||
characterCounterLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
characterCounterLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
||||||
bottomContainerStackView.spacing = VDSLayout.space2X
|
bottomContainerStackView.spacing = VDSLayout.space2X
|
||||||
|
|
||||||
widthConstraint?.isActive = false
|
|
||||||
minWidthConstraint?.isActive = true
|
|
||||||
maxWidthConstraint?.isActive = true
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets to default settings.
|
/// Resets to default settings.
|
||||||
@ -196,8 +188,9 @@ open class TextArea: EntryFieldBase {
|
|||||||
textView.surface = surface
|
textView.surface = surface
|
||||||
|
|
||||||
//set the width constraints
|
//set the width constraints
|
||||||
minWidthConstraint?.constant = containerSize.width
|
let maxwidth = frame.size.width
|
||||||
maxWidthConstraint?.constant = frame.width
|
let minWidth = containerSize.width
|
||||||
|
widthConstraint?.constant = maxwidth >= minWidth ? maxwidth : minWidth
|
||||||
textViewHeightConstraint?.constant = minHeight.value
|
textViewHeightConstraint?.constant = minHeight.value
|
||||||
|
|
||||||
characterCounterLabel.text = getCharacterCounterText()
|
characterCounterLabel.text = getCharacterCounterText()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user