Digital ACT191 story ONEAPP-6682 adding max length textfield to TextArea form
This commit is contained in:
parent
719ae8b9fc
commit
44deb6a680
@ -5,7 +5,6 @@
|
||||
// Created by Matt Bruce on 1/10/23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDS
|
||||
@ -23,7 +22,8 @@ class TextAreaViewController: BaseViewController<TextArea> {
|
||||
var showErrorSwitch = Toggle()
|
||||
var tooltipTitleTextField = TextField()
|
||||
var tooltipContentTextField = TextField()
|
||||
|
||||
var maxLengthTextField = NumericField()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: component)
|
||||
@ -44,7 +44,8 @@ class TextAreaViewController: BaseViewController<TextArea> {
|
||||
addFormRow(label: "Width", view: widthTextField)
|
||||
addFormRow(label: "ToolTip Title", view: tooltipTitleTextField)
|
||||
addFormRow(label: "ToolTip Content", view: tooltipContentTextField)
|
||||
|
||||
addFormRow(label: "Max Length", view: maxLengthTextField)
|
||||
|
||||
requiredSwitch.onChange = { [weak self] sender in
|
||||
self?.component.required = sender.isOn
|
||||
}
|
||||
@ -98,6 +99,12 @@ class TextAreaViewController: BaseViewController<TextArea> {
|
||||
self?.updateTooltip()
|
||||
}.store(in: &subscribers)
|
||||
|
||||
maxLengthTextField
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
guard let number else { return }
|
||||
self?.component.maxLength = number.intValue
|
||||
}.store(in: &subscribers)
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
@ -106,7 +113,7 @@ class TextAreaViewController: BaseViewController<TextArea> {
|
||||
component.helperText = "For example: 123 Verizon St"
|
||||
component.errorText = "Enter a valid address."
|
||||
component.tooltipModel = .init(title: "Check the formatting of your address", content:"House/Building number then street name")
|
||||
|
||||
component.maxLength = 10
|
||||
component
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { component in
|
||||
@ -125,6 +132,7 @@ class TextAreaViewController: BaseViewController<TextArea> {
|
||||
helperTextField.text = component.helperText
|
||||
showErrorSwitch.isOn = component.showError
|
||||
errorTextField.text = component.errorText
|
||||
maxLengthTextField.text = String(component.maxLength ?? 0)
|
||||
tooltipTitleTextField.text = component.tooltipModel?.title
|
||||
tooltipContentTextField.text = component.tooltipModel?.content
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user