updated maxWidth

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-09-20 14:13:27 -05:00
parent 26a3206639
commit ebbbffc86e
2 changed files with 6 additions and 7 deletions

View File

@ -61,8 +61,9 @@ open class DropdownSelect: EntryFieldBase<String> {
internal var minWidthInlineLabel = 102.0 internal var minWidthInlineLabel = 102.0
internal override var minWidth: CGFloat { showInlineLabel ? minWidthInlineLabel : minWidthDefault } internal override var minWidth: CGFloat { showInlineLabel ? minWidthInlineLabel : minWidthDefault }
internal override var maxWidth: CGFloat { internal override var maxWidth: CGFloat {
let frameWidth = frame.size.width let frameWidth = constrainedWidth
return helperTextPlacement == .right ? (frameWidth - horizontalStackView.spacing) / 2 : frameWidth let halfWidth = (frameWidth - horizontalStackView.spacing) / 2
return helperTextPlacement == .right && halfWidth > minWidth * 2 ? halfWidth : frameWidth
} }
/// The is used for the for adding the helperLabel to the right of the containerView. /// The is used for the for adding the helperLabel to the right of the containerView.

View File

@ -47,8 +47,9 @@ open class InputField: EntryFieldBase<String> {
internal override var minWidth: CGFloat { fieldType.handler().minWidth } internal override var minWidth: CGFloat { fieldType.handler().minWidth }
internal override var maxWidth: CGFloat { internal override var maxWidth: CGFloat {
let frameWidth = frame.size.width let frameWidth = constrainedWidth
return helperTextPlacement == .right ? (frameWidth - horizontalStackView.spacing) / 2 : frameWidth let halfWidth = (frameWidth - horizontalStackView.spacing) / 2
return helperTextPlacement == .right && halfWidth > minWidth * 2 ? halfWidth : frameWidth
} }
/// The is used for the for adding the helperLabel to the right of the containerView. /// The is used for the for adding the helperLabel to the right of the containerView.
@ -320,15 +321,12 @@ open class InputField: EntryFieldBase<String> {
internal override func updateContainerWidth() { internal override func updateContainerWidth() {
widthConstraint?.deactivate() widthConstraint?.deactivate()
trailingLessThanEqualsConstraint?.deactivate()
trailingEqualsConstraint?.deactivate()
//see if there is a widthPercentage and follow the same pattern as done for "width" //see if there is a widthPercentage and follow the same pattern as done for "width"
let currentWidth = (horizontalPinnedWidth() ?? 0) * (widthPercentage ?? 0) let currentWidth = (horizontalPinnedWidth() ?? 0) * (widthPercentage ?? 0)
if currentWidth >= minWidth, currentWidth <= maxWidth { if currentWidth >= minWidth, currentWidth <= maxWidth {
widthConstraint?.constant = currentWidth widthConstraint?.constant = currentWidth
widthConstraint?.activate() widthConstraint?.activate()
trailingLessThanEqualsConstraint?.activate()
} else { } else {
super.updateContainerWidth() super.updateContainerWidth()
} }