From 956db9f66332efb724cb6564f1b84d796ff2f70b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 1 Nov 2022 15:16:33 -0500 Subject: [PATCH 1/2] 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 { From dea0a1e6ea72ed2df6e8536cdde90e9048aaff18 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 2 Nov 2022 15:15:01 -0500 Subject: [PATCH 2/2] added textlinkcaret Signed-off-by: Matt Bruce --- VDSSample.xcodeproj/project.pbxproj | 12 ++- .../ViewControllers/MenuViewController.swift | 1 + .../TextLinkCaretViewController.swift | 87 +++++++++++++++++++ ...ink.swift => TextLinkViewController.swift} | 0 4 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 VDSSample/ViewControllers/TextLinkCaretViewController.swift rename VDSSample/ViewControllers/{TextLink.swift => TextLinkViewController.swift} (100%) diff --git a/VDSSample.xcodeproj/project.pbxproj b/VDSSample.xcodeproj/project.pbxproj index a76db7d..8f10825 100644 --- a/VDSSample.xcodeproj/project.pbxproj +++ b/VDSSample.xcodeproj/project.pbxproj @@ -33,6 +33,7 @@ /* Begin PBXBuildFile section */ 5FC35BE928D5235A004EBEAC /* ButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */; }; + EA0FC2C12912DC5500DF80B4 /* TextLinkCaretViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */; }; EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9C289966EF000CA526 /* AppDelegate.swift */; }; EA3C3B9F289966EF000CA526 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9E289966EF000CA526 /* SceneDelegate.swift */; }; EA3C3BA4289966EF000CA526 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EA3C3BA2289966EF000CA526 /* Main.storyboard */; }; @@ -56,7 +57,7 @@ EAA5EEAD28EB6924003B3210 /* TextEntryFieldViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEAC28EB6924003B3210 /* TextEntryFieldViewController.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 */; }; + EAC9258029119FC400091998 /* TextLinkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAC9257F29119FC400091998 /* TextLinkViewController.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 */; }; @@ -92,6 +93,7 @@ /* Begin PBXFileReference section */ 5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonViewController.swift; sourceTree = ""; }; + EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextLinkCaretViewController.swift; sourceTree = ""; }; EA3C3B99289966EF000CA526 /* VDSSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VDSSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; EA3C3B9C289966EF000CA526 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; EA3C3B9E289966EF000CA526 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -121,7 +123,7 @@ EAA5EEAC28EB6924003B3210 /* TextEntryFieldViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryFieldViewController.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 = ""; }; + EAC9257F29119FC400091998 /* TextLinkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextLinkViewController.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 = ""; }; @@ -261,7 +263,8 @@ EAF7F11928A14A0E00B287F5 /* RadioButtonViewController.swift */, EA84F76128BE4AE500D67ABC /* RadioSwatchGroupViewController.swift */, EAA5EEAC28EB6924003B3210 /* TextEntryFieldViewController.swift */, - EAC9257F29119FC400091998 /* TextLink.swift */, + EAC9257F29119FC400091998 /* TextLinkViewController.swift */, + EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */, EA3C3BB328996775000CA526 /* ToggleViewController.swift */, ); path = ViewControllers; @@ -423,11 +426,12 @@ EA89204728B66CE2006B9984 /* KeyboardFrameChangeListener.swift in Sources */, EA4DB30428DCD25B00103EE3 /* BadgeViewController.swift in Sources */, EA89204828B66CE2006B9984 /* ScrollViewKeyboardAvoiding.swift in Sources */, + EA0FC2C12912DC5500DF80B4 /* TextLinkCaretViewController.swift in Sources */, EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */, EA89204E28B67332006B9984 /* CheckBoxGroupViewController.swift in Sources */, EAA5EEAD28EB6924003B3210 /* TextEntryFieldViewController.swift in Sources */, EA89204928B66CE2006B9984 /* KeyboardFrameChangeListening.swift in Sources */, - EAC9258029119FC400091998 /* TextLink.swift in Sources */, + EAC9258029119FC400091998 /* TextLinkViewController.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 9f5efe3..96d9adf 100644 --- a/VDSSample/ViewControllers/MenuViewController.swift +++ b/VDSSample/ViewControllers/MenuViewController.swift @@ -29,6 +29,7 @@ class MenuViewController: UITableViewController { MenuComponent(title: "RadioSwatchGroup", viewController: RadioSwatchGroupViewController.self), MenuComponent(title: "TextEntryField", viewController: TextEntryFieldViewController.self), MenuComponent(title: "TextLink", viewController: TextLinkViewController.self), + MenuComponent(title: "TextLinkCaret", viewController: TextLinkCaretViewController.self), MenuComponent(title: "Toggle", viewController: ToggleViewController.self) ] diff --git a/VDSSample/ViewControllers/TextLinkCaretViewController.swift b/VDSSample/ViewControllers/TextLinkCaretViewController.swift new file mode 100644 index 0000000..f9c66b0 --- /dev/null +++ b/VDSSample/ViewControllers/TextLinkCaretViewController.swift @@ -0,0 +1,87 @@ +// +// TextLinkCaretViewController.swift +// VDSSample +// +// Created by Matt Bruce on 11/2/22. +// + +import Foundation +import UIKit +import VDS +import VDSColorTokens + +class TextLinkCaretViewController: BaseViewController { + + lazy var caretPositionPickerSelectorView = { + PickerSelectorView(title: "", + picker: self.picker, + items: TextLinkCaretPosition.allCases) + }() + + var disabledSwitch = UISwitch() + var textField = TextField() + let textLinkCaret = TextLinkCaret() + + override func viewDidLoad() { + super.viewDidLoad() + let view = UIView() + view.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(textLinkCaret) + textLinkCaret.topAnchor.constraint(equalTo: view.topAnchor).isActive = true + textLinkCaret.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true + textLinkCaret.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: "Caret Position", view: caretPositionPickerSelectorView) + + disabledSwitch + .publisher(for: .valueChanged) + .sink { [weak self] sender in + self?.textLinkCaret.disabled = sender.isOn + }.store(in: &subscribers) + + textField + .textPublisher + .sink { [weak self] text in + self?.textLinkCaret.text = text + }.store(in: &subscribers) + } + + func setupModel() { + textLinkCaret.text = "Text Link" + + textLinkCaret + .publisher(for: .touchUpInside) + .sink { control in + print("clicked me") + }.store(in: &subscribers) + + + //setup UI + surfacePickerSelectorView.text = textLinkCaret.surface.rawValue + disabledSwitch.isOn = textLinkCaret.disabled + textField.text = textLinkCaret.text + caretPositionPickerSelectorView.text = textLinkCaret.iconPosition.rawValue + } + + func setupPicker(){ + + surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.textLinkCaret.surface = item + self?.contentTopView.backgroundColor = item.color + } + + caretPositionPickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.textLinkCaret.iconPosition = item + } + } +} diff --git a/VDSSample/ViewControllers/TextLink.swift b/VDSSample/ViewControllers/TextLinkViewController.swift similarity index 100% rename from VDSSample/ViewControllers/TextLink.swift rename to VDSSample/ViewControllers/TextLinkViewController.swift