Digital ACT-191 ONEAPP-9311 story: parent container width, controlWidth of input stepper can be set to value - percentage

This commit is contained in:
Vasavi Kanamarlapudi 2024-07-26 20:49:36 +05:30
parent 170d902a1e
commit 0830610108

View File

@ -14,12 +14,14 @@ import Combine
class InputStepperViewController: BaseViewController<InputStepper> { class InputStepperViewController: BaseViewController<InputStepper> {
var controlWidthTextField = TextField() var controlWidthTextField = TextField()
var controlWidthPercentageTextField = TextField()
var defaultValueField = NumericField() var defaultValueField = NumericField()
var maxValueTextField = NumericField() var maxValueTextField = NumericField()
var minValueTextField = NumericField() var minValueTextField = NumericField()
var trailingTextField = TextField() var trailingTextField = TextField()
var widthTextField = NumericField() var widthTextField = NumericField()
var widthPercentageTextField = NumericField()
var disabledSwitch = Toggle() var disabledSwitch = Toggle()
var readOnlySwitch = Toggle() var readOnlySwitch = Toggle()
var requiredSwitch = Toggle() var requiredSwitch = Toggle()
@ -51,13 +53,15 @@ class InputStepperViewController: BaseViewController<InputStepper> {
addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Control Width", view: controlWidthTextField) addFormRow(label: "Control Width", view: controlWidthTextField)
addFormRow(label: "ControlWidth Percentage", view: controlWidthPercentageTextField)
addFormRow(label: "Default Value", view: defaultValueField) addFormRow(label: "Default Value", view: defaultValueField)
addFormRow(label: "Max Value", view: maxValueTextField) addFormRow(label: "Max Value", view: maxValueTextField)
addFormRow(label: "Min Value", view: minValueTextField) addFormRow(label: "Min Value", view: minValueTextField)
addFormRow(label: "Trailing Text", view: trailingTextField) addFormRow(label: "Trailing Text", view: trailingTextField)
addFormRow(label: "Size", view: sizePickerSelectorView) addFormRow(label: "Size", view: sizePickerSelectorView)
addFormRow(label: "Width", view: widthTextField) addFormRow(label: "Width Value", view: widthTextField)
addFormRow(label: "Width Percentage", view: widthPercentageTextField)
addFormRow(label: "Disabled", view: disabledSwitch) addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Read Only", view: readOnlySwitch) addFormRow(label: "Read Only", view: readOnlySwitch)
addFormRow(label: "Required", view: requiredSwitch) addFormRow(label: "Required", view: requiredSwitch)
@ -73,8 +77,21 @@ class InputStepperViewController: BaseViewController<InputStepper> {
.textPublisher .textPublisher
.sink { [weak self] text in .sink { [weak self] text in
self?.component.controlWidth = text self?.component.controlWidth = text
self?.controlWidthPercentageTextField.text = ""
self?.component.controlWidthPercentage = nil
}.store(in: &subscribers) }.store(in: &subscribers)
controlWidthPercentageTextField
.numberPublisher
.sink { [weak self] number in
if let number {
self?.component.controlWidthPercentage = number.cgFloatValue
self?.controlWidthTextField.text = ""
} else {
self?.component.controlWidthPercentage = nil
}
}.store(in: &subscribers)
defaultValueField defaultValueField
.numberPublisher .numberPublisher
.sink { [weak self] number in .sink { [weak self] number in
@ -141,8 +158,24 @@ class InputStepperViewController: BaseViewController<InputStepper> {
widthTextField widthTextField
.numberPublisher .numberPublisher
.sink { [weak self] number in .sink { [weak self] number in
self?.component.width = number?.cgFloatValue if let number {
}.store(in: &subscribers) self?.component.width = number.cgFloatValue
self?.widthPercentageTextField.text = ""
} else {
self?.component.width = nil
}
}.store(in: &subscribers)
widthPercentageTextField
.numberPublisher
.sink { [weak self] number in
if let number {
self?.component.widthPercentage = number.cgFloatValue
self?.widthTextField.text = ""
} else {
self?.component.widthPercentage = nil
}
}.store(in: &subscribers)
tooltipTitleTextField tooltipTitleTextField
.textPublisher .textPublisher
@ -185,8 +218,8 @@ class InputStepperViewController: BaseViewController<InputStepper> {
component.labelText = "Quantity" component.labelText = "Quantity"
component.helperText = "Add up to max lines." component.helperText = "Add up to max lines."
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 = 2 component.defaultValue = 88
component.trailingText = "lines" component.trailingText = ""
component.controlWidth = "auto" component.controlWidth = "auto"
trailingTextField.text = component.trailingText trailingTextField.text = component.trailingText
controlWidthTextField.text = component.controlWidth controlWidthTextField.text = component.controlWidth