From 69ed21aa65425783a4579a753e80e4f776777bdc Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 19 Jun 2024 17:29:10 -0500 Subject: [PATCH] updated samples Signed-off-by: Matt Bruce --- VDSSample/Extensions/Bundle.swift | 2 +- .../ViewControllers/BaseViewController.swift | 2 +- .../CheckboxItemViewController.swift | 15 ++++++++++++--- .../RadioBoxGroupViewController.swift | 15 +++++++++++++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/VDSSample/Extensions/Bundle.swift b/VDSSample/Extensions/Bundle.swift index d73f7d7..f6ca51a 100644 --- a/VDSSample/Extensions/Bundle.swift +++ b/VDSSample/Extensions/Bundle.swift @@ -45,7 +45,7 @@ struct VDSHelper { return bundle.contents("ReleaseNotes") ?? "" } - static func changeLog(for component: ViewProtocol.Type) -> String? { + static func changeLog(for component: any ViewProtocol.Type) -> String? { return bundle.contents("\(component.self)ChangeLog") } } diff --git a/VDSSample/ViewControllers/BaseViewController.swift b/VDSSample/ViewControllers/BaseViewController.swift index 631eeac..6048bac 100644 --- a/VDSSample/ViewControllers/BaseViewController.swift +++ b/VDSSample/ViewControllers/BaseViewController.swift @@ -177,7 +177,7 @@ public class BaseViewController: UIViewController, Initable , open override func viewDidLoad() { super.viewDidLoad() - if let component = component as? ViewProtocol, let content = VDSHelper.changeLog(for: type(of: component)) { + if let component = component as? (any ViewProtocol), let content = VDSHelper.changeLog(for: type(of: component)) { let tooltip = VDS.Tooltip() tooltip.title = "ChangeLog" tooltip.content = content diff --git a/VDSSample/ViewControllers/CheckboxItemViewController.swift b/VDSSample/ViewControllers/CheckboxItemViewController.swift index 7bc3e8f..aba9883 100644 --- a/VDSSample/ViewControllers/CheckboxItemViewController.swift +++ b/VDSSample/ViewControllers/CheckboxItemViewController.swift @@ -71,10 +71,19 @@ class CheckboxItemViewController: BaseViewController { } func setupModel() { - component.labelText = "Terms and conditions" - component.childText = "I agree to Verizon's terms and conditions click here" + let fullText = "I accept the Terms and Conditions" + let linkText = "Terms and Conditions" component.errorText = "Error Text" - + component.childText = fullText + + if let link = ActionLabelAttribute(text: fullText, linkText: linkText) { + link.action.sink { [weak self] in + guard let self else { return } + present(UIAlertController(title: "TextLink", message: "Clicked \(linkText)", preferredStyle: .alert).with{ $0.addAction(.init(title: "OK", style: .default)) }, animated: true) + }.store(in: &subscribers) + component.childTextAttributes = [link] + } + //setup UI surfacePickerSelectorView.text = component.surface.rawValue disabledSwitch.isOn = !component.isEnabled diff --git a/VDSSample/ViewControllers/RadioBoxGroupViewController.swift b/VDSSample/ViewControllers/RadioBoxGroupViewController.swift index f795d45..fc458bf 100644 --- a/VDSSample/ViewControllers/RadioBoxGroupViewController.swift +++ b/VDSSample/ViewControllers/RadioBoxGroupViewController.swift @@ -78,8 +78,19 @@ class RadioBoxGroupViewController: BaseViewController{ radioBox2.inputId = "model2" radioBox2.value = "model 2 Value" radioBox2.text = "iPhone 11 Bundle 2" - radioBox2.subText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector" + let fullText = "I accept the Terms and Conditions" + let linkText = "Terms and Conditions" + radioBox2.subText = fullText + + if let link = ActionLabelAttribute(text: fullText, linkText: linkText) { + link.action.sink { [weak self] in + guard let self else { return } + present(UIAlertController(title: "TextLink", message: "Clicked \(linkText)", preferredStyle: .alert).with{ $0.addAction(.init(title: "OK", style: .default)) }, animated: true) + }.store(in: &subscribers) + radioBox2.subTextAttributes = [link] + } + component.selectorModels = [radioBox1, radioBox2] component.onChange = { [weak self] group in @@ -120,7 +131,7 @@ extension RadioBoxGroupViewController: ComponentSampleable { radioBox1.text = "iPhone 11 Bundle 1" radioBox1.subText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector" radioBox1.subTextRight = "Right Text" - + var radioBox2 = RadioBoxGroup.RadioBoxItemModel() radioBox2.inputId = "model2" radioBox2.value = "model 2 Value"