refactored dropdown/inputfield for the helper text position
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
c5262246f3
commit
d870d4f385
@ -83,6 +83,9 @@ open class DropdownSelect: EntryFieldBase {
|
||||
$0.font = TextStyle.bodyLarge.font
|
||||
}
|
||||
|
||||
/// Determines the placement of the helper text.
|
||||
open var helperTextPlacement: HelperTextPlacement = .bottom { didSet { setNeedsUpdate() } }
|
||||
|
||||
open var optionsPicker = UIPickerView()
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -246,6 +249,26 @@ open class DropdownSelect: EntryFieldBase {
|
||||
statusIcon.color = iconColorConfiguration.getColor(self)
|
||||
}
|
||||
|
||||
open override func updateHelperLabel(){
|
||||
//remove first
|
||||
helperLabel.removeFromSuperview()
|
||||
|
||||
super.updateHelperLabel()
|
||||
|
||||
//set the helper label position
|
||||
if helperText != nil {
|
||||
if helperTextPlacement == .right {
|
||||
middleStackView.spacing = 12
|
||||
middleStackView.distribution = .fillEqually
|
||||
middleStackView.addArrangedSubview(helperLabel)
|
||||
} else {
|
||||
middleStackView.spacing = 0
|
||||
middleStackView.distribution = .fill
|
||||
bottomContainerStackView.addArrangedSubview(helperLabel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open override func updateAccessibility() {
|
||||
super.updateAccessibility()
|
||||
let selectedOption = selectedOptionLabel.text ?? ""
|
||||
|
||||
@ -60,7 +60,16 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
$0.distribution = .fill
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
internal var middleStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .horizontal
|
||||
$0.distribution = .fill
|
||||
$0.alignment = .top
|
||||
}
|
||||
}()
|
||||
|
||||
internal var containerView: UIView = {
|
||||
return UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
@ -219,6 +228,9 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
widthConstraint = containerView.widthAnchor.constraint(equalToConstant: 0)
|
||||
widthConstraint?.priority = .defaultHigh
|
||||
|
||||
//add the containerView to the middleStack
|
||||
middleStackView.addArrangedSubview(containerView)
|
||||
|
||||
//add ContainerStackView
|
||||
//this is the horizontal stack that contains
|
||||
//the left, InputContainer, Icons, Buttons
|
||||
@ -242,11 +254,11 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
bottomContainerStackView.addArrangedSubview(helperLabel)
|
||||
|
||||
stackView.addArrangedSubview(titleLabel)
|
||||
stackView.addArrangedSubview(containerView)
|
||||
stackView.addArrangedSubview(middleStackView)
|
||||
stackView.addArrangedSubview(bottomContainer)
|
||||
|
||||
stackView.setCustomSpacing(4, after: titleLabel)
|
||||
stackView.setCustomSpacing(8, after: containerView)
|
||||
stackView.setCustomSpacing(8, after: middleStackView)
|
||||
stackView.setCustomSpacing(8, after: bottomContainer)
|
||||
|
||||
stackView
|
||||
|
||||
@ -34,15 +34,6 @@ open class InputField: EntryFieldBase {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Properties
|
||||
//--------------------------------------------------
|
||||
internal var inputFieldStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .horizontal
|
||||
$0.distribution = .fill
|
||||
$0.spacing = 12
|
||||
}
|
||||
}()
|
||||
|
||||
internal var minWidthConstraint: NSLayoutConstraint?
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -274,13 +265,13 @@ open class InputField: EntryFieldBase {
|
||||
//set the helper label position
|
||||
if helperText != nil {
|
||||
if helperTextPlacement == .right {
|
||||
inputFieldStackView.spacing = 12
|
||||
inputFieldStackView.distribution = .fillEqually
|
||||
inputFieldStackView.addArrangedSubview(helperLabel)
|
||||
middleStackView.spacing = 12
|
||||
middleStackView.distribution = .fillEqually
|
||||
middleStackView.addArrangedSubview(helperLabel)
|
||||
} else {
|
||||
inputFieldStackView.spacing = 0
|
||||
inputFieldStackView.distribution = .fill
|
||||
stackView.addArrangedSubview(helperLabel)
|
||||
middleStackView.spacing = 0
|
||||
middleStackView.distribution = .fill
|
||||
bottomContainerStackView.addArrangedSubview(helperLabel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user