updated onChange

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-04-09 16:19:20 -05:00
parent 2bf7d2e1ab
commit a870ef5de1
3 changed files with 25 additions and 23 deletions

View File

@ -145,11 +145,15 @@ class DropdownSelectViewController: BaseViewController<DropdownSelect> {
component.errorText = "Enter a valid address."
component.tooltipModel = .init(title: "Check the formatting of your address", content:"House/Building number then street name")
component.options = moreOptions
component.selectId = 0
/// callback to know which option chose
component.onDropdownItemSelect = { option in
print("selected option text: \(option.text)")
component.onItemSelected = { index, option in
print("selected index: \(index) text: \(option.text) value: \(option.value)")
}
component.onChange = { dropdown in
guard let option = dropdown.selectedItem, let index = dropdown.selectId else { print("nothing selected"); return }
print("selected index: \(index) text: \(option.text) value: \(option.value)")
}
//setup UI

View File

@ -119,22 +119,21 @@ class InputFieldViewController: BaseViewController<InputField> {
func setupModel() {
component.fieldType = .text
component.width = 328
component.text = "Starting Text"
component.labelText = "Street Address"
component.helperText = "For example: 123 Verizon St"
component.errorText = "Enter a valid address."
component.successText = "Good job entering a valid address!"
component.tooltipModel = .init(title: "Check the formatting of your address", content:"House/Building number then street name")
component
.publisher(for: .valueChanged)
.sink { component in
if let text = component.value {
print("text entry: \(text)")
} else {
print("text entry: null")
}
}.store(in: &subscribers)
component.onChange = { component in
if let text = component.value {
print("text entry: \(text)")
} else {
print("text entry: null")
}
}
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
helperTextPlacementPickerSelectorView.text = component.helperTextPlacement.rawValue

View File

@ -131,16 +131,15 @@ 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
.publisher(for: .valueChanged)
.sink { component in
// if let text = component.value {
// print("text entry: \(text)")
// } else {
// print("text entry: null")
// }
}.store(in: &subscribers)
component.onChange = { component in
if let text = component.value {
print("text entry: \(text)")
} else {
print("text entry: null")
}
}
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
disabledSwitch.isOn = !component.isEnabled