From 956db9f66332efb724cb6564f1b84d796ff2f70b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 1 Nov 2022 15:16:33 -0500 Subject: [PATCH] added textLink Signed-off-by: Matt Bruce --- VDSSample.xcodeproj/project.pbxproj | 4 + .../ViewControllers/MenuViewController.swift | 1 + VDSSample/ViewControllers/TextLink.swift | 87 +++++++++++++++++++ .../ToggleViewController.swift | 2 +- 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 VDSSample/ViewControllers/TextLink.swift diff --git a/VDSSample.xcodeproj/project.pbxproj b/VDSSample.xcodeproj/project.pbxproj index 145e934..d26b820 100644 --- a/VDSSample.xcodeproj/project.pbxproj +++ b/VDSSample.xcodeproj/project.pbxproj @@ -55,6 +55,7 @@ EA89205128B68307006B9984 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89205028B68307006B9984 /* TextField.swift */; }; EAB1D2C928AAAA1D00DAE764 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2C828AAAA1D00DAE764 /* BaseViewController.swift */; }; EAB1D2D428AC409F00DAE764 /* LabelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */; }; + EAC9258029119FC400091998 /* TextLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAC9257F29119FC400091998 /* TextLink.swift */; }; EAF7F07D2899698800B287F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F07B2899698800B287F5 /* Assets.xcassets */; }; EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */; }; EAF7F0CA289DA24F00B287F5 /* ArtifactoryItems.txt in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C5289DA24F00B287F5 /* ArtifactoryItems.txt */; }; @@ -118,6 +119,7 @@ EA89205028B68307006B9984 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = ""; }; EAB1D2C828AAAA1D00DAE764 /* BaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = ""; }; EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelViewController.swift; sourceTree = ""; }; + EAC9257F29119FC400091998 /* TextLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextLink.swift; sourceTree = ""; }; EAF7F07B2899698800B287F5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxViewController.swift; sourceTree = ""; }; EAF7F0C5289DA24F00B287F5 /* ArtifactoryItems.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ArtifactoryItems.txt; sourceTree = ""; }; @@ -256,6 +258,7 @@ EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */, EAF7F11928A14A0E00B287F5 /* RadioButtonViewController.swift */, EA84F76128BE4AE500D67ABC /* RadioSwatchGroupViewController.swift */, + EAC9257F29119FC400091998 /* TextLink.swift */, EA3C3BB328996775000CA526 /* ToggleViewController.swift */, ); path = ViewControllers; @@ -420,6 +423,7 @@ EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */, EA89204E28B67332006B9984 /* CheckBoxGroupViewController.swift in Sources */, EA89204928B66CE2006B9984 /* KeyboardFrameChangeListening.swift in Sources */, + EAC9258029119FC400091998 /* TextLink.swift in Sources */, EAB1D2D428AC409F00DAE764 /* LabelViewController.swift in Sources */, EA89204B28B66CE2006B9984 /* ScrollViewKeyboardAvoider.swift in Sources */, EA84F76228BE4AE500D67ABC /* RadioSwatchGroupViewController.swift in Sources */, diff --git a/VDSSample/ViewControllers/MenuViewController.swift b/VDSSample/ViewControllers/MenuViewController.swift index 190e9f1..2ccd546 100644 --- a/VDSSample/ViewControllers/MenuViewController.swift +++ b/VDSSample/ViewControllers/MenuViewController.swift @@ -28,6 +28,7 @@ class MenuViewController: UITableViewController { MenuComponent(title: "RadioBoxGroup", viewController: RadioBoxGroupViewController.self), MenuComponent(title: "RadioSwatchGroup", viewController: RadioSwatchGroupViewController.self), //MenuComponent(title: "TextEntryField", viewController: TextEntryFieldViewController.self), + MenuComponent(title: "TextLink", viewController: TextLinkViewController.self), MenuComponent(title: "Toggle", viewController: ToggleViewController.self) ] diff --git a/VDSSample/ViewControllers/TextLink.swift b/VDSSample/ViewControllers/TextLink.swift new file mode 100644 index 0000000..2e69b4c --- /dev/null +++ b/VDSSample/ViewControllers/TextLink.swift @@ -0,0 +1,87 @@ +// +// TextLink.swift +// VDSSample +// +// Created by Matt Bruce on 11/1/22. +// + +import Foundation +import UIKit +import VDS +import VDSColorTokens + +class TextLinkViewController: BaseViewController { + + lazy var buttonSizePickerSelectorView = { + PickerSelectorView(title: "", + picker: self.picker, + items: ButtonSize.allCases) + }() + + var disabledSwitch = UISwitch() + var textField = TextField() + let textLink = TextLink() + + override func viewDidLoad() { + super.viewDidLoad() + let view = UIView() + view.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(textLink) + textLink.topAnchor.constraint(equalTo: view.topAnchor).isActive = true + textLink.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true + textLink.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true + addContentTopView(view: view) + + setupForm() + setupPicker() + setupModel() + } + + func setupForm(){ + addFormRow(label: "Surface", view: surfacePickerSelectorView) + addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Label", view: textField) + addFormRow(label: "Size", view: buttonSizePickerSelectorView) + + disabledSwitch + .publisher(for: .valueChanged) + .sink { [weak self] sender in + self?.textLink.disabled = sender.isOn + }.store(in: &subscribers) + + textField + .textPublisher + .sink { [weak self] text in + self?.textLink.text = text + }.store(in: &subscribers) + } + + func setupModel() { + textLink.text = "Text Link" + + textLink + .publisher(for: .touchUpInside) + .sink { control in + print("clicked me") + }.store(in: &subscribers) + + + //setup UI + surfacePickerSelectorView.text = textLink.surface.rawValue + disabledSwitch.isOn = textLink.disabled + textField.text = textLink.text + buttonSizePickerSelectorView.text = ButtonSize.large.rawValue + } + + func setupPicker(){ + + surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.textLink.surface = item + self?.contentTopView.backgroundColor = item.color + } + + buttonSizePickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.textLink.size = item + } + } +} diff --git a/VDSSample/ViewControllers/ToggleViewController.swift b/VDSSample/ViewControllers/ToggleViewController.swift index 3102e7f..1632ce8 100644 --- a/VDSSample/ViewControllers/ToggleViewController.swift +++ b/VDSSample/ViewControllers/ToggleViewController.swift @@ -26,7 +26,7 @@ class ToggleViewController: BaseViewController { }() var disabledSwitch = UISwitch() - var showTextSwitch = UISwitch() + var showTextSwitch = Toggle() var textFormStackView: UIStackView = { return UIStackView().with {