diff --git a/VDSSample.xcodeproj/project.pbxproj b/VDSSample.xcodeproj/project.pbxproj index eb5c277..397c175 100644 --- a/VDSSample.xcodeproj/project.pbxproj +++ b/VDSSample.xcodeproj/project.pbxproj @@ -44,6 +44,7 @@ EA3C3BB728996775000CA526 /* ToggleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3BB328996775000CA526 /* ToggleViewController.swift */; }; EA4DB30428DCD25B00103EE3 /* BadgeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4DB30328DCD25B00103EE3 /* BadgeViewController.swift */; }; EA5E3050294D11540082B959 /* TileContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5E304F294D11540082B959 /* TileContainerViewController.swift */; }; + EA5E30552950EA6E0082B959 /* TitleLockupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5E30542950EA6E0082B959 /* TitleLockupViewController.swift */; }; EA84F76228BE4AE500D67ABC /* RadioSwatchGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA84F76128BE4AE500D67ABC /* RadioSwatchGroupViewController.swift */; }; EA89201928B56DF5006B9984 /* RadioBoxGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */; }; EA89204628B66CE2006B9984 /* ScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89203F28B66CE2006B9984 /* ScrollViewController.swift */; }; @@ -109,6 +110,7 @@ EA3C3BB328996775000CA526 /* ToggleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToggleViewController.swift; sourceTree = ""; }; EA4DB30328DCD25B00103EE3 /* BadgeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeViewController.swift; sourceTree = ""; }; EA5E304F294D11540082B959 /* TileContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileContainerViewController.swift; sourceTree = ""; }; + EA5E30542950EA6E0082B959 /* TitleLockupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleLockupViewController.swift; sourceTree = ""; }; EA84F76128BE4AE500D67ABC /* RadioSwatchGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatchGroupViewController.swift; sourceTree = ""; }; EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxGroupViewController.swift; sourceTree = ""; }; EA89203F28B66CE2006B9984 /* ScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollViewController.swift; sourceTree = ""; }; @@ -256,6 +258,7 @@ EAC9257F29119FC400091998 /* TextLinkViewController.swift */, EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */, EA5E304F294D11540082B959 /* TileContainerViewController.swift */, + EA5E30542950EA6E0082B959 /* TitleLockupViewController.swift */, EA3C3BB328996775000CA526 /* ToggleViewController.swift */, ); path = ViewControllers; @@ -401,6 +404,7 @@ buildActionMask = 2147483647; files = ( EA3C3BB728996775000CA526 /* ToggleViewController.swift in Sources */, + EA5E30552950EA6E0082B959 /* TitleLockupViewController.swift in Sources */, EAB5FEEF2927E28400998C17 /* ButtonGroupViewController.swift in Sources */, EA89204C28B66CE2006B9984 /* ScrollWrapperView.swift in Sources */, EA89205128B68307006B9984 /* TextField.swift in Sources */, diff --git a/VDSSample/ViewControllers/MenuViewController.swift b/VDSSample/ViewControllers/MenuViewController.swift index 3805f7f..f128d07 100644 --- a/VDSSample/ViewControllers/MenuViewController.swift +++ b/VDSSample/ViewControllers/MenuViewController.swift @@ -84,6 +84,7 @@ class MenuViewController: UITableViewController { MenuComponent(title: "TextLink", completed: true, viewController: TextLinkViewController.self), MenuComponent(title: "TextLinkCaret", completed: true, viewController: TextLinkCaretViewController.self), MenuComponent(title: "TileContainer", completed: false, viewController: TileContainerViewController.self), + MenuComponent(title: "TitleLockup", completed: true, viewController: TitleLockupViewController.self), MenuComponent(title: "Toggle", completed: true, viewController: ToggleViewController.self) ] diff --git a/VDSSample/ViewControllers/TitleLockupViewController.swift b/VDSSample/ViewControllers/TitleLockupViewController.swift new file mode 100644 index 0000000..a3304b7 --- /dev/null +++ b/VDSSample/ViewControllers/TitleLockupViewController.swift @@ -0,0 +1,127 @@ +// +// TitleLockupViewController.swift +// VDSSample +// +// Created by Matt Bruce on 12/19/22. +// + +import Foundation +import UIKit +import VDS +import VDSColorTokens + +class TitleLockupViewController: BaseViewController { + + lazy var textPositionPickerSelectorView = { + PickerSelectorView(title: "left", + picker: self.picker, + items: TitleLockupTextPosition.allCases) + }() + + lazy var titleTextStylePickerSelectorView = { + PickerSelectorView(title: "", + picker: self.picker, + items: TitleLockupitleTypographicalStyle.allCases.sorted{ $0.rawValue < $1.rawValue }) + }() + + lazy var otherTextStylePickerSelectorView = { + PickerSelectorView(title: "", + picker: self.picker, + items: TitleLockupOtherTypographicalStyle.allCases.sorted{ $0.rawValue < $1.rawValue }) + }() + + lazy var subtitleColorPickerSelectorView = { + PickerSelectorView(title: "", + picker: self.picker, + items: [.primary, .secondary]) + }() + + var eyebrowTextField = TextField() + var titleTextField = TextField() + var subTitleTextField = TextField() + + var titleLockup = TitleLockup() + + override func viewDidLoad() { + super.viewDidLoad() + addContentTopView(view: titleLockup) + + setupForm() + setupPicker() + setupModel() + } + + override func allTextFields() -> [UITextField]? { [eyebrowTextField, titleTextField, subTitleTextField] } + + func setupForm(){ + addFormRow(label: "Surface", view: surfacePickerSelectorView) + addFormRow(label: "Text Position", view: textPositionPickerSelectorView) + + addFormRow(label: "Title Style", view: titleTextStylePickerSelectorView) + addFormRow(label: "Other Style", view: otherTextStylePickerSelectorView) + + addFormRow(label: "Eyebrow Text", view: eyebrowTextField) + addFormRow(label: "Title Text", view: titleTextField) + + addFormRow(label: "Subtitle Color", view: subtitleColorPickerSelectorView) + addFormRow(label: "Subtitle Text", view: subTitleTextField) + + eyebrowTextField + .textPublisher + .sink { [weak self] text in + self?.titleLockup.eyebrowText = text + }.store(in: &subscribers) + + titleTextField + .textPublisher + .sink { [weak self] text in + self?.titleLockup.titleText = text + }.store(in: &subscribers) + + subTitleTextField + .textPublisher + .sink { [weak self] text in + self?.titleLockup.subTitleText = text + }.store(in: &subscribers) + } + + func setupModel() { + titleLockup.eyebrowText = "Today only." + titleLockup.titleText = "Get more of our best" + titleLockup.subTitleText = "Get both of our best and pay less. Pair 5G Home Internet with Verizon mobile to save every month." + + //setup UI + surfacePickerSelectorView.text = titleLockup.surface.rawValue + textPositionPickerSelectorView.text = titleLockup.textPosition.rawValue + otherTextStylePickerSelectorView.text = titleLockup.otherTypograpicalStyle.rawValue + titleTextStylePickerSelectorView.text = titleLockup.titleTypograpicalStyle.rawValue + subtitleColorPickerSelectorView.text = titleLockup.subTitleColor.rawValue + eyebrowTextField.text = titleLockup.eyebrowText + titleTextField.text = titleLockup.titleText + subTitleTextField.text = titleLockup.subTitleText + } + + //Picker + func setupPicker(){ + surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.titleLockup.surface = item + self?.contentTopView.backgroundColor = item.color + } + + textPositionPickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.titleLockup.textPosition = item + } + + titleTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.titleLockup.titleTypograpicalStyle = item + } + + otherTextStylePickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.titleLockup.otherTypograpicalStyle = item + } + + subtitleColorPickerSelectorView.onPickerDidSelect = { [weak self] item in + self?.titleLockup.subTitleColor = item + } + } +}