Digital ACT191 story ONEAPP-6682 adding character count limit to container
This commit is contained in:
parent
9883bd6214
commit
783143717c
@ -70,6 +70,20 @@ open class EntryFieldBase: Control, Changeable {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
internal var bottomContainerView: UIView = {
|
||||||
|
return UIView().with {
|
||||||
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
internal var bottomContainerStackView: UIStackView = {
|
||||||
|
return UIStackView().with {
|
||||||
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
$0.axis = .vertical
|
||||||
|
$0.distribution = .fill
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration Properties
|
// MARK: - Configuration Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -204,14 +218,24 @@ open class EntryFieldBase: Control, Changeable {
|
|||||||
containerStackView.addArrangedSubview(controlContainerView)
|
containerStackView.addArrangedSubview(controlContainerView)
|
||||||
containerStackView.addArrangedSubview(icon)
|
containerStackView.addArrangedSubview(icon)
|
||||||
|
|
||||||
|
//get the container this is what show helper text, error text
|
||||||
|
//can include other for character count, max length
|
||||||
|
let bottomContainer = getBottomContainer()
|
||||||
|
|
||||||
|
//add bottomContainerStackView
|
||||||
|
//this is the vertical stack that contains error text, helper text
|
||||||
|
bottomContainer.addSubview(bottomContainerStackView)
|
||||||
|
bottomContainerStackView.pinToSuperView()
|
||||||
|
bottomContainerStackView.addArrangedSubview(errorLabel)
|
||||||
|
bottomContainerStackView.addArrangedSubview(helperLabel)
|
||||||
|
|
||||||
stackView.addArrangedSubview(titleLabel)
|
stackView.addArrangedSubview(titleLabel)
|
||||||
stackView.addArrangedSubview(container)
|
stackView.addArrangedSubview(container)
|
||||||
stackView.addArrangedSubview(errorLabel)
|
stackView.addArrangedSubview(bottomContainer)
|
||||||
stackView.addArrangedSubview(helperLabel)
|
|
||||||
|
|
||||||
stackView.setCustomSpacing(4, after: titleLabel)
|
stackView.setCustomSpacing(4, after: titleLabel)
|
||||||
stackView.setCustomSpacing(8, after: container)
|
stackView.setCustomSpacing(8, after: container)
|
||||||
stackView.setCustomSpacing(8, after: errorLabel)
|
stackView.setCustomSpacing(8, after: bottomContainer)
|
||||||
|
|
||||||
stackView
|
stackView
|
||||||
.pinTop()
|
.pinTop()
|
||||||
@ -274,6 +298,11 @@ open class EntryFieldBase: Control, Changeable {
|
|||||||
return containerView
|
return containerView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Container for the area in which helper or error text presents.
|
||||||
|
open func getBottomContainer() -> UIView {
|
||||||
|
return bottomContainerView
|
||||||
|
}
|
||||||
|
|
||||||
open func updateTitleLabel() {
|
open func updateTitleLabel() {
|
||||||
|
|
||||||
//update the local vars for the label since we no
|
//update the local vars for the label since we no
|
||||||
|
|||||||
@ -45,6 +45,30 @@ open class TextArea: EntryFieldBase {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
internal var bottomView: UIView = {
|
||||||
|
return UIView().with {
|
||||||
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
internal var bottomStackView: UIStackView = {
|
||||||
|
return UIStackView().with {
|
||||||
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
$0.axis = .horizontal
|
||||||
|
$0.distribution = .fill
|
||||||
|
$0.alignment = .top
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
open var characterCountLabel = Label().with {
|
||||||
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
|
$0.textStyle = .bodySmall
|
||||||
|
}
|
||||||
|
open var maxLengthLabel = Label().with {
|
||||||
|
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
|
$0.textStyle = .bodySmall
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -70,9 +94,10 @@ open class TextArea: EntryFieldBase {
|
|||||||
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
|
/// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations.
|
||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
|
|
||||||
minWidthConstraint = containerView.widthAnchor.constraint(greaterThanOrEqualToConstant: containerSize.width)
|
minWidthConstraint = containerView.widthAnchor.constraint(greaterThanOrEqualToConstant: containerSize.width)
|
||||||
minWidthConstraint?.isActive = true
|
minWidthConstraint?.isActive = true
|
||||||
|
characterCountLabel.text = "0"
|
||||||
|
maxLengthLabel.text = "/200"
|
||||||
|
|
||||||
controlContainerView.addSubview(textView)
|
controlContainerView.addSubview(textView)
|
||||||
textView
|
textView
|
||||||
@ -119,6 +144,16 @@ open class TextArea: EntryFieldBase {
|
|||||||
minWidthConstraint?.isActive = true
|
minWidthConstraint?.isActive = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Container for the area which shows helper text, error text, character count, max length value.
|
||||||
|
open override func getBottomContainer() -> UIView {
|
||||||
|
bottomView.addSubview(bottomStackView)
|
||||||
|
bottomStackView.pinToSuperView()
|
||||||
|
bottomStackView.addArrangedSubview(bottomContainerView)
|
||||||
|
bottomStackView.addArrangedSubview(characterCountLabel)
|
||||||
|
bottomStackView.addArrangedSubview(maxLengthLabel)
|
||||||
|
return bottomView
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TextArea: UITextViewDelegate {
|
extension TextArea: UITextViewDelegate {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user