diff --git a/VDSSample/Classes/Helper.swift b/VDSSample/Classes/Helper.swift index 058ebd0..7fefee7 100644 --- a/VDSSample/Classes/Helper.swift +++ b/VDSSample/Classes/Helper.swift @@ -60,7 +60,16 @@ extension Changeable { } } -extension Clickable { +extension Clickable where Self: UIControl { + func onClickActionPublisher(_ text: String, label: UILabel) { + onClick = { _ in + let handler = labelPublisherCompletionHandler() + handler(text, label) + } + } +} + +extension Clickable where Self: UIView { func onClickActionPublisher(_ text: String, label: UILabel) { onClick = { _ in let handler = labelPublisherCompletionHandler() diff --git a/VDSSample/ViewControllers/TileContainerViewController.swift b/VDSSample/ViewControllers/TileContainerViewController.swift index b32e7d5..4edbace 100644 --- a/VDSSample/ViewControllers/TileContainerViewController.swift +++ b/VDSSample/ViewControllers/TileContainerViewController.swift @@ -127,8 +127,9 @@ class TileContainerViewController: BaseViewController { topLabel.text = "Do you want to Register?" let topButton = Button() - topButton.setTitle("Register", for: .normal) - + topButton.text = "Register" + topButton.onClick = { c in print("clicked \(c.text!)") } + ///bottom let bottomView = View() bottomView.backgroundColor = .green @@ -137,7 +138,8 @@ class TileContainerViewController: BaseViewController { bottomLabel.text = "Forgot your info?" let bottomButton = Button() - bottomButton.setTitle("Forgot Password", for: .normal) + bottomButton.text = "Forgot Password" + bottomButton.onClick = { c in print("clicked \(c.text!)") } mainView.addSubview(topView) mainView.addSubview(bottomView)