From bcb6bbf7cfb482d11a9ec056b01e8cebbd2ec850 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 29 Mar 2023 14:11:53 -0500 Subject: [PATCH 1/3] updated ui Signed-off-by: Matt Bruce --- VDSSample/Classes/Helper.swift | 25 +++++++++---------- VDSSample/Protocols/PickerBase.swift | 18 ++++++------- .../CheckboxViewController.swift | 2 +- .../TileContainerViewController.swift | 13 ++++------ .../TileletViewController.swift | 10 ++++---- 5 files changed, 31 insertions(+), 37 deletions(-) diff --git a/VDSSample/Classes/Helper.swift b/VDSSample/Classes/Helper.swift index ae446bd..de7b63a 100644 --- a/VDSSample/Classes/Helper.swift +++ b/VDSSample/Classes/Helper.swift @@ -24,21 +24,20 @@ extension UIView { } } -extension ButtonBase { +extension Clickable where Self: ButtonBase { func labelPublisher(_ label: UILabel){ - onClickSubscriber = publisher(for: .touchUpInside) - .sink { control in - let newText = "\(control.text!) clicked - " - if let labelText = label.text { - let components = labelText.components(separatedBy: " - ") - let last: String = (components.last ?? "0").trimmingCharacters(in: .whitespaces) - let count = Int(last)! - label.text = "\(newText)\(count+1)" - } else { - label.text = "\(newText)1" - } - print("clicked me") + onClick = { control in + let newText = "\(control.text!) clicked - " + if let labelText = label.text { + let components = labelText.components(separatedBy: " - ") + let last: String = (components.last ?? "0").trimmingCharacters(in: .whitespaces) + let count = Int(last)! + label.text = "\(newText)\(count+1)" + } else { + label.text = "\(newText)1" } + print("clicked me") + } } } diff --git a/VDSSample/Protocols/PickerBase.swift b/VDSSample/Protocols/PickerBase.swift index a674209..d589d37 100644 --- a/VDSSample/Protocols/PickerBase.swift +++ b/VDSSample/Protocols/PickerBase.swift @@ -74,16 +74,14 @@ public class PickerSelectorView: UIStackView, Picker updateSelectedIndex() addArrangedSubview(label) addArrangedSubview(button) - button - .publisher(for: .touchUpInside) - .sink { [weak self] _ in - self?.picker?.delegate = self - self?.picker?.dataSource = self - self?.picker?.reloadAllComponents() - self?.picker?.selectRow(self?.selectedIndex ?? 0, inComponent: 0, animated: false) - self?.picker?.isHidden = false - self?.scrollToBottom?() - }.store(in: &subscribers) + button.onClick = { [weak self] _ in + self?.picker?.delegate = self + self?.picker?.dataSource = self + self?.picker?.reloadAllComponents() + self?.picker?.selectRow(self?.selectedIndex ?? 0, inComponent: 0, animated: false) + self?.picker?.isHidden = false + self?.scrollToBottom?() + } } func updateSelectedIndex() { diff --git a/VDSSample/ViewControllers/CheckboxViewController.swift b/VDSSample/ViewControllers/CheckboxViewController.swift index 3682077..3325694 100644 --- a/VDSSample/ViewControllers/CheckboxViewController.swift +++ b/VDSSample/ViewControllers/CheckboxViewController.swift @@ -19,7 +19,7 @@ class CheckboxViewController: BaseViewController { var errorTextField = TextField() var showErrorSwitch = Toggle() - var checkbox = SoloCheckbox() + var checkbox = Checkbox() override func viewDidLoad() { super.viewDidLoad() diff --git a/VDSSample/ViewControllers/TileContainerViewController.swift b/VDSSample/ViewControllers/TileContainerViewController.swift index 7f249c0..d9d72fd 100644 --- a/VDSSample/ViewControllers/TileContainerViewController.swift +++ b/VDSSample/ViewControllers/TileContainerViewController.swift @@ -36,7 +36,6 @@ class TileContainerViewController: BaseViewController { }() var clickableSwitch = Toggle() - var clickableCancel: AnyCancellable? var showBackgroundImageSwitch = Toggle() var showBorderSwitch = Toggle() @@ -78,15 +77,13 @@ class TileContainerViewController: BaseViewController { clickableSwitch .publisher(for: .valueChanged) .sink { [weak self] sender in + guard let self else { return } if sender.isOn { - self?.clickableCancel = self?.tileContainer - .publisher(for: .touchUpInside) - .sink(receiveValue: { _ in - print("you click on me!") - }) + self.tileContainer.onClick = { _ in + print("you click on me!") + } } else { - self?.clickableCancel?.cancel() - self?.clickableCancel = nil + self.tileContainer.onClick = nil } }.store(in: &subscribers) diff --git a/VDSSample/ViewControllers/TileletViewController.swift b/VDSSample/ViewControllers/TileletViewController.swift index 23533b8..d3e5ed5 100644 --- a/VDSSample/ViewControllers/TileletViewController.swift +++ b/VDSSample/ViewControllers/TileletViewController.swift @@ -79,13 +79,13 @@ class TileletViewController: BaseViewController { .sink { [weak self] sender in guard let tilelet = self?.tilelet else { return } if sender.isOn { - tilelet.onClickSubscriber = tilelet.publisher(for: .touchUpInside) - .sink(receiveValue: { _ in - print("you click on me!") - }) + tilelet.onClick = { t in + print("you click on me!") + } + } else { + tilelet.onClick = nil } }.store(in: &subscribers) - widthTextField .textPublisher .sink { [weak self] text in From fa502dca98ea768bd67e1a8828aeb1210cce0bdb Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 29 Mar 2023 15:48:54 -0500 Subject: [PATCH 2/3] showing onCloseClick in console Signed-off-by: Matt Bruce --- VDSSample/ViewControllers/NotificationViewController.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/VDSSample/ViewControllers/NotificationViewController.swift b/VDSSample/ViewControllers/NotificationViewController.swift index 2700606..330321e 100644 --- a/VDSSample/ViewControllers/NotificationViewController.swift +++ b/VDSSample/ViewControllers/NotificationViewController.swift @@ -57,6 +57,10 @@ class NotificationViewController: BaseViewController { addFormRow(label: "First Button Text", view: firstButtonTextField) addFormRow(label: "Second Button Text", view: secondButtonTextField) + notificationView.onCloseClick = { notification in + print("onCloseClick: \(notification.titleText)") + } + titleTextField.textPublisher.sink { newString in self.notificationView.titleText = newString }.store(in: &subscribers) From 645c7d5815e058265f1bcb002e42748f7d6ac288 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 30 Mar 2023 10:12:37 -0500 Subject: [PATCH 3/3] updated Signed-off-by: Matt Bruce --- VDSSample/Classes/Helper.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDSSample/Classes/Helper.swift b/VDSSample/Classes/Helper.swift index de7b63a..22611ef 100644 --- a/VDSSample/Classes/Helper.swift +++ b/VDSSample/Classes/Helper.swift @@ -24,7 +24,7 @@ extension UIView { } } -extension Clickable where Self: ButtonBase { +extension ButtonBase { func labelPublisher(_ label: UILabel){ onClick = { control in let newText = "\(control.text!) clicked - "