fixed sample for width updates

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-09-20 13:40:16 -05:00
parent 70493edd0f
commit c1c92f0926
7 changed files with 52 additions and 24 deletions

View File

@ -171,6 +171,7 @@ class DatePickerViewController: BaseViewController<DatePicker> {
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
self?.component.width = number?.cgFloatValue
}.store(in: &subscribers)
@ -479,3 +480,12 @@ extension DatePickerViewController {
}
}
extension DatePickerViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
c.setupCalendar()
return ComponentSample(component: c.component)
}
}

View File

@ -131,6 +131,7 @@ class DropdownSelectViewController: BaseViewController<DropdownSelect> {
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
self?.component.width = number?.cgFloatValue
}.store(in: &subscribers)

View File

@ -17,7 +17,7 @@ class FootnoteGroupViewController: BaseViewController<FootnoteGroup> {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: component)
setupPicker()
setupModel()
}
@ -31,6 +31,7 @@ class FootnoteGroupViewController: BaseViewController<FootnoteGroup> {
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number {
self?.component.width = .value(number.cgFloatValue)
self?.percentageTextField.text = ""
@ -42,6 +43,7 @@ class FootnoteGroupViewController: BaseViewController<FootnoteGroup> {
percentageTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number, number.intValue > 9 {
self?.component.width = .percentage(number.cgFloatValue)
self?.widthTextField.text = ""
@ -67,3 +69,11 @@ class FootnoteGroupViewController: BaseViewController<FootnoteGroup> {
}
}
}
extension FootnoteGroupViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
}
}

View File

@ -61,7 +61,7 @@ class FootnoteItemViewController: BaseViewController<FootnoteItem> {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: component)
setupPicker()
setupModel()
}
@ -92,6 +92,7 @@ class FootnoteItemViewController: BaseViewController<FootnoteItem> {
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number {
self?.component.width = .value(number.cgFloatValue)
self?.percentageTextField.text = ""
@ -103,6 +104,7 @@ class FootnoteItemViewController: BaseViewController<FootnoteItem> {
percentageTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number, number.intValue > 9 {
self?.component.width = .percentage(number.cgFloatValue)
self?.widthTextField.text = ""
@ -164,3 +166,11 @@ class FootnoteItemViewController: BaseViewController<FootnoteItem> {
}
}
extension FootnoteItemViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
}
}

View File

@ -181,6 +181,7 @@ class InputFieldViewController: BaseViewController<InputField> {
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
self?.component.width = number?.cgFloatValue
}.store(in: &subscribers)
@ -329,14 +330,8 @@ class InputFieldViewController: BaseViewController<InputField> {
extension InputFieldViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let component = Self.makeComponent()
component.fieldType = .text
component.width = 328
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")
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
}
}

View File

@ -163,6 +163,7 @@ class InputStepperViewController: BaseViewController<InputStepper> {
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number {
self?.component.widthPercentage = nil
self?.component.width = number.cgFloatValue
@ -175,6 +176,7 @@ class InputStepperViewController: BaseViewController<InputStepper> {
widthPercentageTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number, number.intValue > 10 {
self?.component.width = nil
self?.component.widthPercentage = number.cgFloatValue
@ -253,3 +255,11 @@ class InputStepperViewController: BaseViewController<InputStepper> {
helperTextPlacementPickerSelectorView.text = component.helperTextPlacement.rawValue
}
}
extension InputStepperViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
}
}

View File

@ -101,11 +101,8 @@ class TextAreaViewController: BaseViewController<TextArea> {
widthTextField
.numberPublisher
.sink { [weak self] number in
guard let number else {
self?.component.width = nil
return
}
self?.component.width = number.cgFloatValue
self?.updateComponentConstraint(pinTrailing: number == nil)
self?.component.width = number?.cgFloatValue
}.store(in: &subscribers)
tooltipTitleTextField
@ -182,13 +179,8 @@ class TextAreaViewController: BaseViewController<TextArea> {
extension TextAreaViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let component = Self.makeComponent()
component.width = 328
component.labelText = "Street Address"
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")
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
}
}