refactored width to fields
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
aeb620a8a1
commit
3859c8eeb7
@ -78,15 +78,28 @@ extension InputField {
|
|||||||
inputField.fieldStackView.setCustomSpacing(0, after: inputField.statusIcon)
|
inputField.fieldStackView.setCustomSpacing(0, after: inputField.statusIcon)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// //set the width constraints
|
||||||
|
// if let width = inputField.width, width > minWidth {
|
||||||
|
// inputField.widthConstraint?.constant = width
|
||||||
|
// inputField.widthConstraint?.isActive = true
|
||||||
|
// inputField.minWidthConstraint?.isActive = false
|
||||||
|
// } else {
|
||||||
|
// inputField.minWidthConstraint?.constant = minWidth
|
||||||
|
// inputField.widthConstraint?.isActive = false
|
||||||
|
// inputField.minWidthConstraint?.isActive = true
|
||||||
|
// }
|
||||||
//set the width constraints
|
//set the width constraints
|
||||||
if let width = inputField.width, width > minWidth {
|
if let width = inputField.width, width > minWidth {
|
||||||
inputField.widthConstraint?.constant = width
|
inputField.widthConstraint?.constant = width
|
||||||
inputField.widthConstraint?.isActive = true
|
inputField.widthConstraint?.isActive = true
|
||||||
inputField.minWidthConstraint?.isActive = false
|
inputField.minWidthConstraint?.isActive = false
|
||||||
|
inputField.maxWidthConstraint?.isActive = false
|
||||||
} else {
|
} else {
|
||||||
inputField.minWidthConstraint?.constant = minWidth
|
inputField.minWidthConstraint?.constant = minWidth
|
||||||
|
inputField.maxWidthConstraint?.constant = inputField.frame.width
|
||||||
inputField.widthConstraint?.isActive = false
|
inputField.widthConstraint?.isActive = false
|
||||||
inputField.minWidthConstraint?.isActive = true
|
inputField.minWidthConstraint?.isActive = true
|
||||||
|
inputField.maxWidthConstraint?.isActive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
//placeholder
|
//placeholder
|
||||||
|
|||||||
@ -34,6 +34,7 @@ open class InputField: EntryFieldBase {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Properties
|
// MARK: - Private Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
internal var maxWidthConstraint: NSLayoutConstraint?
|
||||||
internal var minWidthConstraint: NSLayoutConstraint?
|
internal var minWidthConstraint: NSLayoutConstraint?
|
||||||
internal var titleLabelWidthConstraint: NSLayoutConstraint?
|
internal var titleLabelWidthConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
@ -171,9 +172,8 @@ open class InputField: EntryFieldBase {
|
|||||||
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)
|
||||||
|
maxWidthConstraint = containerView.width(constant: containerSize.width)
|
||||||
minWidthConstraint = containerView.widthAnchor.constraint(greaterThanOrEqualToConstant: 0)
|
minWidthConstraint = containerView.widthGreaterThanEqualTo(constant: 0)
|
||||||
minWidthConstraint?.isActive = true
|
|
||||||
|
|
||||||
textField.heightAnchor.constraint(equalToConstant: 20).isActive = true
|
textField.heightAnchor.constraint(equalToConstant: 20).isActive = true
|
||||||
textField.delegate = self
|
textField.delegate = self
|
||||||
|
|||||||
@ -52,20 +52,7 @@ open class TextArea: EntryFieldBase {
|
|||||||
$0.numberOfLines = 1
|
$0.numberOfLines = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
private var _minHeight: Height = .twoX
|
open var minHeight: Height = .twoX { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
open var minHeight: Height? {
|
|
||||||
get { return _minHeight }
|
|
||||||
set {
|
|
||||||
if let newValue {
|
|
||||||
_minHeight = newValue
|
|
||||||
} else {
|
|
||||||
_minHeight = .twoX
|
|
||||||
}
|
|
||||||
textViewHeightConstraint?.constant = _minHeight.value
|
|
||||||
setNeedsUpdate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
@ -211,6 +198,7 @@ open class TextArea: EntryFieldBase {
|
|||||||
//set the width constraints
|
//set the width constraints
|
||||||
minWidthConstraint?.constant = containerSize.width
|
minWidthConstraint?.constant = containerSize.width
|
||||||
maxWidthConstraint?.constant = frame.width
|
maxWidthConstraint?.constant = frame.width
|
||||||
|
textViewHeightConstraint?.constant = minHeight.value
|
||||||
|
|
||||||
characterCounterLabel.text = getCharacterCounterText()
|
characterCounterLabel.text = getCharacterCounterText()
|
||||||
|
|
||||||
@ -309,7 +297,7 @@ open class TextArea: EntryFieldBase {
|
|||||||
//since it will autogrow with the current settings
|
//since it will autogrow with the current settings
|
||||||
if let textViewHeightConstraint, textView.isEditable {
|
if let textViewHeightConstraint, textView.isEditable {
|
||||||
var height = textView.contentSize.height
|
var height = textView.contentSize.height
|
||||||
height = max(height, _minHeight.value)
|
height = max(height, minHeight.value)
|
||||||
if height > Height.twoX.value && height <= Height.fourX.value {
|
if height > Height.twoX.value && height <= Height.fourX.value {
|
||||||
textViewHeightConstraint.constant = Height.fourX.value
|
textViewHeightConstraint.constant = Height.fourX.value
|
||||||
} else if height > Height.fourX.value {
|
} else if height > Height.fourX.value {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user