refactred getContainer() to getFieldContainer() to make more sense that the developer needs to only return the Item the User see to interact with.
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
501dc4a55f
commit
c5262246f3
@ -103,26 +103,10 @@ open class DropdownSelect: EntryFieldBase {
|
||||
open override func setup() {
|
||||
super.setup()
|
||||
|
||||
// stackview for controls in EntryFieldBase.controlContainerView
|
||||
let controlStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .horizontal
|
||||
$0.spacing = VDSFormControls.spaceInset
|
||||
}
|
||||
fieldContainerView.addSubview(controlStackView)
|
||||
controlStackView.pinToSuperView()
|
||||
|
||||
controlStackView.addArrangedSubview(dropdownField)
|
||||
controlStackView.addArrangedSubview(inlineDisplayLabel)
|
||||
controlStackView.addArrangedSubview(selectedOptionLabel)
|
||||
|
||||
containerStackView.isAccessibilityElement = true
|
||||
containerStackView.accessibilityLabel = "Dropdown Select"
|
||||
fieldStackView.isAccessibilityElement = true
|
||||
fieldStackView.accessibilityLabel = "Dropdown Select"
|
||||
inlineDisplayLabel.isAccessibilityElement = true
|
||||
|
||||
controlStackView.setCustomSpacing(0, after: dropdownField)
|
||||
controlStackView.setCustomSpacing(VDSLayout.space1X, after: inlineDisplayLabel)
|
||||
controlStackView.setCustomSpacing(VDSLayout.space3X, after: selectedOptionLabel)
|
||||
dropdownField.width(0)
|
||||
inlineWidthConstraint = inlineDisplayLabel.widthAnchor.constraint(greaterThanOrEqualToConstant: 0)
|
||||
inlineWidthConstraint?.isActive = true
|
||||
@ -150,7 +134,7 @@ open class DropdownSelect: EntryFieldBase {
|
||||
}()
|
||||
|
||||
// tap gesture
|
||||
containerStackView
|
||||
fieldStackView
|
||||
.publisher(for: UITapGestureRecognizer())
|
||||
.sink { [weak self] _ in
|
||||
self?.launchPicker()
|
||||
@ -158,6 +142,21 @@ open class DropdownSelect: EntryFieldBase {
|
||||
.store(in: &subscribers)
|
||||
}
|
||||
|
||||
open override func getFieldContainer() -> UIView {
|
||||
let controlStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .horizontal
|
||||
$0.spacing = VDSFormControls.spaceInset
|
||||
}
|
||||
controlStackView.addArrangedSubview(dropdownField)
|
||||
controlStackView.addArrangedSubview(inlineDisplayLabel)
|
||||
controlStackView.addArrangedSubview(selectedOptionLabel)
|
||||
controlStackView.setCustomSpacing(0, after: dropdownField)
|
||||
controlStackView.setCustomSpacing(VDSLayout.space1X, after: inlineDisplayLabel)
|
||||
controlStackView.setCustomSpacing(VDSLayout.space3X, after: selectedOptionLabel)
|
||||
return controlStackView
|
||||
}
|
||||
|
||||
/// Used to make changes to the View based off a change events or from local properties.
|
||||
open override func updateView() {
|
||||
super.updateView()
|
||||
@ -250,14 +249,14 @@ open class DropdownSelect: EntryFieldBase {
|
||||
open override func updateAccessibility() {
|
||||
super.updateAccessibility()
|
||||
let selectedOption = selectedOptionLabel.text ?? ""
|
||||
containerStackView.accessibilityLabel = "Dropdown Select, \(selectedOption) \(isReadOnly ? ", read only" : "")"
|
||||
containerStackView.accessibilityHint = isReadOnly || !isEnabled ? "" : "Double tap to open."
|
||||
fieldStackView.accessibilityLabel = "Dropdown Select, \(selectedOption) \(isReadOnly ? ", read only" : "")"
|
||||
fieldStackView.accessibilityHint = isReadOnly || !isEnabled ? "" : "Double tap to open."
|
||||
}
|
||||
|
||||
open override var accessibilityElements: [Any]? {
|
||||
get {
|
||||
var elements = [Any]()
|
||||
elements.append(contentsOf: [titleLabel, containerStackView])
|
||||
elements.append(contentsOf: [titleLabel, fieldStackView])
|
||||
|
||||
if showError {
|
||||
elements.append(statusIcon)
|
||||
@ -281,7 +280,7 @@ open class DropdownSelect: EntryFieldBase {
|
||||
optionsPicker.isHidden = true
|
||||
dropdownField.resignFirstResponder()
|
||||
setNeedsUpdate()
|
||||
UIAccessibility.post(notification: .layoutChanged, argument: containerStackView)
|
||||
UIAccessibility.post(notification: .layoutChanged, argument: fieldStackView)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
}
|
||||
}()
|
||||
|
||||
internal var containerStackView: UIStackView = {
|
||||
internal var fieldStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .horizontal
|
||||
@ -76,12 +76,6 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
}
|
||||
}()
|
||||
|
||||
internal var fieldContainerView: UIView = {
|
||||
return UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
}()
|
||||
|
||||
internal var bottomContainerStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
@ -224,21 +218,20 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
|
||||
widthConstraint = containerView.widthAnchor.constraint(equalToConstant: 0)
|
||||
widthConstraint?.priority = .defaultHigh
|
||||
|
||||
//get the container this is what is color
|
||||
//border, internal, etc...
|
||||
let container = getContainer()
|
||||
|
||||
|
||||
//add ContainerStackView
|
||||
//this is the horizontal stack that contains
|
||||
//the left, InputContainer, Icons, Buttons
|
||||
container.addSubview(containerStackView)
|
||||
containerStackView.pinToSuperView(.uniform(VDSLayout.space3X))
|
||||
containerView.addSubview(fieldStackView)
|
||||
fieldStackView.pinToSuperView(.uniform(VDSLayout.space3X))
|
||||
|
||||
let fieldContainerView = getFieldContainer()
|
||||
fieldContainerView.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
//add the view to add input fields
|
||||
containerStackView.addArrangedSubview(fieldContainerView)
|
||||
containerStackView.addArrangedSubview(statusIcon)
|
||||
containerStackView.setCustomSpacing(VDSLayout.space3X, after: fieldContainerView)
|
||||
fieldStackView.addArrangedSubview(fieldContainerView)
|
||||
fieldStackView.addArrangedSubview(statusIcon)
|
||||
fieldStackView.setCustomSpacing(VDSLayout.space3X, after: fieldContainerView)
|
||||
|
||||
//get the container this is what show helper text, error text
|
||||
//can include other for character count, max length
|
||||
@ -249,11 +242,11 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
bottomContainerStackView.addArrangedSubview(helperLabel)
|
||||
|
||||
stackView.addArrangedSubview(titleLabel)
|
||||
stackView.addArrangedSubview(container)
|
||||
stackView.addArrangedSubview(containerView)
|
||||
stackView.addArrangedSubview(bottomContainer)
|
||||
|
||||
stackView.setCustomSpacing(4, after: titleLabel)
|
||||
stackView.setCustomSpacing(8, after: container)
|
||||
stackView.setCustomSpacing(8, after: containerView)
|
||||
stackView.setCustomSpacing(8, after: bottomContainer)
|
||||
|
||||
stackView
|
||||
@ -322,8 +315,8 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
// MARK: - Public Methods
|
||||
//--------------------------------------------------
|
||||
/// Container for the area in which the user interacts.
|
||||
open func getContainer() -> UIView {
|
||||
return containerView
|
||||
open func getFieldContainer() -> UIView {
|
||||
fatalError("Subclass must return the view that contains the field/view the user will interact with.")
|
||||
}
|
||||
|
||||
/// Container for the area in which helper or error text presents.
|
||||
|
||||
@ -72,10 +72,10 @@ extension InputField {
|
||||
actionModel.onClick(inputField)
|
||||
}
|
||||
inputField.actionTextLink.isHidden = false
|
||||
inputField.containerStackView.setCustomSpacing(VDSLayout.space2X, after: inputField.statusIcon)
|
||||
inputField.fieldStackView.setCustomSpacing(VDSLayout.space2X, after: inputField.statusIcon)
|
||||
} else {
|
||||
inputField.actionTextLink.isHidden = true
|
||||
inputField.containerStackView.setCustomSpacing(0, after: inputField.statusIcon)
|
||||
inputField.fieldStackView.setCustomSpacing(0, after: inputField.statusIcon)
|
||||
}
|
||||
|
||||
//set the width constraints
|
||||
|
||||
@ -178,19 +178,7 @@ open class InputField: EntryFieldBase {
|
||||
|
||||
minWidthConstraint = containerView.widthAnchor.constraint(greaterThanOrEqualToConstant: 0)
|
||||
minWidthConstraint?.isActive = true
|
||||
|
||||
// stackview for controls in EntryFieldBase.controlContainerView
|
||||
let controlStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .horizontal
|
||||
$0.spacing = VDSLayout.space3X
|
||||
}
|
||||
fieldContainerView.addSubview(controlStackView)
|
||||
controlStackView.pinToSuperView()
|
||||
|
||||
controlStackView.addArrangedSubview(leftImageView)
|
||||
controlStackView.addArrangedSubview(textField)
|
||||
|
||||
|
||||
textField.heightAnchor.constraint(equalToConstant: 20).isActive = true
|
||||
textField.delegate = self
|
||||
textField
|
||||
@ -207,7 +195,7 @@ open class InputField: EntryFieldBase {
|
||||
stackView.addArrangedSubview(successLabel)
|
||||
stackView.setCustomSpacing(8, after: successLabel)
|
||||
|
||||
containerStackView.addArrangedSubview(actionTextLink)
|
||||
fieldStackView.addArrangedSubview(actionTextLink)
|
||||
|
||||
successLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
||||
|
||||
@ -217,6 +205,18 @@ open class InputField: EntryFieldBase {
|
||||
|
||||
}
|
||||
|
||||
open override func getFieldContainer() -> UIView {
|
||||
// stackview for controls in EntryFieldBase.controlContainerView
|
||||
let stackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .horizontal
|
||||
$0.spacing = VDSLayout.space3X
|
||||
}
|
||||
stackView.addArrangedSubview(leftImageView)
|
||||
stackView.addArrangedSubview(textField)
|
||||
return stackView
|
||||
}
|
||||
|
||||
/// Resets to default settings.
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
@ -230,12 +230,6 @@ open class InputField: EntryFieldBase {
|
||||
successText = nil
|
||||
helperTextPlacement = .bottom
|
||||
}
|
||||
|
||||
/// Container for the area in which the user interacts.
|
||||
open override func getContainer() -> UIView {
|
||||
inputFieldStackView.addArrangedSubview(containerView)
|
||||
return inputFieldStackView
|
||||
}
|
||||
|
||||
/// Used to make changes to the View based off a change events or from local properties.
|
||||
open override func updateView() {
|
||||
|
||||
@ -151,15 +151,9 @@ open class TextArea: EntryFieldBase {
|
||||
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
|
||||
open override func setup() {
|
||||
super.setup()
|
||||
containerStackView.pinToSuperView(.uniform(VDSFormControls.spaceInset))
|
||||
fieldStackView.pinToSuperView(.uniform(VDSFormControls.spaceInset))
|
||||
minWidthConstraint = containerView.widthAnchor.constraint(greaterThanOrEqualToConstant: containerSize.width)
|
||||
minWidthConstraint?.isActive = true
|
||||
fieldContainerView.addSubview(textView)
|
||||
textView
|
||||
.pinTop()
|
||||
.pinLeading()
|
||||
.pinTrailingLessThanOrEqualTo(nil, 0, .defaultHigh)
|
||||
.pinBottom(0, .defaultHigh)
|
||||
|
||||
textView.isScrollEnabled = true
|
||||
textView.autocorrectionType = .no
|
||||
@ -200,13 +194,7 @@ open class TextArea: EntryFieldBase {
|
||||
characterCounterLabel.textStyle = .bodySmall
|
||||
setNeedsUpdate()
|
||||
}
|
||||
|
||||
/// Container for the area in which the user interacts.
|
||||
open override func getContainer() -> UIView {
|
||||
inputFieldStackView.addArrangedSubview(containerView)
|
||||
return inputFieldStackView
|
||||
}
|
||||
|
||||
|
||||
/// Used to make changes to the View based off a change events or from local properties.
|
||||
open override func updateView() {
|
||||
super.updateView()
|
||||
@ -242,6 +230,10 @@ open class TextArea: EntryFieldBase {
|
||||
rules.append(.init(countRule))
|
||||
}
|
||||
|
||||
open override func getFieldContainer() -> UIView {
|
||||
textView
|
||||
}
|
||||
|
||||
/// Container for the area showing helper text, error text, character count, maximum length value.
|
||||
open override func getBottomContainer() -> UIView {
|
||||
let stackView = UIStackView().with {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user