// // Helper.swift // VDSSample // // Created by Matt Bruce on 11/18/22. // import Foundation import VDS import UIKit extension UIView { public static func makeWrapper(for view: UIView) -> UIView { let wrapper = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false } wrapper.addSubview(view) view .pinTop() .pinBottom() .pinLeading() view.trailingAnchor.constraint(lessThanOrEqualTo: wrapper.trailingAnchor).isActive = true return wrapper } } extension BaseViewController { func makeButton(_ text: String) -> Button { return Button().with{ $0.text = text $0.publisher(for: .touchUpInside) .sink { [weak self] control in let alertController:UIAlertController = UIAlertController(title: "Alert", message: "\(control.text!) Clicked", preferredStyle: UIAlertController.Style.alert) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil)) self?.present(alertController, animated: true) print("clicked me") }.store(in: &subscribers) } } func makeTextLink(_ text: String) -> TextLink { return TextLink().with{ $0.text = text $0.publisher(for: .touchUpInside) .sink { [weak self] control in let alertController:UIAlertController = UIAlertController(title: "Alert", message: "\(control.text!) Clicked", preferredStyle: UIAlertController.Style.alert) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil)) self?.present(alertController, animated: true) print("clicked me") }.store(in: &subscribers) } } func makeTextLinkCaret(_ text: String) -> TextLinkCaret { return TextLinkCaret().with{ $0.text = text $0.publisher(for: .touchUpInside) .sink { [weak self] control in let alertController:UIAlertController = UIAlertController(title: "Alert", message: "\(control.text!) Clicked", preferredStyle: UIAlertController.Style.alert) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:nil)) self?.present(alertController, animated: true) print("clicked me") }.store(in: &subscribers) } } }