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