update to deal with tooltip model

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-09-14 08:35:33 -05:00
parent 66673cb294
commit 5502bee9d7
4 changed files with 40 additions and 28 deletions

View File

@ -105,13 +105,13 @@ class InputFieldViewController: BaseViewController<InputField> {
tooltipTitleTextField
.textPublisher
.sink { [weak self] text in
self?.component.tooltipTitle = text
self?.updateTooltip()
}.store(in: &subscribers)
tooltipContentTextField
.textPublisher
.sink { [weak self] text in
self?.component.tooltipContent = text
self?.updateTooltip()
}.store(in: &subscribers)
}
@ -123,8 +123,7 @@ class InputFieldViewController: BaseViewController<InputField> {
component.helperText = "For example: 123 Verizon St"
component.errorText = "Enter a valid address."
component.successText = "Good job entering a valid address!"
component.tooltipTitle = "Check the formatting of your address"
component.tooltipContent = "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)
@ -147,8 +146,8 @@ class InputFieldViewController: BaseViewController<InputField> {
errorTextField.text = component.errorText
showSuccessSwitch.isOn = component.showSuccess
successTextField.text = component.successText
tooltipTitleTextField.text = component.tooltipTitle
tooltipContentTextField.text = component.tooltipContent
tooltipTitleTextField.text = component.tooltipModel?.title
tooltipContentTextField.text = component.tooltipModel?.content
if let width = component.width {
widthTextField.text = String(describing: width)
}
@ -165,6 +164,11 @@ class InputFieldViewController: BaseViewController<InputField> {
self?.component.helperTextPlacement = item
}
}
func updateTooltip() {
component.tooltipModel = .init(title: tooltipTitleTextField.text,
content: tooltipContentTextField.text)
}
}
@ -177,8 +181,7 @@ extension InputFieldViewController: ComponentSampleable {
component.helperText = "For example: 123 Verizon St"
component.errorText = "Enter a valid address."
component.successText = "Good job entering a valid address!"
component.tooltipTitle = "Check the formatting of your address"
component.tooltipContent = "House/Building number then street name"
component.tooltipModel = .init(title: "Check the formatting of your address", content: "House/Building number then street name")
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}

View File

@ -89,13 +89,13 @@ class TextAreaViewController: BaseViewController<TextArea> {
tooltipTitleTextField
.textPublisher
.sink { [weak self] text in
self?.component.tooltipTitle = text
self?.updateTooltip()
}.store(in: &subscribers)
tooltipContentTextField
.textPublisher
.sink { [weak self] text in
self?.component.tooltipContent = text
self?.updateTooltip()
}.store(in: &subscribers)
}
@ -105,8 +105,7 @@ class TextAreaViewController: BaseViewController<TextArea> {
component.labelText = "Street Address"
component.helperText = "For example: 123 Verizon St"
component.errorText = "Enter a valid address."
component.tooltipTitle = "Check the formatting of your address"
component.tooltipContent = "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)
@ -126,8 +125,8 @@ class TextAreaViewController: BaseViewController<TextArea> {
helperTextField.text = component.helperText
showErrorSwitch.isOn = component.showError
errorTextField.text = component.errorText
tooltipTitleTextField.text = component.tooltipTitle
tooltipContentTextField.text = component.tooltipContent
tooltipTitleTextField.text = component.tooltipModel?.title
tooltipContentTextField.text = component.tooltipModel?.content
}
//Picker
@ -137,6 +136,12 @@ class TextAreaViewController: BaseViewController<TextArea> {
self?.contentTopView.backgroundColor = item.color
}
}
func updateTooltip() {
component.tooltipModel = .init(title: tooltipTitleTextField.text,
content: tooltipContentTextField.text)
}
}
extension TextAreaViewController: ComponentSampleable {
@ -146,8 +151,8 @@ extension TextAreaViewController: ComponentSampleable {
component.labelText = "Street Address"
component.helperText = "For example: 123 Verizon St"
component.errorText = "Enter a valid address."
component.tooltipTitle = "Check the formatting of your address"
component.tooltipContent = "House/Building number then street name"
component.tooltipModel = .init(title: "Check the formatting of your address",
content:"House/Building number then street name")
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}

View File

@ -195,7 +195,6 @@ extension TitleLockupViewController: ComponentSampleable {
component.eyebrowModel = eyebrowModel
component.titleModel = titleModel
component.subTitleModel = subTitleModel
component.debugBorder(show: true)
return ComponentSample(component: component)
}
}

View File

@ -79,27 +79,27 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
titleTextField
.textPublisher
.sink { [weak self] text in
self?.component.tooltipTitle = text
self?.updateTooltip()
}.store(in: &subscribers)
contentTextField
.textPublisher
.sink { [weak self] text in
self?.component.tooltipContent = text
self?.updateTooltip()
}.store(in: &subscribers)
closeButtonTextField
.textPublisher
.sink { [weak self] text in
self?.component.tooltipCloseButtonText = text
self?.updateTooltip()
}.store(in: &subscribers)
}
func setupModel() {
component.labelText = "5G Ultra Wideband is available in your area"
component.tooltipTitle = "5G Ultra Wideband is available in your area."
component.tooltipContent = "$799.99 (128 GB only)"
component.tooltipModel = .init(title: "Check the formatting of your address",
content:"House/Building number then street name")
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
@ -114,10 +114,9 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
disabledSwitch.isOn = !component.isEnabled
titleTextField.text = component.tooltipTitle
contentTextField.text = component.tooltipContent
closeButtonTextField.text = component.tooltipCloseButtonText
titleTextField.text = component.tooltipModel?.title
contentTextField.text = component.tooltipModel?.content
closeButtonTextField.text = component.tooltipModel?.closeButtonText
}
//Picker
@ -166,14 +165,20 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
self?.fontCategory = item
}
}
func updateTooltip() {
component.tooltipModel = .init(closeButtonText: closeButtonTextField.text ?? "Close",
title: titleTextField.text,
content: contentTextField.text)
}
}
extension TrailingTooltipLabelViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let component = Self.makeComponent()
component.labelText = "5G Ultra Wideband is available in your area"
component.tooltipTitle = "5G Ultra Wideband is available in your area."
component.tooltipContent = "$799.99 (128 GB only)"
component.tooltipModel = .init(title: "Check the formatting of your address",
content:"House/Building number then street name")
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}