Digital ACT-191 ONEAPP-9311 story: refactored code and resolved constraint issues

This commit is contained in:
Vasavi Kanamarlapudi 2024-07-31 14:53:43 +05:30
parent a85a675214
commit 4399eef2d6

View File

@ -74,21 +74,24 @@ class InputStepperViewController: BaseViewController<InputStepper> {
addFormRow(label: "Tooltip Content", view: tooltipContentTextField) addFormRow(label: "Tooltip Content", view: tooltipContentTextField)
controlWidthTextField controlWidthTextField
.textPublisher .numberPublisher
.sink { [weak self] text in .sink { [weak self] number in
self?.component.controlWidth = text if let number {
self?.controlWidthPercentageTextField.text = "" self?.component.controlWidth = .value(number.cgFloatValue)
self?.component.controlWidthPercentage = nil self?.controlWidthPercentageTextField.text = ""
} else {
self?.component.controlWidth = nil
}
}.store(in: &subscribers) }.store(in: &subscribers)
controlWidthPercentageTextField controlWidthPercentageTextField
.numberPublisher .numberPublisher
.sink { [weak self] number in .sink { [weak self] number in
if let number, number.intValue > 10 { if let number {
self?.component.controlWidthPercentage = number.cgFloatValue self?.component.controlWidth = .percentage(number.cgFloatValue)
self?.controlWidthTextField.text = "" self?.controlWidthTextField.text = ""
} else { } else {
self?.component.controlWidthPercentage = nil self?.component.controlWidth = nil
} }
}.store(in: &subscribers) }.store(in: &subscribers)
@ -159,6 +162,7 @@ class InputStepperViewController: BaseViewController<InputStepper> {
.numberPublisher .numberPublisher
.sink { [weak self] number in .sink { [weak self] number in
if let number { if let number {
self?.component.widthPercentage = nil
self?.component.width = number.cgFloatValue self?.component.width = number.cgFloatValue
self?.widthPercentageTextField.text = "" self?.widthPercentageTextField.text = ""
} else { } else {
@ -170,6 +174,7 @@ class InputStepperViewController: BaseViewController<InputStepper> {
.numberPublisher .numberPublisher
.sink { [weak self] number in .sink { [weak self] number in
if let number, number.intValue > 10 { if let number, number.intValue > 10 {
self?.component.width = nil
self?.component.widthPercentage = number.cgFloatValue self?.component.widthPercentage = number.cgFloatValue
self?.widthTextField.text = "" self?.widthTextField.text = ""
} else { } else {
@ -220,9 +225,8 @@ class InputStepperViewController: BaseViewController<InputStepper> {
component.errorText = "You must choose a number of lines before advancing to the next step." component.errorText = "You must choose a number of lines before advancing to the next step."
component.defaultValue = 8 component.defaultValue = 8
component.trailingText = "" component.trailingText = ""
component.controlWidth = "auto"
trailingTextField.text = component.trailingText trailingTextField.text = component.trailingText
controlWidthTextField.text = component.controlWidth controlWidthTextField.text = ""
errorTextField.text = component.errorText errorTextField.text = component.errorText
helperTextField.text = component.helperText helperTextField.text = component.helperText
labelTextField.text = component.labelText labelTextField.text = component.labelText