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.errorText = "Enter a valid address."
component.tooltipModel = .init(title: "Check the formatting of your address", content:"House/Building number then street name") component.tooltipModel = .init(title: "Check the formatting of your address", content:"House/Building number then street name")
component.options = moreOptions component.options = moreOptions
component.selectId = 0
/// callback to know which option chose /// callback to know which option chose
component.onDropdownItemSelect = { option in component.onItemSelected = { index, option in
print("selected option text: \(option.text)") 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 //setup UI

View File

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

View File

@ -131,16 +131,15 @@ class TextAreaViewController: BaseViewController<TextArea> {
component.helperText = "For example: 123 Verizon St" component.helperText = "For example: 123 Verizon St"
component.errorText = "Enter a valid address." component.errorText = "Enter a valid address."
component.tooltipModel = .init(title: "Check the formatting of your address", content:"House/Building number then street name") component.tooltipModel = .init(title: "Check the formatting of your address", content:"House/Building number then street name")
component
.publisher(for: .valueChanged) component.onChange = { component in
.sink { component in if let text = component.value {
// if let text = component.value { print("text entry: \(text)")
// print("text entry: \(text)") } else {
// } else { print("text entry: null")
// print("text entry: null") }
// } }
}.store(in: &subscribers)
//setup UI //setup UI
surfacePickerSelectorView.text = component.surface.rawValue surfacePickerSelectorView.text = component.surface.rawValue
disabledSwitch.isOn = !component.isEnabled disabledSwitch.isOn = !component.isEnabled