Compare commits

..

No commits in common. "develop" and "feature/monarch" have entirely different histories.

53 changed files with 1158 additions and 2481 deletions

View File

@ -32,17 +32,10 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
180636CB2C29B12B00C92D86 /* InputStepperViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 180636CA2C29B12B00C92D86 /* InputStepperViewController.swift */; };
1808BEBE2BA4479500129230 /* CarouselScrollbarViewConttroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1808BEBD2BA4479500129230 /* CarouselScrollbarViewConttroller.swift */; };
1832AC5B2BA1347B008AE476 /* BreadcrumbsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1832AC5A2BA1347B008AE476 /* BreadcrumbsViewController.swift */; };
183B16F52C80B27C00BA6A10 /* FootnoteGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 183B16F42C80B27C00BA6A10 /* FootnoteGroupViewController.swift */; };
184023492C61E9E700A412C8 /* PriceLockupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 184023482C61E9E700A412C8 /* PriceLockupViewController.swift */; };
1859B3152CBF77B30031CD70 /* ListUnorderedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1859B3142CBF77B30031CD70 /* ListUnorderedViewController.swift */; };
186D13CD2BBA990800986B53 /* DropdownSelectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 186D13CC2BBA990800986B53 /* DropdownSelectViewController.swift */; };
18926F5F2C76185A00C55BF6 /* FootnoteItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18926F5E2C76185A00C55BF6 /* FootnoteItemViewController.swift */; };
18A3F1302BD9332500498E4A /* CalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18A3F12F2BD9332500498E4A /* CalendarViewController.swift */; };
18AE87522C06FDD60075F181 /* CarouselViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18AE87512C06FDD60075F181 /* CarouselViewController.swift */; };
18C0F9482C98177F00E1DD71 /* ModalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18C0F9472C98177F00E1DD71 /* ModalViewController.swift */; };
440B84CC2BD8E98B004A732A /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440B84CB2BD8E98B004A732A /* TableViewController.swift */; };
445BA07A29C088470036A7C5 /* NotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 445BA07929C088470036A7C5 /* NotificationViewController.swift */; };
44604AD929CE1CF900E62B51 /* LineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44604AD829CE1CF900E62B51 /* LineViewController.swift */; };
@ -53,6 +46,8 @@
EA0D1C332A673FD400E5C127 /* RadioButtonItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */; };
EA0FC2C12912DC5500DF80B4 /* TextLinkCaretViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */; };
EA1758462BC8893700A5C0D9 /* DatePickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1758452BC8893700A5C0D9 /* DatePickerViewController.swift */; };
EA21C5D82B600E4200CFC139 /* VDSTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA21C5D72B600E4200CFC139 /* VDSTokens.xcframework */; };
EA21C5D92B600E4200CFC139 /* VDSTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EA21C5D72B600E4200CFC139 /* VDSTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
EA297A682A02F5320031ED56 /* TableViewTestController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA297A672A02F5320031ED56 /* TableViewTestController.swift */; };
EA3C3B9D289966EF000CA526 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9C289966EF000CA526 /* AppDelegate.swift */; };
EA3C3B9F289966EF000CA526 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B9E289966EF000CA526 /* SceneDelegate.swift */; };
@ -108,7 +103,6 @@
EAF7F0CC289DA24F00B287F5 /* DownloadArtifactoryItems.sh in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C8289DA24F00B287F5 /* DownloadArtifactoryItems.sh */; };
EAF7F0CD289DA24F00B287F5 /* Artifactory.sh in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C9289DA24F00B287F5 /* Artifactory.sh */; };
EAF7F11A28A14A0E00B287F5 /* RadioButtonGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F11928A14A0E00B287F5 /* RadioButtonGroupViewController.swift */; };
EAFD5A9D2CB4609900C87DE1 /* TokenColorPickerFormSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAFD5A9C2CB4609900C87DE1 /* TokenColorPickerFormSection.swift */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -137,17 +131,10 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
180636CA2C29B12B00C92D86 /* InputStepperViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputStepperViewController.swift; sourceTree = "<group>"; };
1808BEBD2BA4479500129230 /* CarouselScrollbarViewConttroller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselScrollbarViewConttroller.swift; sourceTree = "<group>"; };
1832AC5A2BA1347B008AE476 /* BreadcrumbsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BreadcrumbsViewController.swift; sourceTree = "<group>"; };
183B16F42C80B27C00BA6A10 /* FootnoteGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FootnoteGroupViewController.swift; sourceTree = "<group>"; };
184023482C61E9E700A412C8 /* PriceLockupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PriceLockupViewController.swift; sourceTree = "<group>"; };
1859B3142CBF77B30031CD70 /* ListUnorderedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListUnorderedViewController.swift; sourceTree = "<group>"; };
186D13CC2BBA990800986B53 /* DropdownSelectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropdownSelectViewController.swift; sourceTree = "<group>"; };
18926F5E2C76185A00C55BF6 /* FootnoteItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FootnoteItemViewController.swift; sourceTree = "<group>"; };
18A3F12F2BD9332500498E4A /* CalendarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarViewController.swift; sourceTree = "<group>"; };
18AE87512C06FDD60075F181 /* CarouselViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselViewController.swift; sourceTree = "<group>"; };
18C0F9472C98177F00E1DD71 /* ModalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalViewController.swift; sourceTree = "<group>"; };
440B84CB2BD8E98B004A732A /* TableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = "<group>"; };
445BA07929C088470036A7C5 /* NotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationViewController.swift; sourceTree = "<group>"; };
44604AD829CE1CF900E62B51 /* LineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineViewController.swift; sourceTree = "<group>"; };
@ -216,7 +203,6 @@
EAF7F0C8289DA24F00B287F5 /* DownloadArtifactoryItems.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = DownloadArtifactoryItems.sh; sourceTree = "<group>"; };
EAF7F0C9289DA24F00B287F5 /* Artifactory.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = Artifactory.sh; sourceTree = "<group>"; };
EAF7F11928A14A0E00B287F5 /* RadioButtonGroupViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonGroupViewController.swift; sourceTree = "<group>"; };
EAFD5A9C2CB4609900C87DE1 /* TokenColorPickerFormSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenColorPickerFormSection.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -295,7 +281,6 @@
EAB5FEF22928153D00998C17 /* Helper.swift */,
EAD062A42A3B5CDF0015965D /* Slider.swift */,
EA89205028B68307006B9984 /* TextField.swift */,
EAFD5A9C2CB4609900C87DE1 /* TokenColorPickerFormSection.swift */,
);
path = Classes;
sourceTree = "<group>";
@ -345,26 +330,19 @@
EA81410D2A0ED8DC004F60D2 /* ButtonIconViewController.swift */,
5FC35BE828D5235A004EBEAC /* ButtonViewController.swift */,
18A3F12F2BD9332500498E4A /* CalendarViewController.swift */,
18AE87512C06FDD60075F181 /* CarouselViewController.swift */,
1808BEBD2BA4479500129230 /* CarouselScrollbarViewConttroller.swift */,
EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */,
EAF7F09B2899B92400B287F5 /* CheckboxItemViewController.swift */,
EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */,
EA1758452BC8893700A5C0D9 /* DatePickerViewController.swift */,
186D13CC2BBA990800986B53 /* DropdownSelectViewController.swift */,
18926F5E2C76185A00C55BF6 /* FootnoteItemViewController.swift */,
183B16F42C80B27C00BA6A10 /* FootnoteGroupViewController.swift */,
EA985C00296CC21C00F2FF2E /* IconViewController.swift */,
EAA5EEAC28EB6924003B3210 /* InputFieldViewController.swift */,
180636CA2C29B12B00C92D86 /* InputStepperViewController.swift */,
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */,
44604AD829CE1CF900E62B51 /* LineViewController.swift */,
1859B3142CBF77B30031CD70 /* ListUnorderedViewController.swift */,
EAD0688F2A55FC11002E3A2D /* LoaderViewController.swift */,
18C0F9472C98177F00E1DD71 /* ModalViewController.swift */,
445BA07929C088470036A7C5 /* NotificationViewController.swift */,
71B23C302B921D730027F7D9 /* PaginationViewController.swift */,
184023482C61E9E700A412C8 /* PriceLockupViewController.swift */,
EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */,
EAF7F11928A14A0E00B287F5 /* RadioButtonGroupViewController.swift */,
EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */,
@ -373,8 +351,8 @@
EA5F86CD2A1E863F00BC83E4 /* TabsContainerViewController.swift */,
EA596AB92A16B2ED00300C4B /* TabsViewController.swift */,
EA985C24296E06EA00F2FF2E /* TextAreaViewController.swift */,
EAC9257F29119FC400091998 /* TextLinkViewController.swift */,
EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */,
EAC9257F29119FC400091998 /* TextLinkViewController.swift */,
EA5E304F294D11540082B959 /* TileContainerViewController.swift */,
EA5E305B295111050082B959 /* TileletViewController.swift */,
EA5E30542950EA6E0082B959 /* TitleLockupViewController.swift */,
@ -555,18 +533,14 @@
EAB2376C29E9E74900AABE9A /* TrailingTooltipLabelViewController.swift in Sources */,
EAB1D2C928AAAA1D00DAE764 /* BaseViewController.swift in Sources */,
EA1758462BC8893700A5C0D9 /* DatePickerViewController.swift in Sources */,
180636CB2C29B12B00C92D86 /* InputStepperViewController.swift in Sources */,
EAD062AD2A3B86950015965D /* BadgeIndicatorViewController.swift in Sources */,
EA5E305C295111050082B959 /* TileletViewController.swift in Sources */,
EAD062A32A3913920015965D /* DropShawdowViewController.swift in Sources */,
EA6642972BD1B2E700D81DC4 /* ColorPickerView.swift in Sources */,
EA0D1C312A673F3500E5C127 /* RadioButtonViewController.swift in Sources */,
EAFD5A9D2CB4609900C87DE1 /* TokenColorPickerFormSection.swift in Sources */,
EAB5FEF32928153D00998C17 /* Helper.swift in Sources */,
EA89204728B66CE2006B9984 /* KeyboardFrameChangeListener.swift in Sources */,
EA4DB30428DCD25B00103EE3 /* BadgeViewController.swift in Sources */,
1859B3152CBF77B30031CD70 /* ListUnorderedViewController.swift in Sources */,
18C0F9482C98177F00E1DD71 /* ModalViewController.swift in Sources */,
EAB2376029E88D5D00AABE9A /* TooltipViewController.swift in Sources */,
EA89204828B66CE2006B9984 /* ScrollViewKeyboardAvoiding.swift in Sources */,
EA0FC2C12912DC5500DF80B4 /* TextLinkCaretViewController.swift in Sources */,
@ -574,10 +548,8 @@
EAF7F09C2899B92400B287F5 /* CheckboxItemViewController.swift in Sources */,
EA0D1C2F2A66CFE900E5C127 /* CheckboxViewController.swift in Sources */,
18A3F1302BD9332500498E4A /* CalendarViewController.swift in Sources */,
18AE87522C06FDD60075F181 /* CarouselViewController.swift in Sources */,
EA596ABA2A16B2ED00300C4B /* TabsViewController.swift in Sources */,
EA89204E28B67332006B9984 /* CheckBoxGroupViewController.swift in Sources */,
183B16F52C80B27C00BA6A10 /* FootnoteGroupViewController.swift in Sources */,
EAA5EEAD28EB6924003B3210 /* InputFieldViewController.swift in Sources */,
440B84CC2BD8E98B004A732A /* TableViewController.swift in Sources */,
EA985C25296E06EA00F2FF2E /* TextAreaViewController.swift in Sources */,
@ -586,9 +558,7 @@
EA985C20296DECF600F2FF2E /* IconName.swift in Sources */,
EA89204928B66CE2006B9984 /* KeyboardFrameChangeListening.swift in Sources */,
EA5F86CE2A1E863F00BC83E4 /* TabsContainerViewController.swift in Sources */,
18926F5F2C76185A00C55BF6 /* FootnoteItemViewController.swift in Sources */,
EA985C01296CC21C00F2FF2E /* IconViewController.swift in Sources */,
184023492C61E9E700A412C8 /* PriceLockupViewController.swift in Sources */,
EAC9258029119FC400091998 /* TextLinkViewController.swift in Sources */,
EAD068902A55FC11002E3A2D /* LoaderViewController.swift in Sources */,
EAD062A52A3B5CDF0015965D /* Slider.swift in Sources */,
@ -745,7 +715,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 75;
CURRENT_PROJECT_VERSION = 66;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = FCMA4QKS77;
GENERATE_INFOPLIST_FILE = YES;
@ -781,7 +751,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 75;
CURRENT_PROJECT_VERSION = 66;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = FCMA4QKS77;
GENERATE_INFOPLIST_FILE = YES;

View File

@ -9,18 +9,14 @@ import Foundation
import UIKit
import VDS
public class ColorPickerView: UIStackView, UIColorPickerViewControllerDelegate {
public class ColorPickerView<EnumType>: UIStackView {
public var pickerType: EnumType
public var selectedColor: UIColor? {
didSet {
selectedColorView.backgroundColor = selectedColor
}
}
private var colorPicker: UIColorPickerViewController = {
let picker = UIColorPickerViewController()
return picker
}()
var selectedColorView: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
@ -35,23 +31,18 @@ public class ColorPickerView: UIStackView, UIColorPickerViewControllerDelegate {
$0.text = "Select"
}
/// Callback once the user picks a color from the picker.
public var onColorSelected: ((UIColor) -> Void)?
public init(color: UIColor? = nil) {
public init(with pickerType: EnumType, color: UIColor? = nil, onClick: @escaping (ColorPickerView)->Void) {
self.pickerType = pickerType
super.init(frame: .zero)
if let color {
selectedColor = color
}
colorPicker.delegate = self
setup()
button.onClick = { _ in
UIApplication.topViewController()?.present(self.colorPicker, animated: true)
}
button.onClick = { _ in onClick(self) }
}
required init(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
fatalError()
}
private func setup() {
@ -68,7 +59,6 @@ public class ColorPickerView: UIStackView, UIColorPickerViewControllerDelegate {
indicatorWrapper.pinTrailingGreaterThanOrEqualTo(anchor: indicatorWrapper.trailingAnchor)
addArrangedSubview(indicatorWrapper)
let buttonWrapper = View()
buttonWrapper.addSubview(button)
buttonWrapper.height(32)
@ -78,15 +68,4 @@ public class ColorPickerView: UIStackView, UIColorPickerViewControllerDelegate {
button.pinLeadingGreaterThanOrEqualTo(anchor: buttonWrapper.leadingAnchor)
addArrangedSubview(buttonWrapper)
}
// MARK: - UIColorPickerViewControllerDelegate
public func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
selectedColor = viewController.selectedColor
onColorSelected?(viewController.selectedColor)
}
public func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
UIApplication.topViewController()?.dismiss(animated: true)
}
}

View File

@ -10,15 +10,15 @@ import VDS
import UIKit
extension UIView {
public func makeWrapper(edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true, isBottom: Bool = false) -> View {
UIView.makeWrapper(for: self, edgeSpacing: edgeSpacing, isTrailing: isTrailing, isBottom: isBottom)
public func makeWrapper(edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true) -> View {
UIView.makeWrapper(for: self, edgeSpacing: edgeSpacing, isTrailing: isTrailing)
}
public static func makeWrapper(for view: UIView, edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true, isBottom: Bool = false) -> View {
makeWrapperWithConstraints(for: view, edgeSpacing: edgeSpacing, isTrailing: isTrailing, isBottom: isBottom).view
public static func makeWrapper(for view: UIView, edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true) -> View {
makeWrapperWithConstraints(for: view, edgeSpacing: edgeSpacing, isTrailing: isTrailing).view
}
public static func makeWrapperWithConstraints(for view: UIView, edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true, isBottom: Bool = false) -> (view: View, container: NSLayoutConstraint.Container) {
public static func makeWrapperWithConstraints(for view: UIView, edgeSpacing: CGFloat = 0.0, isTrailing: Bool = true) -> (view: View, container: NSLayoutConstraint.Container) {
let container = NSLayoutConstraint.Container()
let wrapper = View().with {
$0.translatesAutoresizingMaskIntoConstraints = false
@ -26,11 +26,7 @@ extension UIView {
wrapper.addSubview(view)
container.topConstraint = view.pinTop(anchor: wrapper.topAnchor, constant: edgeSpacing)
if isBottom {
container.bottomConstraint = view.pinBottomLessThanOrEqualTo(anchor: wrapper.bottomAnchor, constant: edgeSpacing)
} else {
container.bottomConstraint = view.pinBottom(anchor: wrapper.bottomAnchor, constant: edgeSpacing)
}
container.leadingConstraint = view.pinLeading(anchor: wrapper.leadingAnchor, constant: edgeSpacing)
if isTrailing {
container.trailingConstraint = view.pinTrailingLessThanOrEqualTo(anchor: wrapper.trailingAnchor, constant: edgeSpacing)
@ -64,16 +60,7 @@ extension Changeable {
}
}
extension Clickable where Self: UIControl {
func onClickActionPublisher(_ text: String, label: UILabel) {
onClick = { _ in
let handler = labelPublisherCompletionHandler()
handler(text, label)
}
}
}
extension Clickable where Self: UIView {
extension Clickable {
func onClickActionPublisher(_ text: String, label: UILabel) {
onClick = { _ in
let handler = labelPublisherCompletionHandler()

View File

@ -1,107 +0,0 @@
//
// TokenColorPickerFormSection.swift
// VDSSample
//
// Created by Matt Bruce on 10/7/24.
//
import Foundation
import UIKit
import VDS
public class TokenColorPickerSection<EnumType: RawRepresentable & CaseIterable>: FormSection where EnumType.RawValue == String {
//--------------------------------------------------
// MARK: - Private Properties
//--------------------------------------------------
private var picker: UIPickerView
private var rowTitle: String = "Color"
private var rowToolTip: Tooltip.TooltipModel?
///Handles VDS Color Selections
private var tokenColorRow: UIView?
private lazy var tokenColorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: UIColor.VDSColor.allCases)
.with { $0.text = UIColor.VDSColor.paletteBlack.rawValue }
}()
///Handles Custom Color picker selections
private var customColorRow: UIView?
private lazy var customColorView: ColorPickerView = {
.init(color: .black).with {
$0.onColorSelected = { [weak self] color in
guard let self else { return }
onColorSelected?(color)
}
}
}()
//--------------------------------------------------
// MARK: - Public Properties
//--------------------------------------------------
/// This is the 1st row that the user will pick from, again this enum has to contain "token" and "custom" otherwise it won't work well.
public lazy var pickerSelectorView = {
PickerSelectorView<EnumType>(title: "",
picker: picker,
items: EnumType.allCases as! [EnumType])
}()
public var selectedItem: EnumType { pickerSelectorView.selectedItem }
/// Callback for a non-token/non-color selection
public var onSelected: ((EnumType) -> Void)?
/// Callback after "token" is selected from the VDSColor array
public var onTokenSelected: ((UIColor.VDSColor) -> Void)?
/// Callback once the user picks a color from the picker.
public var onColorSelected: ((UIColor) -> Void)?
///Pass in a title and the reference for the picker
public init(title: String? = nil, rowTitle: String = "Color", rowTooltip: Tooltip.TooltipModel? = nil, picker: UIPickerView) {
self.picker = picker
super.init(frame: .zero)
self.title = title
self.rowTitle = rowTitle
self.rowToolTip = rowTooltip
setup()
}
required init(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public func setup() {
addFormRow(label: rowTitle, tooltip: rowToolTip, view: pickerSelectorView)
tokenColorRow = addFormRow(label: "Token", view: tokenColorView)
customColorRow = addFormRow(label: "Custom", view: customColorView)
tokenColorRow?.isHidden = true
customColorRow?.isHidden = true
pickerSelectorView.onPickerDidSelect = { [weak self] item in
guard let self else { return }
let isToken = item.rawValue == "token"
let isCustom = item.rawValue == "custom"
if isToken {
self.onTokenSelected?(self.tokenColorView.selectedItem)
} else if let selectedItem = self.customColorView.selectedColor, isCustom {
self.onColorSelected?(selectedItem)
} else {
self.onSelected?(item)
}
self.tokenColorRow?.isHidden = !isToken
self.customColorRow?.isHidden = !isCustom
}
tokenColorView.onPickerDidSelect = { [weak self] item in
guard let self else { return }
self.onTokenSelected?(item)
}
}
public func setDefault(value: EnumType) {
pickerSelectorView.set(item: value)
}
}

View File

@ -45,7 +45,7 @@ struct VDSHelper {
return bundle.contents("ReleaseNotes") ?? ""
}
static func changeLog(for component: any ViewProtocol.Type) -> String? {
static func changeLog(for component: ViewProtocol.Type) -> String? {
return bundle.contents("\(component.self)ChangeLog")
}
}

View File

@ -4,10 +4,10 @@
VERSION="2.0"
#Update onces stable
#APITOKEN=AKCp5cbwXBA2Rarq6WagmFFxQxcxsARGxSq5g1H8NaGm7837KTgwdWPqsp7FdgRa13B7AcpGN
#URL=https://oneartifactorycloud.verizon.com/artifactory/
#URL=https://oneartifactorycloud.verizon.com/artifactory
APITOKEN=AKCp5ZmHP8B1dkLtdSh23bMcWHtrWzoB3SfhoCNpEC5e3dKNhiKsn8TPMZQafXzm2qkeXFXE6
URL=https://oneartifactoryci.verizon.com/artifactory
URL=https://oneartifactoryprod.verizon.com/artifactory
LOCALPATH="${1}"
REMOTEPATH="${2}"

View File

@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "Icon on stone.png",
"filename" : "VZ-My-Verizon-iOS-1024x1024.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -37,46 +37,19 @@ class BadgeIndicatorViewController: BaseViewController<BadgeIndicator> {
items: BadgeIndicator.MaximumDigits.allCases)
}()
enum BorderColor: String, CaseIterable {
case `default`, token, custom
}
lazy var borderColorLightPickerSelectorView: TokenColorPickerSection = {
TokenColorPickerSection<BorderColor>(rowTitle: "Border Light",
picker: self.picker).with {
$0.onSelected = { [weak self] color in
guard let self else { return }
component.borderColorLight = nil
}
$0.onTokenSelected = { [weak self] color in
guard let self else { return }
component.borderColorLight = color.uiColor
}
$0.onColorSelected = { [weak self] color in
guard let self else { return }
component.borderColorLight = color
}
}
lazy var borderColorLightPickerSelectorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: UIColor.VDSColor.allCases)
}()
lazy var borderColorDarkPickerSelectorView : TokenColorPickerSection = {
TokenColorPickerSection<BorderColor>(rowTitle: "Border Dark",
picker: self.picker).with {
$0.onSelected = { [weak self] color in
guard let self else { return }
component.borderColorDark = nil
}
$0.onTokenSelected = { [weak self] color in
guard let self else { return }
component.borderColorDark = color.uiColor
}
$0.onColorSelected = { [weak self] color in
guard let self else { return }
component.borderColorDark = color
}
}
lazy var borderColorDarkPickerSelectorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: UIColor.VDSColor.allCases)
}()
var textField = NumericField()
var leadingCharacterTextField = TextField()
var accessibilityTextField = TextField()
@ -86,7 +59,7 @@ class BadgeIndicatorViewController: BaseViewController<BadgeIndicator> {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: .makeWrapper(for: component))
setupPicker()
setupModel()
}
@ -109,13 +82,13 @@ class BadgeIndicatorViewController: BaseViewController<BadgeIndicator> {
addFormRow(label: "Vertical Padding", view: verticalPaddingTextField)
addFormRow(label: "Fill Color", view: fillColorPickerSelectorView)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Hide Border", view: hideBorderSwitch, pinTrailing: false)
append(section: borderColorLightPickerSelectorView)
append(section: borderColorDarkPickerSelectorView)
addFormRow(label: "Hide Border", view: hideBorderSwitch)
addFormRow(label: "Border Light", view: borderColorLightPickerSelectorView)
addFormRow(label: "Border Dark", view: borderColorDarkPickerSelectorView)
addFormRow(label: "Size", view: textSizePickerSelectorView)
addFormRow(label: "Accessiblity Text", view: accessibilityTextField)
dotForm.addFormRow(label: "Hide Dot", view: hideDotSwitch, pinTrailing: false)
dotForm.addFormRow(label: "Hide Dot", view: hideDotSwitch)
dotForm.addFormRow(label: "Dot Size", view: dotSizeTextField)
numberedForm.addFormRow(label: "Leading Character", view: leadingCharacterTextField)
numberedForm.addFormRow(label: "Trailing Text", view: trailingTextField)
@ -200,6 +173,8 @@ class BadgeIndicatorViewController: BaseViewController<BadgeIndicator> {
fillColorPickerSelectorView.text = component.fillColor.rawValue
textSizePickerSelectorView.text = component.size.rawValue
maxDigitsPickerSelectorView.text = component.maximumDigits.rawValue
borderColorDarkPickerSelectorView.text = component.borderColorDark?.toVDSColor()?.rawValue ?? ""
borderColorLightPickerSelectorView.text = component.borderColorLight?.toVDSColor()?.rawValue ?? ""
textField.text = "\(component.number!)"
visibleForms()
}
@ -232,6 +207,14 @@ class BadgeIndicatorViewController: BaseViewController<BadgeIndicator> {
maxDigitsPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.maximumDigits = item
}
borderColorDarkPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.borderColorDark = item.uiColor
}
borderColorLightPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.borderColorLight = item.uiColor
}
}
}

View File

@ -37,13 +37,11 @@ class BadgeViewController: BaseViewController<Badge> {
}
}
enum FillColor: String, CaseIterable {
case red, yellow, green, orange, blue, black, white, token, custom
}
enum TextColor: String, CaseIterable {
case `default`, token, custom
}
lazy var fillColorPickerSelectorView = {
PickerSelectorView(title: "red",
picker: self.picker,
items: Badge.FillColor.allCases)
}()
lazy var numberOfLinesPickerSelectorView = {
PickerSelectorView(title: "one",
@ -56,71 +54,15 @@ class BadgeViewController: BaseViewController<Badge> {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: .makeWrapper(for: component))
setupPicker()
setupModel()
}
lazy var fillColorSection = {
TokenColorPickerSection<FillColor>(rowTitle: "Fill Color", picker: self.picker).with {
$0.onSelected = { [weak self] item in
guard let self else { return }
var fillColor: Badge.FillColor = .red
switch item {
case .red:
fillColor = .red
case .yellow:
fillColor = .yellow
case .green:
fillColor = .green
case .orange:
fillColor = .orange
case .blue:
fillColor = .blue
case .black:
fillColor = .black
case .white:
fillColor = .white
default:
break
}
component.fillColor = fillColor
}
$0.onTokenSelected = { [weak self] color in
guard let self else { return }
component.fillColor = .token(color)
}
$0.onColorSelected = { [weak self] color in
guard let self else { return }
component.fillColor = .custom(color)
}
}
}()
lazy var textColorSection = {
TokenColorPickerSection<TextColor>(rowTitle: "Text Color", picker: self.picker).with {
$0.onSelected = { [weak self] item in
guard let self else { return }
component.textColor = nil
}
$0.onTokenSelected = { [weak self] color in
guard let self else { return }
component.textColor = .token(color)
}
$0.onColorSelected = { [weak self] color in
guard let self else { return }
component.textColor = .custom(color)
}
}
}()
override func setupForm(){
super.setupForm()
addFormRow(label: "Fill Color", view: fillColorPickerSelectorView)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
append(section: fillColorSection)
append(section: textColorSection)
addFormRow(label: "Text", view: textField)
addFormRow(label: "Max Width", view: maxWidthTextField)
addFormRow(label: "Number of Lines", view: numberOfLinesPickerSelectorView)
@ -147,8 +89,6 @@ class BadgeViewController: BaseViewController<Badge> {
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
textField.text = component.text
fillColorSection.setDefault(value: .red)
textColorSection.setDefault(value: .default)
}
func setupPicker(){
@ -157,13 +97,24 @@ class BadgeViewController: BaseViewController<Badge> {
self?.component.surface = item
self?.contentTopView.backgroundColor = item.color
}
fillColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.fillColor = item
}
numberOfLinesPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.numberOfLines = item.intValue
}
}
}
extension BadgeViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component, trailingPinningType: .lessThanOrEqual)
let component = Self.makeComponent()
component.fillColor = .red
component.text = "Terms and conditions"
component.maxWidth = 70
component.numberOfLines = 3
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}

View File

@ -43,7 +43,7 @@ public class FormSection: UIStackView {
}
@discardableResult
open func addFormRow(label: String, tooltip: Tooltip.TooltipModel? = nil, view: UIView, pinTrailing: Bool = true) -> UIView {
open func addFormRow(label: String, tooltip: Tooltip.TooltipModel? = nil, view: UIView) -> UIView {
let formRow = UIStackView().with {
$0.translatesAutoresizingMaskIntoConstraints = false
$0.alignment = .fill
@ -63,7 +63,7 @@ public class FormSection: UIStackView {
}
formRow.addArrangedSubview(label)
formRow.addArrangedSubview(pinTrailing ? view : .makeWrapper(for: view))
formRow.addArrangedSubview(view)
addArrangedSubview(formRow)
return formRow
@ -177,7 +177,7 @@ public class BaseViewController<Component: UIView>: UIViewController, Initable ,
open override func viewDidLoad() {
super.viewDidLoad()
if let component = component as? (any ViewProtocol), let content = VDSHelper.changeLog(for: type(of: component)) {
if let component = component as? ViewProtocol, let content = VDSHelper.changeLog(for: type(of: component)) {
let tooltip = VDS.Tooltip()
tooltip.title = "ChangeLog"
tooltip.content = content
@ -252,16 +252,8 @@ public class BaseViewController<Component: UIView>: UIViewController, Initable ,
NotificationCenter.default.publisher(for: UIAccessibility.voiceOverStatusDidChangeNotification).sink { [weak self] _ in
if UIAccessibility.isVoiceOverRunning {
if let component = self?.component {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in
guard let self else { return }
loadCustomRotors()
if let rotors = component.accessibilityCustomRotors {
if var accessibilityCustomRotors {
accessibilityCustomRotors.append(contentsOf: rotors)
} else {
accessibilityCustomRotors = rotors
}
}
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self?.loadCustomRotors()
UIAccessibility.post(notification: .screenChanged, argument: component)
}
}
@ -311,7 +303,7 @@ public class BaseViewController<Component: UIView>: UIViewController, Initable ,
}
public func setupForm() {
addFormRow(label: "Show Bounds", view: debugViewSwitch, pinTrailing: false)
addFormRow(label: "Show Bounds", view: debugViewSwitch)
}
let actionLabel = Label()
@ -334,34 +326,10 @@ public class BaseViewController<Component: UIView>: UIViewController, Initable ,
viewController.didMove(toParent: self)
}
var componentTrailingEqualConstraint: NSLayoutConstraint?
var componentTrailingLessThanEqualConstraint: NSLayoutConstraint?
open func addContentTopView(view: UIView, edgeSpacing: CGFloat = 16.0, pinTrailing: Bool = true) {
open func addContentTopView(view: UIView, edgeSpacing: CGFloat = 16.0) {
view.translatesAutoresizingMaskIntoConstraints = false
contentTopView.addSubview(view)
componentTrailingEqualConstraint = view.pinTrailing(anchor: contentTopView.trailingAnchor, constant: edgeSpacing)?.deactivate()
componentTrailingLessThanEqualConstraint = view.pinTrailingLessThanOrEqualTo(anchor: contentTopView.trailingAnchor, constant: edgeSpacing)?.deactivate()
view
.pinTop(edgeSpacing)
.pinLeading(edgeSpacing)
.pinBottom(edgeSpacing)
if pinTrailing {
componentTrailingEqualConstraint?.activate()
} else {
componentTrailingLessThanEqualConstraint?.activate()
}
}
open func updateComponentConstraint(pinTrailing: Bool = true) {
componentTrailingEqualConstraint?.deactivate()
componentTrailingLessThanEqualConstraint?.deactivate()
if pinTrailing {
componentTrailingEqualConstraint?.activate()
} else {
componentTrailingLessThanEqualConstraint?.activate()
}
view.pinToSuperView(.uniform(edgeSpacing))
}
open func append(section: FormSection) {
@ -369,8 +337,8 @@ public class BaseViewController<Component: UIView>: UIViewController, Initable ,
}
@discardableResult
open func addFormRow(label: String, tooltip: Tooltip.TooltipModel? = nil, view: UIView, pinTrailing: Bool = true) -> UIView {
return formStackView.addFormRow(label: label,tooltip: tooltip, view: view, pinTrailing: pinTrailing)
open func addFormRow(label: String, tooltip: Tooltip.TooltipModel? = nil, view: UIView) -> UIView {
return formStackView.addFormRow(label: label,tooltip: tooltip, view: view)
}
var activeTextField: UITextField?

View File

@ -48,8 +48,8 @@ class BreadcrumbsViewController: BaseViewController<Breadcrumbs> {
override func setupForm(){
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Last Crumb Selected", view: selectedSwitch, pinTrailing: false)
addFormRow(label: "No Long Breadcrumbs", view: sampleSwitch, pinTrailing: false)
addFormRow(label: "Last Crumb Selected", view: selectedSwitch)
addFormRow(label: "No Long Breadcrumbs", view: sampleSwitch)
selectedSwitch.onChange = { [weak self] sender in
guard let self else { return }

View File

@ -111,7 +111,7 @@ class ButtonGroupViewController: BaseViewController<ButtonGroup> {
super.setupForm()
addActionRow()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Alignment", view: buttonAlignmentSelectorView)
addFormRow(label: "Width", view: widthTextField)
addFormRow(label: "Row Quantity", view: rowQuantitySelectorView)

View File

@ -71,67 +71,61 @@ class ButtonIconViewController: BaseViewController<ButtonIcon> {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
setupPicker()
setupModel()
}
var badgeIndicatorFormStackView = FormSection().with { $0.isHidden = true; $0.title = "Badge Indicator" }
var badgeIndicatorFormStackView = FormSection().with { $0.isHidden = true }
///ColorPicker
lazy var lightColorPicker: ColorPickerView = {
return .init().with {
$0.onColorSelected = { [weak self] _ in
guard let self else { return }
updateColors()
var colorPickerType: ColorPickerType = .light
enum ColorPickerType {
case light, dark
}
lazy var colorPicker: UIColorPickerViewController = {
let picker = UIColorPickerViewController()
picker.delegate = self
return picker
}()
lazy var lightColorPicker: ColorPickerView<ColorPickerType> = {
return .init(with: ColorPickerType.light) {[weak self] picker in
self?.colorPickerType = picker.pickerType
self?.selectedColorTapped(picker)
}
}()
lazy var darkColorPicker: ColorPickerView = {
return .init().with {
$0.onColorSelected = { [weak self] _ in
guard let self else { return }
updateColors()
}
return .init(with: ColorPickerType.dark) {[weak self] picker in
self?.colorPickerType = picker.pickerType
self?.selectedColorTapped(picker)
}
}()
func updateColors() {
if let selectedLightColor = lightColorPicker.selectedColor {
component.selectedIconColorConfiguration = .init(selectedLightColor, selectedLightColor)
} else if let selectedDarkColor = darkColorPicker.selectedColor,
let selectedLightColor = lightColorPicker.selectedColor {
component.selectedIconColorConfiguration = .init(selectedLightColor, selectedDarkColor)
}
}
override func setupForm(){
super.setupForm()
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Surface Type", view: surfaceTypePickerSelectorView)
addFormRow(label: "Size", view: sizePickerSelectorView)
addFormRow(label: "Kind", view: kindPickerSelectorView)
addFormRow(label: "Floating", view: floating, pinTrailing: false)
addFormRow(label: "Hide Border", view: hideBorder, pinTrailing: false)
addFormRow(label: "Fit To Icon", view: fitToIcon, pinTrailing: false)
addFormRow(label: "Selected Light", view: lightColorPicker)
addFormRow(label: "Selected Dark", view: darkColorPicker)
addFormRow(label: "Floating", view: floating)
addFormRow(label: "Hide Border", view: hideBorder)
addFormRow(label: "Fit To Icon", view: fitToIcon)
addFormRow(label: "Name", view: namePickerSelectorView)
addFormRow(label: "Selected Icon Name", view: selectedIconNamePickerSelectorView)
addFormRow(label: "Selectable", view: selectableSwitch)
addFormRow(label: "X Offset", view: centerX)
addFormRow(label: "Y Offset", view: centerY)
append(section: .init().with {
$0.title = "Select State"
$0.addFormRow(label: "Selectable", view: selectableSwitch, pinTrailing: false)
$0.addFormRow(label: "Selected Icon Name", view: selectedIconNamePickerSelectorView)
$0.addFormRow(label: "Selected Light", view: lightColorPicker)
$0.addFormRow(label: "Selected Dark", view: darkColorPicker)
})
addFormRow(label: "Show Badge Indicator", view: badgeIndicatorSwitch, pinTrailing: false)
//badgeIndicator section
addFormRow(label: "Show Badge Indicator", view: badgeIndicatorSwitch)
badgeIndicatorFormStackView.addFormRow(label: "Expand Direction", view: badgeIndicatorExpandDirectionPickerSelectorView)
badgeIndicatorFormStackView.addFormRow(label: "Badge Variants", view: variantOneSwitch, pinTrailing: false)
badgeIndicatorFormStackView.addFormRow(label: "Badge Variants", view: variantOneSwitch)
badgeIndicatorFormStackView.addFormRow(label: "Custom X offset", view: customBadgeIndicatorXField)
badgeIndicatorFormStackView.addFormRow(label: "Custom Y offset", view: customBadgeIndicatorYField)
@ -224,8 +218,7 @@ class ButtonIconViewController: BaseViewController<ButtonIcon> {
func setupModel() {
let name = Icon.Name.addToFavorite
let selectedName = Icon.Name.addedToFavorite
component.selectedIconName = selectedName
component.iconName = name
component.onChange = { c in print("changed: \(c.isSelected)") }
//setup UI
@ -234,7 +227,6 @@ class ButtonIconViewController: BaseViewController<ButtonIcon> {
kindPickerSelectorView.text = component.kind.rawValue
sizePickerSelectorView.text = component.size.rawValue
namePickerSelectorView.text = name.rawValue
selectedIconNamePickerSelectorView.text = selectedName.rawValue
disabledSwitch.isOn = !component.isEnabled
badgeIndicatorExpandDirectionPickerSelectorView.text = ButtonIcon.BadgeIndicatorModel.ExpandDirection.right.rawValue
}
@ -316,3 +308,27 @@ extension ButtonIconViewController: ComponentSampleable {
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}
extension ButtonIconViewController: UIColorPickerViewControllerDelegate {
func selectedColorTapped(_ picker: ColorPickerView<ColorPickerType>) {
let selectedColor = picker.selectedColor
if let selectedColor {
colorPicker.selectedColor = selectedColor
}
present(colorPicker, animated: true)
}
func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
dismiss(animated: true)
}
func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
let color = viewController.selectedColor
let selectedColorPickerView = colorPickerType == .dark ? darkColorPicker : lightColorPicker
selectedColorPickerView.selectedColor = color
if let selectedDarkColor = darkColorPicker.selectedColor, let selectedLightColor = lightColorPicker.selectedColor {
component.selectedIconColorConfiguration = .init(selectedLightColor, selectedDarkColor)
}
}
}

View File

@ -32,7 +32,7 @@ class ButtonViewController: BaseViewController<Button> {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
setupPicker()
setupModel()
@ -43,7 +43,7 @@ class ButtonViewController: BaseViewController<Button> {
addFormRow(label: "Action", view: label)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Use", view: usePickerSelectorView)
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Text", view: textField)
addFormRow(label: "Width", view: widthTextField)
addFormRow(label: "Percentage (1-100)", view: percentageTextField)

View File

@ -47,6 +47,13 @@ class CalendarViewController: BaseViewController<CalendarBase> {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component)
component.minDate = Date().startOfMonth
component.maxDate = Date().endOfMonth
component.onChange = { [weak self] control in
self?.label.text = DateFormatter.localizedString(from: control.selectedDate, dateStyle: .short, timeStyle: .none)
}
minDatePicker.date = component.minDate
maxDatePicker.date = component.maxDate
setupPicker()
setupModel()
}
@ -76,20 +83,20 @@ class CalendarViewController: BaseViewController<CalendarBase> {
//add form rows
addFormRow(label: "onChange", view: label)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Hide Container Border", view: containerBorderSwitch, pinTrailing: false)
addFormRow(label: "Hide Current Date Indicator", view: hideCurrentDateIndicatorSwitch, pinTrailing: false)
addFormRow(label: "Hide Container Border", view: containerBorderSwitch)
addFormRow(label: "Hide Current Date Indicator", view: hideCurrentDateIndicatorSwitch)
addFormRow(label: "Min Date", view: minDatePicker)
addFormRow(label: "Max Date", view: maxDatePicker)
addFormRow(label: "Transparent Background", view: transparentBgSwitch, pinTrailing: false)
addFormRow(label: "Transparent Background", view: transparentBgSwitch)
addFormRow(label: "Active Dates", view: activeDatesField)
addFormRow(label: "Select ActiveDate", view: activeDatePicker)
addFormRow(label: "Clear Active Dates", view: clearActiveDatesSwitch, pinTrailing: false)
addFormRow(label: "Clear Active Dates", view: clearActiveDatesSwitch)
addFormRow(label: "Inactive Dates", view: inactiveDatesField)
addFormRow(label: "Select InActiveDate", view: inactiveDatePicker)
addFormRow(label: "Clear Inactive Dates", view: clearInactiveDatesSwitch, pinTrailing: false)
addFormRow(label: "Indicator One", view: indicatorOneSwitch, pinTrailing: false)
addFormRow(label: "Indicator Two", view: indicatorTwoSwitch, pinTrailing: false)
addFormRow(label: "Indicator Three", view: indicatorThreeSwitch, pinTrailing: false)
addFormRow(label: "Clear Inactive Dates", view: clearInactiveDatesSwitch)
addFormRow(label: "Indicator One", view: indicatorOneSwitch)
addFormRow(label: "Indicator Two", view: indicatorTwoSwitch)
addFormRow(label: "Indicator Three", view: indicatorThreeSwitch)
addFormRow(label: "Legend One", view: legendOneField)
addFormRow(label: "Legend Two", view: legendTwoField)
addFormRow(label: "Legend Three", view: legendThreeField)
@ -199,13 +206,6 @@ class CalendarViewController: BaseViewController<CalendarBase> {
func setupModel() {
let calendar = Calendar.current
let indicatorDate = calendar.startOfDay(for: calendar.date(byAdding: .day, value: 1, to: Date())!)
component.minDate = Date().startOfMonth
component.maxDate = Date().endOfMonth
component.onChange = { [weak self] control in
self?.label.text = DateFormatter.localizedString(from: control.selectedDate, dateStyle: .short, timeStyle: .none)
}
minDatePicker.date = component.minDate
maxDatePicker.date = component.maxDate
component.indicators = indicators
legendOneField.text = "Due Date"
legendTwoField.text = "Auto Pay"
@ -303,11 +303,3 @@ class CalendarViewController: BaseViewController<CalendarBase> {
return day
}
}
extension CalendarViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.viewDidLoad()
return ComponentSample(component: c.component, edgeInset: .init(top: 16, left: 0, bottom: 16, right: 0))
}
}

View File

@ -114,7 +114,7 @@ class CarouselScrollbarViewConttroller: BaseViewController<CarouselScrollbar> {
}
layoutPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.layout = item
self?.component.selectedLayout = item
self?.component.position = Int(self?.positionTextField.text ?? "1") ?? 1
}
}

View File

@ -1,229 +0,0 @@
//
// CarouselViewController.swift
// VDSSample
//
// Created by Kanamarlapudi, Vasavi on 29/05/24.
//
import Foundation
import UIKit
import VDS
import Combine
import VDSCoreTokens
class CarouselViewController: BaseViewController<Carousel> {
let label = Label()
lazy var paginationDisplayPickerSelectorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: Carousel.PaginationDisplay.allCases)
}()
lazy var peekPickerSelectorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: Carousel.Peek.allCases)
}()
lazy var gutterPickerSelectorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: Carousel.Gutter.allCases)
}()
lazy var layoutPickerSelectorView = {
PickerSelectorView(title: "1UP",
picker: self.picker,
items: UIDevice.isIPad ? CarouselScrollbar.Layout.allCases : [CarouselScrollbar.Layout.oneUP, CarouselScrollbar.Layout.twoUP, CarouselScrollbar.Layout.threeUP])
}()
lazy var paginationKindPickerSelectorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: ButtonIcon.Kind.allCases)
}()
lazy var horizAlignmtPickerSelectorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: Carousel.Horizontal.allCases)
}()
lazy var vertAlignmtPickerSelectorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: Carousel.Vertical.allCases)
}()
var paginationFloatingSwitch = Toggle()
var paginationInsetField = NumericField()
var selectedIndexField = NumericField()
var rows: [UIView] = []
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component)
setupPicker()
setupModel()
}
override func setupForm() {
super.setupForm()
//add form rows
addFormRow(label: "onChange", view: label)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Pagination Display", view: paginationDisplayPickerSelectorView)
addFormRow(label: "Peek", view: peekPickerSelectorView)
addFormRow(label: "Gutter", view: gutterPickerSelectorView)
addFormRow(label: "Layout", view: layoutPickerSelectorView)
// addFormRow(label: "Selected Group Index", view: selectedIndexField)
addFormRow(label: "Pagination Kind", view: paginationKindPickerSelectorView)
addFormRow(label: "Pagination Float", view: paginationFloatingSwitch, pinTrailing: false)
addFormRow(label: "Pagination Inset", view: paginationInsetField)
addFormRow(label: "Slot Horizontal Alignment", view: horizAlignmtPickerSelectorView)
addFormRow(label: "Slot Vertical Alignment", view: vertAlignmtPickerSelectorView)
selectedIndexField
.numberPublisher
.sink { [weak self] number in
if let number, number.intValue >= 0 {
self?.component.groupIndex = number.intValue
} else {
self?.component.groupIndex = 0
}
}.store(in: &subscribers)
paginationInsetField
.numberPublisher
.sink { [weak self] number in
if let number {
self?.component.paginationInset = number.cgFloatValue
} else {
self?.component.paginationInset = UIDevice.isIPad ? VDSLayout.space3X : VDSLayout.space2X
}
}.store(in: &subscribers)
paginationFloatingSwitch.onChange = { [weak self] sender in
guard let self else { return }
self.component.pagination = .init(kind: paginationKindPickerSelectorView.selectedItem, floating: sender.isOn)
}
}
func setupModel() {
//setup UI
paginationDisplayPickerSelectorView.text = component.paginationDisplay.rawValue
peekPickerSelectorView.text = component.peek.rawValue
gutterPickerSelectorView.text = component.gutter.rawValue
layoutPickerSelectorView.text = component.layout.rawValue
paginationKindPickerSelectorView.text = ButtonIcon.Kind.lowContrast.rawValue
paginationFloatingSwitch.isOn = true
paginationInsetField.text = UIDevice.isIPad ? "12" : "8"
let onClick: (ButtonBase) -> Void = { button in print("\(button.text!) clicked")}
rows.append(Label().with { $0.text = "Offer you best deals on phones, tablets, home, internet and more. Pre order the new version mobiles and get off *T&C apply."; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping})
rows.append(Button().with{ $0.use = .secondary; $0.text = "Secondary"; $0.onClick = onClick})
rows.append(Label().with { $0.text = "Get iPhone 15 on us. Online only. "; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping})
rows.append(Button().with{ $0.use = .primary; $0.text = "Primary"; $0.onClick = onClick})
rows.append(Label().with { $0.text = "Unlimited plans. No trade-in required."; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping})
rows.append(Label().with { $0.text = "With trade-in. Any condition guaranteed"; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping})
rows.append(Button().with{ $0.use = .primary; $0.text = "More"; $0.onClick = onClick})
rows.append(Button().with{ $0.use = .secondary; $0.text = "Shop"; $0.onClick = onClick})
rows.append(Button().with{ $0.use = .secondary; $0.text = "Buy"; $0.onClick = onClick})
rows.append(Button().with{ $0.use = .secondary; $0.text = "Offer"; $0.onClick = onClick})
label.text = "0"
component.slotAlignment = .init(vertical: Carousel.Vertical.top, horizontal: Carousel.Horizontal.left)
horizAlignmtPickerSelectorView.text = Carousel.Horizontal.left.rawValue
vertAlignmtPickerSelectorView.text = Carousel.Vertical.top.rawValue
updateCarousel()
// Callback when moving the carousel. Returns selectedGroupIndex.
component.onChange = { [weak self] selectedGroupIndex in
guard let self else { return }
label.text = "\(selectedGroupIndex)"
}
}
func updateCarousel() {
component.views = rows.compactMap({ view in
return TileContainer().with { instance in
instance.aspectRatio = .none
instance.addContentView(view)
instance.color = .custom(.lightGray)
}
})
}
func setupPicker() {
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.surface = item
self?.contentTopView.backgroundColor = item.color
}
paginationDisplayPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.paginationDisplay = item
if (self?.component.peek == Carousel.Peek.none) && item == .none {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.0) {
self?.paginationDisplayPickerSelectorView.text = "persistent"
}
}
}
peekPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.peek = item
if item == .none {
self?.paginationDisplayPickerSelectorView.text = "persistent"
} else if item == .minimum && UIDevice.isIPad {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.0) {
self?.peekPickerSelectorView.text = "standard"
}
} else if item == .standard && !UIDevice.isIPad && (self?.component.layout != CarouselScrollbar.Layout.oneUP) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.0) {
self?.peekPickerSelectorView.text = "minimum"
}
}
}
gutterPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.gutter = item
self?.updateCarousel()
}
layoutPickerSelectorView.onPickerDidSelect = { [weak self] item in
if item != .oneUP && !UIDevice.isIPad && self?.component.peek == Carousel.Peek.standard {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.0) {
self?.peekPickerSelectorView.text = "minimum"
}
}
self?.component.layout = item
self?.label.text = "0"
self?.updateCarousel()
}
paginationKindPickerSelectorView.onPickerDidSelect = { [weak self] item in
guard let self else { return }
self.component.pagination = .init(kind: item, floating: paginationFloatingSwitch.isOn)
}
vertAlignmtPickerSelectorView.onPickerDidSelect = { [weak self] item in
guard let self else { return }
self.component.slotAlignment = .init(vertical: item, horizontal: horizAlignmtPickerSelectorView.selectedItem)
}
horizAlignmtPickerSelectorView.onPickerDidSelect = { [weak self] item in
guard let self else { return }
self.component.slotAlignment = .init(vertical: vertAlignmtPickerSelectorView.selectedItem, horizontal: item)
}
}
}
extension CarouselViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
}
}

View File

@ -31,11 +31,11 @@ class CheckboxGroupViewController: BaseViewController<CheckboxGroup> {
override func setupForm(){
super.setupForm()
addActionRow()
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Label Text", view: labelTextField)
addFormRow(label: "Child Text", view: childTextField)
addFormRow(label: "Error", view: showErrorSwitch, pinTrailing: false)
addFormRow(label: "Error", view: showErrorSwitch)
showErrorSwitch.onChange = { [weak self] sender in
self?.component.showError = sender.isOn
@ -138,6 +138,6 @@ extension CheckboxGroupViewController: ComponentSampleable {
component.selectorModels = [checkbox1, checkbox2]
return ComponentSample(component: component)
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}

View File

@ -30,11 +30,11 @@ class CheckboxItemViewController: BaseViewController<CheckboxItem> {
override func setupForm(){
super.setupForm()
addActionRow()
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Label Text", view: labelTextField)
addFormRow(label: "Child Text", view: childTextField)
addFormRow(label: "Error", view: showErrorSwitch, pinTrailing: false)
addFormRow(label: "Error", view: showErrorSwitch)
addFormRow(label: "Error Text", view: errorTextField)
showErrorSwitch.onChange = { [weak self] sender in
@ -71,18 +71,9 @@ class CheckboxItemViewController: BaseViewController<CheckboxItem> {
}
func setupModel() {
let fullText = "I accept the Terms and Conditions"
let linkText = "Terms and Conditions"
component.labelText = "Terms and conditions"
component.childText = "I agree to Verizon's terms and conditions click here"
component.errorText = "Error Text"
component.childText = fullText
if let link = ActionLabelAttribute(text: fullText, linkText: linkText) {
link.action.sink { [weak self] in
guard let self else { return }
present(UIAlertController(title: "TextLink", message: "Clicked \(linkText)", preferredStyle: .alert).with{ $0.addAction(.init(title: "OK", style: .default)) }, animated: true)
}.store(in: &subscribers)
component.childTextAttributes = [link]
}
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
@ -110,6 +101,6 @@ extension CheckboxItemViewController: ComponentSampleable {
component.childText = "I agree to Verizon's terms and conditions click here"
component.errorText = "Error Text"
return ComponentSample(component: component)
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}

View File

@ -18,7 +18,7 @@ class CheckboxViewController: BaseViewController<Checkbox> {
let toggle = UISwitch()
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
setupPicker()
setupModel()
}
@ -26,12 +26,10 @@ class CheckboxViewController: BaseViewController<Checkbox> {
override func setupForm(){
super.setupForm()
addActionRow()
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Error", view: showErrorSwitch, pinTrailing: false)
addFormRow(label: "Calendar", view: VDS.DatePicker().with {
$0.calendarModel = .init(minDate: Date().startOfMonth, maxDate: Calendar.current.date(byAdding: .month, value: 2, to: Date())!)
})
addFormRow(label: "Error", view: showErrorSwitch)
showErrorSwitch.onChange = { [weak self] sender in
guard let self else { return }
self.component.showError = sender.isOn

View File

@ -80,50 +80,19 @@ class DatePickerViewController: BaseViewController<DatePicker> {
override func setupForm(){
addFormRow(label: "onChange", view: label)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Read Only", view: readonlySwitch, pinTrailing: false)
addFormRow(label: "Required", view: requiredSwitch, pinTrailing: false)
addFormRow(label: "Transparent Background", view: transparentBgSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Read Only", view: readonlySwitch)
addFormRow(label: "Required", view: requiredSwitch)
addFormRow(label: "Transparent Background", view: transparentBgSwitch)
addFormRow(label: "Date Format", view: dateFormatPickerSelectorView)
addFormRow(label: "Label Text", view: labelTextField)
addFormRow(label: "Helper Text", view: helperTextField)
addFormRow(label: "Error", view: errorSwitch, pinTrailing: false)
addFormRow(label: "Error", view: .makeWrapper(for: errorSwitch))
addFormRow(label: "Error Text", view: errorTextField)
addFormRow(label: "Width", view: widthTextField)
addFormRow(label: "ToolTip Title", view: tooltipTitleTextField)
addFormRow(label: "ToolTip Content", view: tooltipContentTextField)
append(section: getCalendarSection())
append(section: .init().with({
func datePicker() -> VDS.DatePicker {
VDS.DatePicker().with {
$0.calendarModel = .init(minDate: Date().startOfMonth, maxDate: Calendar.current.date(byAdding: .month, value: 2, to: Date())!)
}
}
$0.title = "UI Testing"
$0.addFormRow(label: "Below Test", view: datePicker())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Test Space", view: View())
$0.addFormRow(label: "Above Test", view: datePicker())
}))
disabledSwitch.onChange = { [weak self] sender in
self?.component.isEnabled = !sender.isOn
}
@ -171,7 +140,6 @@ class DatePickerViewController: BaseViewController<DatePicker> {
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
self?.component.width = number?.cgFloatValue
}.store(in: &subscribers)
@ -186,6 +154,7 @@ class DatePickerViewController: BaseViewController<DatePicker> {
.sink { [weak self] text in
self?.updateTooltip()
}.store(in: &subscribers)
}
func setupModel() {
@ -239,19 +208,19 @@ extension DatePickerViewController {
func getCalendarSection() -> FormSection {
let section = FormSection()
section.title = "Calendar Options"
section.addFormRow(label: "Hide Container Border", view: containerBorderSwitch, pinTrailing: false)
section.addFormRow(label: "Hide Current Date Indicator", view: hideCurrentDateIndicatorSwitch, pinTrailing: false)
section.addFormRow(label: "Hide Container Border", view: containerBorderSwitch)
section.addFormRow(label: "Hide Current Date Indicator", view: hideCurrentDateIndicatorSwitch)
section.addFormRow(label: "Min Date", view: minDatePicker)
section.addFormRow(label: "Max Date", view: maxDatePicker)
section.addFormRow(label: "Active Dates", view: activeDatesField)
section.addFormRow(label: "Select ActiveDate", view: activeDatePicker)
section.addFormRow(label: "Clear Active Dates", view: clearActiveDatesSwitch, pinTrailing: false)
section.addFormRow(label: "Clear Active Dates", view: clearActiveDatesSwitch)
section.addFormRow(label: "Inactive Dates", view: inactiveDatesField)
section.addFormRow(label: "Select InActiveDate", view: inactiveDatePicker)
section.addFormRow(label: "Clear Inactive Dates", view: clearInactiveDatesSwitch, pinTrailing: false)
section.addFormRow(label: "Indicator One", view: indicatorOneSwitch, pinTrailing: false)
section.addFormRow(label: "Indicator Two", view: indicatorTwoSwitch, pinTrailing: false)
section.addFormRow(label: "Indicator Three", view: indicatorThreeSwitch, pinTrailing: false)
section.addFormRow(label: "Clear Inactive Dates", view: clearInactiveDatesSwitch)
section.addFormRow(label: "Indicator One", view: indicatorOneSwitch)
section.addFormRow(label: "Indicator Two", view: indicatorTwoSwitch)
section.addFormRow(label: "Indicator Three", view: indicatorThreeSwitch)
section.addFormRow(label: "Legend One", view: legendOneField)
section.addFormRow(label: "Legend Two", view: legendTwoField)
section.addFormRow(label: "Legend Three", view: legendThreeField)
@ -259,6 +228,7 @@ extension DatePickerViewController {
section.addFormRow(label: "Indicator Two Date", view: indicatorTwoPicker)
section.addFormRow(label: "Indicator Three Date", view: indicatorThreePicker)
containerBorderSwitch.onChange = { [weak self] sender in
self?.updateCalendarModel()
}
@ -337,7 +307,8 @@ extension DatePickerViewController {
}
func updateCalendarModel() {
component.calendarModel = .init(hideContainerBorder: containerBorderSwitch.isOn,
component.calendarModel = .init(surface: component.surface,
hideContainerBorder: containerBorderSwitch.isOn,
hideCurrentDateIndicator: hideCurrentDateIndicatorSwitch.isOn,
activeDates: activeDates,
inactiveDates: inactiveDates,
@ -480,12 +451,3 @@ extension DatePickerViewController {
}
}
extension DatePickerViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
c.setupCalendar()
return ComponentSample(component: c.component)
}
}

View File

@ -64,20 +64,20 @@ class DropdownSelectViewController: BaseViewController<DropdownSelect> {
override func setupForm(){
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Read Only", view: readonlySwitch, pinTrailing: false)
addFormRow(label: "Required", view: requiredSwitch, pinTrailing: false)
addFormRow(label: "Transparent Background", view: transparentBgSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Read Only", view: readonlySwitch)
addFormRow(label: "Required", view: requiredSwitch)
addFormRow(label: "Transparent Background", view: transparentBgSwitch)
addFormRow(label: "Label Text", view: labelTextField)
addFormRow(label: "Helper Text Placement", view: helperTextPlacementPickerSelectorView)
addFormRow(label: "Helper Text", view: helperTextField)
addFormRow(label: "Inline Label", view: inlineLabelSwitch, pinTrailing: false)
addFormRow(label: "Error", view: errorSwitch, pinTrailing: false)
addFormRow(label: "Inline Label", view: .makeWrapper(for: inlineLabelSwitch))
addFormRow(label: "Error", view: .makeWrapper(for: errorSwitch))
addFormRow(label: "Error Text", view: errorTextField)
addFormRow(label: "Width", view: widthTextField)
addFormRow(label: "ToolTip Title", view: tooltipTitleTextField)
addFormRow(label: "ToolTip Content", view: tooltipContentTextField)
addFormRow(label: "More Options", view: optionsSwitch, pinTrailing: false)
addFormRow(label: "More Options", view: optionsSwitch)
disabledSwitch.onChange = { [weak self] sender in
self?.component.isEnabled = !sender.isOn
@ -131,7 +131,6 @@ class DropdownSelectViewController: BaseViewController<DropdownSelect> {
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
self?.component.width = number?.cgFloatValue
}.store(in: &subscribers)

View File

@ -1,79 +0,0 @@
//
// FootnoteGroupViewController.swift
// VDSSample
//
// Created by Kanamarlapudi, Vasavi on 29/08/24.
//
import Foundation
import UIKit
import VDS
class FootnoteGroupViewController: BaseViewController<FootnoteGroup> {
var widthTextField = NumericField()
var percentageTextField = NumericField()
var footnotes: [FootnoteItem] = []
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component)
setupPicker()
setupModel()
}
override func setupForm() {
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Width", view: widthTextField)
addFormRow(label: "Percentage (1-100)", view: percentageTextField)
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number {
self?.component.width = .value(number.cgFloatValue)
self?.percentageTextField.text = ""
} else {
self?.component.width = nil
}
}.store(in: &subscribers)
percentageTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number, number.intValue > 9 {
self?.component.width = .percentage(number.cgFloatValue)
self?.widthTextField.text = ""
} else {
self?.component.width = nil
}
}.store(in: &subscribers)
}
func setupModel() {
let toolTipModel = Tooltip.TooltipModel.init(title: "Check your item.", content:"Here is the content for your item.")
footnotes.append(.init().with { $0.text = "Offer you best deals on phones, tablets, home, internet and more. Pre order the new version mobiles and get off *T&C apply."; $0.symbolType = "*"; $0.kind = .primary; $0.tooltipModel = toolTipModel})
footnotes.append(.init().with { $0.text = "The display has rounded corners. When measured as a standard rectangular shape, the screen is 6.68 inches diagonally. Actual viewable area is less."; $0.symbolType = "**"; $0.kind = .primary})
footnotes.append(.init().with { $0.text = "Some features may not be available for all countries or all areas."; $0.symbolType = "1."; $0.kind = .primary})
component.footnoteItems = footnotes
}
func setupPicker() {
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.surface = item
self?.contentTopView.backgroundColor = item.color
}
}
}
extension FootnoteGroupViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
}
}

View File

@ -1,176 +0,0 @@
//
// FootnoteViewController.swift
// VDSSample
//
// Created by Kanamarlapudi, Vasavi on 21/08/24.
//
import Foundation
import UIKit
import VDS
class FootnoteItemViewController: BaseViewController<FootnoteItem> {
internal enum SymbolType: String, DefaultValuing, CaseIterable {
case asterisk
case doubleAsterisk
case character
case none
public static var defaultValue: Self { .asterisk }
/// TextStyle relative to Size.
public var text: String {
switch self {
case .asterisk:
return "*"
case .doubleAsterisk:
return "**"
case .character:
return "1."
case .none:
return ""
}
}
}
lazy var kindPickerSelectorView = {
PickerSelectorView(title: "secondary",
picker: self.picker,
items: FootnoteItem.Kind.allCases)
}()
lazy var symbolTypePickerSelectorView = {
PickerSelectorView(title: "asterisk",
picker: self.picker,
items: SymbolType.allCases)
}()
lazy var sizePickerSelectorView = {
PickerSelectorView(title: "micro",
picker: self.picker,
items: FootnoteItem.Size.allCases)
}()
var hideSymbolSwitch = Toggle()
var footnoteTextField = TextField()
var widthTextField = NumericField()
var percentageTextField = NumericField()
var tooltipTitleTextField = TextField()
var tooltipContentTextField = TextField()
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component)
setupPicker()
setupModel()
}
override func setupForm() {
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Kind", view: kindPickerSelectorView)
addFormRow(label: "Size", view: sizePickerSelectorView)
addFormRow(label: "Symbol Type", view: symbolTypePickerSelectorView)
addFormRow(label: "Hide Symbol", view: hideSymbolSwitch, pinTrailing: false)
addFormRow(label: "Text", view: footnoteTextField)
addFormRow(label: "Width", view: widthTextField)
addFormRow(label: "Percentage (1-100)", view: percentageTextField)
addFormRow(label: "ToolTip Title", view: tooltipTitleTextField)
addFormRow(label: "ToolTip Content", view: tooltipContentTextField)
hideSymbolSwitch.publisher(for: .valueChanged).sink { [weak self] control in
self?.component.hideSymbol = control.isOn
}.store(in: &subscribers)
footnoteTextField
.textPublisher
.sink { [weak self] text in
self?.component.text = text
}.store(in: &subscribers)
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number {
self?.component.width = .value(number.cgFloatValue)
self?.percentageTextField.text = ""
} else {
self?.component.width = nil
}
}.store(in: &subscribers)
percentageTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number, number.intValue > 9 {
self?.component.width = .percentage(number.cgFloatValue)
self?.widthTextField.text = ""
} else {
self?.component.width = nil
}
}.store(in: &subscribers)
tooltipTitleTextField
.textPublisher
.sink { [weak self] text in
self?.updateTooltip()
}.store(in: &subscribers)
tooltipContentTextField
.textPublisher
.sink { [weak self] text in
self?.updateTooltip()
}.store(in: &subscribers)
}
func setupModel() {
component.text = "Service is included for free for two years with activation of any iPhone15 model. Connection and response times vary based on location, site conditions, and other factors. See support.apple.com/en-us/HT213885 for more information."
component.tooltipModel = nil
footnoteTextField.text = component.text
sizePickerSelectorView.text = component.size.rawValue
kindPickerSelectorView.text = component.kind.rawValue
symbolTypePickerSelectorView.text = SymbolType.defaultValue.text
tooltipTitleTextField.text = component.tooltipModel?.title
tooltipContentTextField.text = component.tooltipModel?.content
}
func setupPicker() {
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.surface = item
self?.contentTopView.backgroundColor = item.color
}
kindPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.kind = item
}
sizePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.size = item
}
symbolTypePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.symbolType = item.text
}
}
func updateTooltip() {
let title = tooltipTitleTextField.text ?? ""
let content = tooltipContentTextField.text ?? ""
component.tooltipModel = !title.isEmpty || !content.isEmpty ? .init(title: title,
content: content) : nil
}
}
extension FootnoteItemViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
}
}

View File

@ -12,50 +12,17 @@ import VDSCoreTokens
import Combine
class IconViewController: BaseViewController<Icon> {
enum IconColor: String, CaseIterable {
case `default`, token, custom
}
lazy var lightColorPickerSelectorView : TokenColorPickerSection = {
TokenColorPickerSection<IconColor>(rowTitle: "Light Color",
picker: self.picker).with {
$0.onSelected = { [weak self] color in
guard let self else { return }
light = .black
setColorConfiguration()
}
$0.onTokenSelected = { [weak self] color in
guard let self else { return }
light = color.uiColor
setColorConfiguration()
}
$0.onColorSelected = { [weak self] color in
guard let self else { return }
light = color
setColorConfiguration()
}
}
lazy var lightColorPickerSelectorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: UIColor.VDSColor.allCases)
}()
lazy var darkColorPickerSelectorView: TokenColorPickerSection = {
TokenColorPickerSection<IconColor>(rowTitle: "Dark Color",
picker: self.picker).with {
$0.onSelected = { [weak self] color in
guard let self else { return }
dark = .white
setColorConfiguration()
}
$0.onTokenSelected = { [weak self] color in
guard let self else { return }
dark = color.uiColor
setColorConfiguration()
}
$0.onColorSelected = { [weak self] color in
guard let self else { return }
dark = color
setColorConfiguration()
}
}
lazy var darkColorPickerSelectorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: UIColor.VDSColor.allCases)
}()
lazy var namePickerSelectorView = {
@ -74,7 +41,7 @@ class IconViewController: BaseViewController<Icon> {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: .makeWrapper(for: component))
setupPicker()
setupModel()
}
@ -84,8 +51,8 @@ class IconViewController: BaseViewController<Icon> {
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Size", view: sizePickerSelectorView)
addFormRow(label: "Custom Size", view: customSizeField)
append(section: lightColorPickerSelectorView)
append(section: darkColorPickerSelectorView)
addFormRow(label: "Light Color", view: lightColorPickerSelectorView)
addFormRow(label: "Dark Color", view: darkColorPickerSelectorView)
addFormRow(label: "Name", view: namePickerSelectorView)
customSizeField
@ -102,6 +69,8 @@ class IconViewController: BaseViewController<Icon> {
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
sizePickerSelectorView.text = component.size.rawValue
lightColorPickerSelectorView.text = UIColor.VDSColor.elementsPrimaryOnlight.rawValue
darkColorPickerSelectorView.text = UIColor.VDSColor.elementsPrimaryOndark.rawValue
namePickerSelectorView.text = name.rawValue
}
func setupPicker(){
@ -115,14 +84,22 @@ class IconViewController: BaseViewController<Icon> {
self?.component.size = item
}
lightColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.setColorConfiguration()
}
darkColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.setColorConfiguration()
}
namePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.name = item
}
}
var light: UIColor = .black
var dark: UIColor = .white
func setColorConfiguration() {
let light = lightColorPickerSelectorView.selectedItem.uiColor
let dark = darkColorPickerSelectorView.selectedItem.uiColor
component.colorConfiguration = .init(light, dark)
}

View File

@ -106,16 +106,16 @@ class InputFieldViewController: BaseViewController<InputField> {
}
general.addFormRow(label: "Surface", view: surfacePickerSelectorView)
general.addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
general.addFormRow(label: "Read Only", view: readonlySwitch, pinTrailing: false)
general.addFormRow(label: "Required", view: requiredSwitch, pinTrailing: false)
general.addFormRow(label: "Transparent Background", view: transparentBgSwitch, pinTrailing: false)
general.addFormRow(label: "Disabled", view: disabledSwitch)
general.addFormRow(label: "Read Only", view: readonlySwitch)
general.addFormRow(label: "Required", view: requiredSwitch)
general.addFormRow(label: "Transparent Background", view: transparentBgSwitch)
general.addFormRow(label: "Label Text", view: labelTextField)
general.addFormRow(label: "Helper Text Placement", view: helperTextPlacementPickerSelectorView)
general.addFormRow(label: "Helper Text", view: helperTextField)
general.addFormRow(label: "Error", view: showErrorSwitch, pinTrailing: false)
general.addFormRow(label: "Error", view: showErrorSwitch)
general.addFormRow(label: "Error Text", view: errorTextField)
general.addFormRow(label: "Success", view: showSuccessSwitch, pinTrailing: false)
general.addFormRow(label: "Success", view: showSuccessSwitch)
general.addFormRow(label: "Success Text", view: successTextField)
general.addFormRow(label: "Width", view: widthTextField)
general.addFormRow(label: "ToolTip Title", view: tooltipTitleTextField)
@ -181,7 +181,6 @@ class InputFieldViewController: BaseViewController<InputField> {
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
self?.component.width = number?.cgFloatValue
}.store(in: &subscribers)
@ -330,8 +329,14 @@ class InputFieldViewController: BaseViewController<InputField> {
extension InputFieldViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
let component = Self.makeComponent()
component.fieldType = .text
component.width = 328
component.labelText = "Street Address"
component.helperText = "For example: 123 Verizon St"
component.errorText = "Enter a valid address."
component.successText = "Good job entering a valid address!"
component.tooltipModel = .init(title: "Check the formatting of your address", content: "House/Building number then street name")
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}

View File

@ -1,265 +0,0 @@
//
// InputStepperViewController.swift
// VDSSample
//
// Created by Kanamarlapudi, Vasavi on 24/06/24.
//
import Foundation
import UIKit
import VDS
import VDSCoreTokens
import Combine
class InputStepperViewController: BaseViewController<InputStepper> {
var controlWidthTextField = TextField()
var controlWidthPercentageTextField = TextField()
var defaultValueField = NumericField()
var maxValueTextField = NumericField()
var minValueTextField = NumericField()
var trailingTextField = TextField()
var widthTextField = NumericField()
var widthPercentageTextField = NumericField()
var disabledSwitch = Toggle()
var readOnlySwitch = Toggle()
var requiredSwitch = Toggle()
var labelTextField = TextField()
var showErrorSwitch = Toggle()
var errorTextField = TextField()
var helperTextField = TextField()
var tooltipTitleTextField = TextField()
var tooltipContentTextField = TextField()
lazy var helperTextPlacementPickerSelectorView = {
PickerSelectorView(title: "", picker: self.picker, items: InputStepper.HelperTextPlacement.allCases)
}()
lazy var sizePickerSelectorView = {
PickerSelectorView(title: "", picker: self.picker, items: InputStepper.Size.allCases)
}()
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component)
setupPicker()
setupModel()
}
override func setupForm(){
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Control Width", view: controlWidthTextField)
addFormRow(label: "ControlWidth Percentage", view: controlWidthPercentageTextField)
addFormRow(label: "Default Value", view: defaultValueField)
addFormRow(label: "Max Value", view: maxValueTextField)
addFormRow(label: "Min Value", view: minValueTextField)
addFormRow(label: "Trailing Text", view: trailingTextField)
addFormRow(label: "Size", view: sizePickerSelectorView)
addFormRow(label: "Width Value", view: widthTextField)
addFormRow(label: "Width Percentage", view: widthPercentageTextField)
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Read Only", view: readOnlySwitch, pinTrailing: false)
addFormRow(label: "Required", view: requiredSwitch, pinTrailing: false)
addFormRow(label: "Label Text", view: labelTextField)
addFormRow(label: "Error", view: showErrorSwitch, pinTrailing: false)
addFormRow(label: "Error Text", view: errorTextField)
addFormRow(label: "Helper Text Placement", view: helperTextPlacementPickerSelectorView)
addFormRow(label: "Helper Text", view: helperTextField)
addFormRow(label: "Tooltip Title", view: tooltipTitleTextField)
addFormRow(label: "Tooltip Content", view: tooltipContentTextField)
controlWidthTextField
.numberPublisher
.sink { [weak self] number in
if let number {
self?.component.controlWidth = .value(number.cgFloatValue)
self?.controlWidthPercentageTextField.text = ""
} else {
self?.component.controlWidth = nil
}
}.store(in: &subscribers)
controlWidthPercentageTextField
.numberPublisher
.sink { [weak self] number in
if let number {
self?.component.controlWidth = .percentage(number.cgFloatValue)
self?.controlWidthTextField.text = ""
} else {
self?.component.controlWidth = nil
}
}.store(in: &subscribers)
defaultValueField
.numberPublisher
.sink { [weak self] number in
self?.component.defaultValue = number?.intValue ?? 0
}.store(in: &subscribers)
maxValueTextField
.numberPublisher
.sink { [weak self] number in
guard let number else { return }
self?.component.maxValue = number.intValue
}.store(in: &subscribers)
minValueTextField
.numberPublisher
.sink { [weak self] number in
guard let number else { return }
self?.component.minValue = number.intValue
}.store(in: &subscribers)
trailingTextField
.textPublisher
.sink { [weak self] text in
self?.component.trailingText = text
}.store(in: &subscribers)
requiredSwitch.onChange = { [weak self] sender in
self?.component.isRequired = sender.isOn
}
showErrorSwitch.onChange = { [weak self] sender in
guard let self else { return }
self.component.showError = sender.isOn
if self.component.showError != sender.isOn {
self.showErrorSwitch.isOn = self.component.showError
}
}
disabledSwitch.onChange = { [weak self] sender in
self?.component.isEnabled = !sender.isOn
}
readOnlySwitch.onChange = { [weak self] sender in
self?.component.isReadOnly = sender.isOn
}
labelTextField
.textPublisher
.sink { [weak self] text in
self?.component.labelText = text
}.store(in: &subscribers)
helperTextField
.textPublisher
.sink { [weak self] text in
self?.component.helperText = text
}.store(in: &subscribers)
errorTextField
.textPublisher
.sink { [weak self] text in
self?.component.errorText = text
}.store(in: &subscribers)
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number {
self?.component.widthPercentage = nil
self?.component.width = number.cgFloatValue
self?.widthPercentageTextField.text = ""
} else {
self?.component.width = nil
}
}.store(in: &subscribers)
widthPercentageTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
if let number, number.intValue > 10 {
self?.component.width = nil
self?.component.widthPercentage = number.cgFloatValue
self?.widthTextField.text = ""
} else {
self?.component.widthPercentage = nil
}
}.store(in: &subscribers)
tooltipTitleTextField
.textPublisher
.sink { [weak self] text in
self?.updateTooltip()
}.store(in: &subscribers)
tooltipContentTextField
.textPublisher
.sink { [weak self] text in
self?.updateTooltip()
}.store(in: &subscribers)
}
func updateTooltip() {
let title = tooltipTitleTextField.text ?? ""
let content = tooltipContentTextField.text ?? ""
component.tooltipModel = !title.isEmpty || !content.isEmpty ? .init(title: title,
content: content) : nil
}
//Picker
func setupPicker(){
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.surface = item
self?.contentTopView.backgroundColor = item.color
}
helperTextPlacementPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.helperTextPlacement = item
}
sizePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.size = item
}
}
func setupModel() {
component.labelText = "Quantity"
component.helperText = "Add up to max lines."
component.errorText = "You must choose a number of lines before advancing to the next step."
component.defaultValue = nil
component.trailingText = ""
component.onChange = { component in
if let text = component.value {
print("inputStepper Change: \(text)")
} else {
print("inputStepper Change: check code")
}
}
trailingTextField.text = component.trailingText
controlWidthTextField.text = ""
errorTextField.text = component.errorText
helperTextField.text = component.helperText
labelTextField.text = component.labelText
if let defaultVal = component.defaultValue {
defaultValueField.text = String(defaultVal)
}
minValueTextField.text = String(component.minValue)
maxValueTextField.text = String(component.maxValue)
component.size = .large
sizePickerSelectorView.text = "large"
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
helperTextPlacementPickerSelectorView.text = component.helperTextPlacement.rawValue
}
}
extension InputStepperViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
}
}

View File

@ -145,9 +145,8 @@ class LabelViewController: BaseViewController<Label> {
override func setupForm(){
super.setupForm()
addFormRow(label: "Current Language", view: Label().with { $0.text = LanguageManager.currentLanguage.description })
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Bold", view: boldSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Bold", view: boldSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
//Scaled Fonts implementation

View File

@ -1,138 +0,0 @@
//
// ListUnorderedViewController.swift
// VDSSample
//
// Created by Vasavi Kanamarlapudi on 16/10/24.
//
import Foundation
import VDS
class ListUnorderedViewController: BaseViewController<ListUnordered> {
lazy var sizePickerView = {
PickerSelectorView(title: "Large",
picker: self.picker,
items: ListUnordered.Size.allCases)
}()
lazy var spacingPickerView = {
PickerSelectorView(title:"Standard",
picker: self.picker,
items: ListUnordered.Spacing.allCases)
}()
var leadInTextField = TextField()
var itemLevelTwoTextOne = TextField()
var itemLevelTwoTextTwo = TextField()
var unorderedList: [ListUnordered.ListUnorderedItemModel]?
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component)
setupPicker()
setupModel()
}
override func setupForm() {
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Size", view: sizePickerView)
addFormRow(label: "Spacing", view: spacingPickerView)
let form1 = FormSection()
form1.title = "Lead-In Text (optional)"
form1.addFormRow(label: "Lead In Text", view: leadInTextField)
let form2 = FormSection()
form2.title = "List Item Level 2 (Optional)"
form2.addFormRow(label: "Subtext 1", view: itemLevelTwoTextOne)
form2.addFormRow(label: "Subtext 2", view: itemLevelTwoTextTwo)
append(section: form1)
append(section: form2)
leadInTextField
.textPublisher
.sink { [weak self] text in
self?.component.leadInText = text
}.store(in: &subscribers)
itemLevelTwoTextOne
.textPublisher
.sink { [weak self] text in
guard let self else { return }
self.updateUnorderList()
self.component.unorderedList = unorderedList ?? []
}.store(in: &subscribers)
itemLevelTwoTextTwo
.textPublisher
.sink { [weak self] text in
guard let self else { return }
self.updateUnorderList()
self.component.unorderedList = unorderedList ?? []
}.store(in: &subscribers)
}
func setupPicker() {
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.surface = item
self?.contentTopView.backgroundColor = item.color
}
sizePickerView.onPickerDidSelect = { [weak self] item in
self?.component.size = item
}
spacingPickerView.onPickerDidSelect = { [weak self] item in
self?.component.spacing = item
}
}
func setupModel() {
sizePickerView.text = component.size.rawValue
spacingPickerView.text = component.spacing.rawValue
leadInTextField.text = "To manage your existing Call Intercept calling feature:"
self.component.leadInText = leadInTextField.text
itemLevelTwoTextOne.text = "Priority callers can bypass Call Intercept by entering your 4 digit Call Intercept Override Code."
itemLevelTwoTextTwo.text = "Your phone will alert you with a short-short-long ring and \"Priority Caller\" will appear on your display."
updateUnorderList()
self.component.unorderedList = self.unorderedList ?? []
}
// Update test data
func updateUnorderList() {
if (itemLevelTwoTextOne.text?.isEmpty == true) {
itemLevelTwoTextOne.text = nil
}
if (itemLevelTwoTextTwo.text?.isEmpty == true) {
itemLevelTwoTextTwo.text = nil
}
var levelTwoSubTexts : [String?]? = nil
if let subtextOneEmpty = itemLevelTwoTextOne.text?.isEmpty, let subtextTwoEmpty = itemLevelTwoTextTwo.text?.isEmpty {
if !subtextOneEmpty && !subtextTwoEmpty {
levelTwoSubTexts = [itemLevelTwoTextOne.text, itemLevelTwoTextTwo.text]
} else if !subtextOneEmpty || !subtextTwoEmpty {
if subtextOneEmpty {
levelTwoSubTexts = [itemLevelTwoTextTwo.text]
} else if subtextTwoEmpty {
levelTwoSubTexts = [itemLevelTwoTextOne.text]
}
}
unorderedList = [
.init(itemLevelOneText: "Call 800-435-7986 to have your PIN reset."),
.init(itemLevelOneText: "To bypass Call Intercept",
itemLevelTwoTexts: levelTwoSubTexts)
]
}
}
}
extension ListUnorderedViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let component = Self.makeComponent()
return ComponentSample(component: component)
}
}

View File

@ -23,10 +23,10 @@ class LoaderViewController: BaseViewController<Loader>, LoaderLaunchable {
override func setupForm() {
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Active", view: isActive, pinTrailing: false)
addFormRow(label: "Active", view: isActive)
let fullScreen = FormSection().with { $0.title = "LoaderLaunchable (separate from Loader)" }
fullScreen.addFormRow(label: "presentLoader", view: isFullscreen, pinTrailing: false)
fullScreen.addFormRow(label: "presentLoader", view: isFullscreen)
append(section: fullScreen)
isActive

View File

@ -75,26 +75,19 @@ class MenuViewController: UITableViewController, TooltipLaunchable {
MenuComponent(title: "ButtonGroup", completed: true, viewController: ButtonGroupViewController.self),
MenuComponent(title: "ButtonIcon", completed: true, viewController: ButtonIconViewController.self),
MenuComponent(title: "Calendar", completed: true, viewController: CalendarViewController.self),
MenuComponent(title: "Carousel", completed: true, viewController: CarouselViewController.self),
MenuComponent(title: "Carousel Scrollbar", completed: true, viewController: CarouselScrollbarViewConttroller.self),
MenuComponent(title: "Checkbox", completed: true, viewController: CheckboxViewController.self),
MenuComponent(title: "CheckboxItem", completed: true, viewController: CheckboxItemViewController.self),
MenuComponent(title: "CheckboxGroup", completed: true, viewController: CheckboxGroupViewController.self),
MenuComponent(title: "DatePicker", completed: true, viewController: DatePickerViewController.self),
MenuComponent(title: "DropdownSelect", completed: true, viewController: DropdownSelectViewController.self),
MenuComponent(title: "FootnoteItem", completed: true, viewController: FootnoteItemViewController.self),
MenuComponent(title: "FootnoteGroup", completed: true, viewController: FootnoteGroupViewController.self),
MenuComponent(title: "Icon", completed: true, viewController: IconViewController.self),
MenuComponent(title: "InputField", completed: true, viewController: InputFieldViewController.self),
MenuComponent(title: "InputStepper", completed: true, viewController: InputStepperViewController.self),
MenuComponent(title: "Label", completed: true, viewController: LabelViewController.self),
MenuComponent(title: "Line", completed: true, viewController: LineViewController.self),
MenuComponent(title: "List Unordered", completed: false, viewController: ListUnorderedViewController.self),
MenuComponent(title: "Loader", completed: true, viewController: LoaderViewController.self),
MenuComponent(title: "Modal", completed: true, viewController: ModalViewController.self),
MenuComponent(title: "Notification", completed: true, viewController: NotificationViewController.self),
MenuComponent(title: "Pagination", completed: true, viewController: PaginationViewController.self),
MenuComponent(title: "PriceLockup", completed: true, viewController: PriceLockupViewController.self),
MenuComponent(title: "RadioBoxGroup", completed: true, viewController: RadioBoxGroupViewController.self),
MenuComponent(title: "RadioButton", completed: true, viewController: RadioButtonViewController.self),
MenuComponent(title: "RadioButtonItem", completed: true, viewController: RadioButtonItemViewController.self),
@ -118,31 +111,16 @@ class MenuViewController: UITableViewController, TooltipLaunchable {
}
override func viewDidLoad() {
let build = Bundle.main.build ?? "none"
title = "VDS Sample: Build \(build)"
title = "VDS Sample: Build \(Bundle.main.build ?? "none")"
let content = VDSHelper.releaseNotes()
if !content.isEmpty {
let tooltip = VDS.Tooltip()
tooltip.title = "Release Notes: \(build)"
tooltip.title = "Release Notes: \(VDSHelper.version)"
tooltip.content = content
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: tooltip)
}
var useSpanish = Toggle().with {
$0.offText = "English"
$0.onText = "Spanish"
$0.showText = true
$0.textPosition = .right
}
useSpanish.isOn = LanguageManager.currentLanguage == .spanish
useSpanish.onChange = { control in
LanguageManager.currentLanguage = control.isOn ? .spanish : .english
}
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: useSpanish)
super.viewDidLoad()
overrideUserInterfaceStyle = .light
tableView.register(MenuCell.self, forCellReuseIdentifier: "cell")

View File

@ -1,127 +0,0 @@
//
// ModalViewController.swift
// VDSSample
//
// Created by Kanamarlapudi, Vasavi on 05/09/24.
//
import Foundation
import UIKit
import VDS
import VDSCoreTokens
import Combine
class ModalViewController: BaseViewController<Modal> {
var showFooterSwitch = Toggle()
var fullScreenDialogSwitch = Toggle()
var singleButtonSwitch = Toggle()
var hideCloseSwitch = Toggle()
var titleTextField = TextField()
var bodyTextField = TextField()
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
setupPicker()
setupModel()
}
override func setupForm(){
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Show Modal Footer", view: showFooterSwitch, pinTrailing: false)
addFormRow(label: "Full Screen Dialog", view: fullScreenDialogSwitch, pinTrailing: false)
addFormRow(label: "Single Button", view: singleButtonSwitch, pinTrailing: false)
addFormRow(label: "Hide Close Button", view: hideCloseSwitch, pinTrailing: false)
addFormRow(label: "Modal Title", view: titleTextField)
addFormRow(label: "Modal Body", view: bodyTextField)
fullScreenDialogSwitch.publisher(for: .valueChanged).sink { [weak self] control in
self?.component.fullScreenDialog = control.isOn
}.store(in: &subscribers)
showFooterSwitch.publisher(for: .valueChanged).sink { [weak self] control in
guard let self else { return }
if control.isOn {
showFooter(with: singleButtonSwitch.isOn)
} else {
self.component.buttonData = nil
}
}.store(in: &subscribers)
singleButtonSwitch.publisher(for: .valueChanged).sink { [weak self] control in
guard let self else { return }
if control.isOn {
showFooterSwitch.isOn = true
}
showFooter(with: control.isOn)
}.store(in: &subscribers)
hideCloseSwitch.publisher(for: .valueChanged).sink { [weak self] control in
self?.component.hideCloseButton = control.isOn
}.store(in: &subscribers)
titleTextField
.textPublisher
.sink { [weak self] text in
self?.component.title = text
}.store(in: &subscribers)
bodyTextField
.textPublisher
.sink { [weak self] text in
self?.component.content = text
}.store(in: &subscribers)
}
func showFooter(with singleButton: Bool) {
if singleButton {
component.buttonData = [
Button().with{ $0.use = .secondary; $0.text = "Close"; $0.onClick = { button in self.dismiss(animated: true); print("\(button.text!) clicked")} ; $0.size = .large }
]
} else {
component.buttonData = [
Button().with{ $0.use = .primary; $0.text = "In-store Pickup"; $0.onClick = { button in print("\(button.text!) clicked")}; $0.size = .large },
Button().with{ $0.use = .secondary; $0.text = "Close"; $0.onClick = { button in self.dismiss(animated: true); print("\(button.text!) clicked")} ; $0.size = .large }
]
}
}
func setupModel() {
component.title = "Choose free 2-day shipping or In-store Pickup"
component.content = "Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed."
component.contentView = Icon().with { $0.name = .addFolder; $0.size = .medium }
let onClick: (ButtonBase) -> Void = { button in print("\(button.text!) clicked")}
component.buttonData = [
Button().with{ $0.use = .primary; $0.text = "In-store Pickup"; $0.onClick = onClick; $0.size = .large },
Button().with{ $0.use = .secondary; $0.text = "Close"; $0.onClick = { button in self.dismiss(animated: true); print("\(button.text!) clicked")} ; $0.size = .large }
]
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
titleTextField.text = component.title
bodyTextField.text = component.content
showFooterSwitch.isOn = true
}
//Picker
func setupPicker(){
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.surface = item
self?.contentTopView.backgroundColor = item.color
}
}
}
extension ModalViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let component = Self.makeComponent()
component.title = "Choose free 2-day shipping or In-store Pickup"
component.content = "Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed."
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual, bottomPinningType: .lessThanOrEqual)
}
}

View File

@ -52,8 +52,8 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
addFormRow(label: "Style", view: notificationTypePickerSelectorView)
addFormRow(label: "Title", view: titleTextField)
addFormRow(label: "SubTitle", view: subTitleTextField)
addFormRow(label: "Hide Button Group", view: buttonGroupToggle, pinTrailing: false)
addFormRow(label: "Hide Close Button", view: hideCloseButtonToggle, pinTrailing: false)
addFormRow(label: "Hide Button Group", view: buttonGroupToggle)
addFormRow(label: "Hide Close Button", view: hideCloseButtonToggle)
addFormRow(label: "Action", view: label)
addFormRow(label: "First Button Text", view: firstButtonTextField)
addFormRow(label: "Second Button Text", view: secondButtonTextField)

View File

@ -1,152 +0,0 @@
//
// PriceLockupViewController.swift
// VDSSample
//
// Created by Kanamarlapudi, Vasavi on 06/08/24.
//
import Foundation
import UIKit
import VDS
class PriceLockupViewController: BaseViewController<PriceLockup> {
lazy var kindPickerSelectorView = {
PickerSelectorView(title: "primary",
picker: self.picker,
items: PriceLockup.Kind.allCases)
}()
lazy var termPickerSelectorView = {
PickerSelectorView(title: "month",
picker: self.picker,
items: PriceLockup.Term.allCases)
}()
lazy var sizePickerSelectorView = {
PickerSelectorView(title: "medium",
picker: self.picker,
items: PriceLockup.Size.allCases)
}()
var boldSwitch = Toggle()
var hideCurrencySwitch = Toggle()
var strikethroughSwitch = Toggle()
var uniformSizeSwitch = Toggle()
var priceTextField = NumericField()
var leadingTextField = TextField()
var termTextField = TextField()
var trailingTextField = TextField()
var superscriptTextField = TextField()
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component)
setupPicker()
setupModel()
}
override func setupForm() {
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Bold", view: boldSwitch, pinTrailing: false)
addFormRow(label: "Kind", view: kindPickerSelectorView)
addFormRow(label: "Size", view: sizePickerSelectorView)
addFormRow(label: "Hide Currency", view: hideCurrencySwitch, pinTrailing: false)
addFormRow(label: "Price", view: priceTextField)
addFormRow(label: "Leading Text", view: leadingTextField)
addFormRow(label: "Strikethrough", view: strikethroughSwitch, pinTrailing: false)
addFormRow(label: "Uniform Size", view: uniformSizeSwitch, pinTrailing: false)
addFormRow(label: "Term", view: termPickerSelectorView)
addFormRow(label: "Trailing Text", view: trailingTextField)
addFormRow(label: "Superscript", view: superscriptTextField)
boldSwitch.publisher(for: .valueChanged).sink { [weak self] control in
self?.component.bold = control.isOn
}.store(in: &subscribers)
hideCurrencySwitch.publisher(for: .valueChanged).sink { [weak self] control in
self?.component.hideCurrency = control.isOn
}.store(in: &subscribers)
strikethroughSwitch.publisher(for: .valueChanged).sink { [weak self] control in
self?.component.strikethrough = control.isOn
}.store(in: &subscribers)
uniformSizeSwitch.publisher(for: .valueChanged).sink { [weak self] control in
self?.component.uniformSize = control.isOn
}.store(in: &subscribers)
priceTextField
.numberPublisher
.sink { [weak self] number in
if let number {
self?.component.price = number.floatValue
} else {
self?.component.price = nil
}
}.store(in: &subscribers)
leadingTextField
.textPublisher
.sink { [weak self] text in
self?.component.leadingText = text
}.store(in: &subscribers)
trailingTextField
.textPublisher
.sink { [weak self] text in
self?.component.trailingText = text
}.store(in: &subscribers)
superscriptTextField
.textPublisher
.sink { [weak self] text in
self?.component.superscript = text
}.store(in: &subscribers)
}
func setupModel() {
component.price = 24.22
component.superscript = "*"
component.leadingText = "Save"
component.trailingText = "with Auto Pay"
sizePickerSelectorView.text = component.size.rawValue
kindPickerSelectorView.text = component.kind.rawValue
termPickerSelectorView.text = component.term.rawValue
priceTextField.text = "\(component.price!)"
leadingTextField.text = component.leadingText
trailingTextField.text = component.trailingText
superscriptTextField.text = component.superscript
}
func setupPicker() {
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.surface = item
self?.contentTopView.backgroundColor = item.color
}
kindPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.kind = item
}
sizePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.size = item
}
termPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.term = item
}
}
}
extension PriceLockupViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
}
}

View File

@ -31,9 +31,9 @@ class RadioBoxGroupViewController: BaseViewController<RadioBoxGroup>{
override func setupForm(){
super.setupForm()
addActionRow()
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Strikethrough", view: strikeThroughSwitch, pinTrailing: false)
addFormRow(label: "Strikethrough", view: strikeThroughSwitch)
addFormRow(label: "Text", view: textField)
addFormRow(label: "Sub Text", view: subTextField)
addFormRow(label: "Sub Text Right", view: subTextRightField)
@ -78,18 +78,7 @@ class RadioBoxGroupViewController: BaseViewController<RadioBoxGroup>{
radioBox2.inputId = "model2"
radioBox2.value = "model 2 Value"
radioBox2.text = "iPhone 11 Bundle 2"
let fullText = "I accept the Terms and Conditions"
let linkText = "Terms and Conditions"
radioBox2.subText = fullText
if let link = ActionLabelAttribute(text: fullText, linkText: linkText) {
link.action.sink { [weak self] in
guard let self else { return }
present(UIAlertController(title: "TextLink", message: "Clicked \(linkText)", preferredStyle: .alert).with{ $0.addAction(.init(title: "OK", style: .default)) }, animated: true)
}.store(in: &subscribers)
radioBox2.subTextAttributes = [link]
}
radioBox2.subText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector"
component.selectorModels = [radioBox1, radioBox2]
@ -140,6 +129,6 @@ extension RadioBoxGroupViewController: ComponentSampleable {
component.selectorModels = [radioBox1, radioBox2]
return ComponentSample(component: component)
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}

View File

@ -29,11 +29,11 @@ class RadioButtonGroupViewController: BaseViewController<RadioButtonGroup> {
override func setupForm(){
super.setupForm()
addActionRow()
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Label Text", view: labelTextField)
addFormRow(label: "Child Text", view: childTextField)
addFormRow(label: "Error", view: showErrorSwitch, pinTrailing: false)
addFormRow(label: "Error", view: showErrorSwitch)
showErrorSwitch.onChange = { [weak self] sender in
self?.component.showError = sender.isOn
@ -133,6 +133,6 @@ extension RadioButtonGroupViewController: ComponentSampleable {
component.selectorModels = [radioButton1, radioButton2, radioButton3]
return ComponentSample(component: component)
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}

View File

@ -30,11 +30,11 @@ class RadioButtonItemViewController: BaseViewController<RadioButtonItem> {
override func setupForm(){
super.setupForm()
addActionRow()
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Label Text", view: labelTextField)
addFormRow(label: "Child Text", view: childTextField)
addFormRow(label: "Error", view: showErrorSwitch, pinTrailing: false)
addFormRow(label: "Error", view: showErrorSwitch)
addFormRow(label: "Error Text", view: errorTextField)
showErrorSwitch.onChange = { [weak self] sender in
@ -105,6 +105,6 @@ extension RadioButtonItemViewController: ComponentSampleable {
component.childText = "I agree to Verizon's terms and conditions click here"
component.errorText = "Error Text"
return ComponentSample(component: component)
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}

View File

@ -18,16 +18,16 @@ class RadioButtonViewController: BaseViewController<RadioButton> {
let toggle = UISwitch()
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
setupPicker()
setupModel()
}
override func setupForm(){
super.setupForm()
addActionRow()
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Error", view: showErrorSwitch, pinTrailing: false)
addFormRow(label: "Error", view: showErrorSwitch)
showErrorSwitch.onChange = { [weak self] sender in
guard let self else { return }

View File

@ -10,23 +10,6 @@ import VDS
import UIKit
import VDSCoreTokens
enum TableLineStyle: String, CaseIterable {
case none
case primary
case secondary
func lineStyle() -> Line.Style? {
switch self {
case .primary:
return Line.Style.primary
case .secondary:
return Line.Style.secondary
case .none:
return nil
}
}
}
class TableViewController: BaseViewController<Table> {
var striped = Toggle()
@ -38,11 +21,11 @@ class TableViewController: BaseViewController<Table> {
}
lazy var headerLineStylePicker = {
PickerSelectorView(title: "primary", picker: self.picker, items: TableLineStyle.allCases)
PickerSelectorView(title: "primary", picker: self.picker, items: Line.Style.allCases)
}()
lazy var rowLineStylePicker = {
PickerSelectorView(title: "secondary", picker: self.picker, items: TableLineStyle.allCases)
PickerSelectorView(title: "secondary", picker: self.picker, items: Line.Style.allCases)
}()
lazy var paddingPicker = {
@ -59,10 +42,10 @@ class TableViewController: BaseViewController<Table> {
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Padding", view: paddingPicker)
addFormRow(label: "Striped", view: striped, pinTrailing: false)
addFormRow(label: "Striped", view: striped)
addFormRow(label: "Header line style", view: headerLineStylePicker)
addFormRow(label: "Row line style", view: rowLineStylePicker)
addFormRow(label: "Fill container", view: fillContainer, pinTrailing: false)
addFormRow(label: "Fill container", view: fillContainer)
addFormRow(label: "Custom column size", view: customColumnWidthSize)
fillContainer.isOn = component.fillContainer
@ -72,20 +55,6 @@ class TableViewController: BaseViewController<Table> {
striped.onChange = { [weak self] sender in
self?.component.striped = sender.isOn
let headerStyle = sender.isOn ? nil : TableLineStyle(rawValue: self?.headerLineStylePicker.text ?? "")
let rowStyle = sender.isOn ? nil : TableLineStyle(rawValue: self?.rowLineStylePicker.text ?? "")
var headers = self?.component.tableHeader ?? [TableRowModel]()
self?.updateBottomLineStyle(items:&headers, style: headerStyle?.lineStyle())
self?.component.tableHeader = headers
var rows = self?.component.tableRows ?? [TableRowModel]()
self?.updateBottomLineStyle(items:&rows, style: rowStyle?.lineStyle())
self?.component.tableRows = rows
self?.component.padding = .compact
self?.paddingPicker.text = Table.Padding.compact.rawValue
}
fillContainer.onChange = { [weak self] sender in
@ -113,14 +82,28 @@ class TableViewController: BaseViewController<Table> {
headerLineStylePicker.onPickerDidSelect = { [weak self] item in
var headers = self?.component.tableHeader ?? [TableRowModel]()
self?.updateBottomLineStyle(items:&headers, style: item.lineStyle())
for currentHeaderIndex in 0..<headers.count {
var currentHeader = headers[currentHeaderIndex]
for currentHeaderItem in 0..<currentHeader.columnsCount {
currentHeader.columns[currentHeaderItem].bottomLine = item
}
headers[currentHeaderIndex] = currentHeader
}
self?.component.tableHeader = headers
}
rowLineStylePicker.onPickerDidSelect = { [weak self] item in
var rows = self?.component.tableRows ?? [TableRowModel]()
self?.updateBottomLineStyle(items:&rows, style: item.lineStyle())
for currentRowIndex in 0..<rows.count {
var currentRow = rows[currentRowIndex]
for currentRowItem in 0..<currentRow.columnsCount {
currentRow.columns[currentRowItem].bottomLine = item
}
rows[currentRowIndex] = currentRow
}
self?.component.tableRows = rows
}
@ -134,26 +117,12 @@ class TableViewController: BaseViewController<Table> {
customColumnWidthSize.backgroundColor = enable ? UIColor.white : VDSColor.paletteGray85
}
func updateBottomLineStyle(items:inout [TableRowModel], style: Line.Style?) {
for currentRowIndex in 0..<items.count {
var currentRow = items[currentRowIndex]
for currentRowItem in 0..<currentRow.columnsCount {
currentRow.columns[currentRowItem].bottomLine = style
}
items[currentRowIndex] = currentRow
}
}
func setupModel() {
///Header row
let tableInfoLabel = Label().with({
$0.text = ""
$0.accessibilityLabel = "Verizon Plan compare, table, with 3 Rows, 3 Columns, Empty"
})
self.component.tableHeader = [TableRowModel(columns: [TableItemModel(bottomLine: .primary, component: tableInfoLabel),
self.component.tableHeader = [TableRowModel(columns: [TableItemModel(bottomLine: .primary, component: nil),
TableItemModel(bottomLine: .primary, component: Label().with { $0.text = "Verizon smart family"; $0.textStyle = .boldTitleSmall; $0.lineBreakMode = .byWordWrapping}),
TableItemModel(bottomLine: .primary, component: Label().with { $0.text = "Call filter"; $0.textStyle = .boldTitleSmall; $0.lineBreakMode = .byWordWrapping })], isHeader: true)]
TableItemModel(bottomLine: .primary, component: Label().with { $0.text = "Call filter"; $0.textStyle = .boldTitleSmall; $0.lineBreakMode = .byWordWrapping })])]
///First row
var rows = [TableRowModel(columns: [TableItemModel(bottomLine: .secondary, component: Label().with { $0.text = "Cost"; $0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall; $0.lineBreakMode = .byWordWrapping}),
@ -206,12 +175,11 @@ class TableViewController: BaseViewController<Table> {
trailingToolTip.labelText = "5G Ultra Wideband is available in your area"
trailingToolTip.tooltipModel = .init(title: "Check the formatting of your address",
content:"House/Building number then street name")
let iconView = Icon()
iconView.name = .cleanSurface
let image = UIImage(named: "clean-surface")
let imageView = UIImageView(image: image)
rows.append(TableRowModel(columns: [TableItemModel(bottomLine: .secondary, component:textArea),
TableItemModel(bottomLine: .secondary, component:iconView),
TableItemModel(bottomLine: .secondary, component:imageView),
TableItemModel(bottomLine: .secondary, component:trailingToolTip)]))
}
@ -222,11 +190,3 @@ class TableViewController: BaseViewController<Table> {
self.component.tableRows = rows
}
}
extension TableViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
}
}

View File

@ -20,7 +20,7 @@ public struct ComponentSample {
public enum LessThanPinningType: String {
case none, equalTo, lessThanOrEqual
}
public var edgeInset: UIEdgeInsets = .uniform(16)
public var top: GreaterThanPinningType = .equalTo
public var leading: GreaterThanPinningType = .equalTo
public var trailing: LessThanPinningType = .equalTo
@ -30,18 +30,16 @@ public struct ComponentSample {
topPinningType: GreaterThanPinningType = .equalTo,
leadingPinningType: GreaterThanPinningType = .equalTo,
trailingPinningType: LessThanPinningType = .equalTo,
bottomPinningType: LessThanPinningType = .equalTo,
edgeInset: UIEdgeInsets = .uniform(16)) {
bottomPinningType: LessThanPinningType = .equalTo) {
self.component = component
self.top = topPinningType
self.leading = leadingPinningType
self.trailing = trailingPinningType
self.bottom = bottomPinningType
self.edgeInset = edgeInset
}
public func pin() {
public func pin(edgeInset: UIEdgeInsets = .zero) {
guard let superview = component.superview else { return }
switch top {
@ -128,10 +126,10 @@ public class TableViewTestController: UIViewController, Initable, Surfaceable {
}
}
let toggleSample = ComponentSample(component: toggle, leadingPinningType: .none, edgeInset: .init(top: 5, left: 0, bottom: 5, right: 16))
let toggleSample = ComponentSample(component: toggle, leadingPinningType: .none)
let wrapper = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false }
wrapper.addSubview(toggle)
toggleSample.pin()
toggleSample.pin(edgeInset: .init(top: 5, left: 0, bottom: 5, right: 16))
let stackView = UIStackView(arrangedSubviews: [wrapper, tableView]).with {
$0.translatesAutoresizingMaskIntoConstraints = false
@ -195,7 +193,7 @@ extension TableViewTestController : UITableViewDelegate, UITableViewDataSource {
let cell = UITableViewCell()
cell.contentView.addSubview(component)
sample.pin()
sample.pin(edgeInset: .uniform(16))
cell.backgroundColor = surface.color
cell.layoutIfNeeded()
return cell

View File

@ -59,8 +59,8 @@ class TabsContainerViewController: BaseViewController<TabsContainer> {
override func setupForm(){
super.setupForm()
addFormRow(label: "Large Sample", view: sampleSwitch, pinTrailing: false)
addFormRow(label: "Show Borderline", view: borderlineSwitch, pinTrailing: false)
addFormRow(label: "Large Sample", view: sampleSwitch)
addFormRow(label: "Show Borderline", view: borderlineSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Size", view: sizePickerSelectorView)
@ -72,7 +72,7 @@ class TabsContainerViewController: BaseViewController<TabsContainer> {
}
//only in horizontal mode
horizontalOrientationFormStackView.addFormRow(label: "Fill Container", view: fillContainerSwitch, pinTrailing: false)
horizontalOrientationFormStackView.addFormRow(label: "Fill Container", view: fillContainerSwitch)
horizontalOrientationFormStackView.addFormRow(label: "Indicator Position", view: indicatorPositionPickerSelectorView)
overflowRow = horizontalOrientationFormStackView.addFormRow(label: "Overflow", view: overflowPickerSelectorView)

View File

@ -59,8 +59,8 @@ class TabsViewController: BaseViewController<Tabs> {
override func setupForm(){
super.setupForm()
addFormRow(label: "Large Sample", view: sampleSwitch, pinTrailing: false)
addFormRow(label: "Show Borderline", view: borderlineSwitch, pinTrailing: false)
addFormRow(label: "Large Sample", view: sampleSwitch)
addFormRow(label: "Show Borderline", view: borderlineSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Size", view: sizePickerSelectorView)
@ -69,7 +69,7 @@ class TabsViewController: BaseViewController<Tabs> {
}
//only in horizontal mode
horizontalOrientationFormStackView.addFormRow(label: "Fill Container", view: fillContainerSwitch, pinTrailing: false)
horizontalOrientationFormStackView.addFormRow(label: "Fill Container", view: fillContainerSwitch)
horizontalOrientationFormStackView.addFormRow(label: "Indicator Position", view: indicatorPositionPickerSelectorView)
//overflowRow = horizontalOrientationFormStackView.addFormRow(label: "Overflow", view: overflowPickerSelectorView)

View File

@ -42,13 +42,13 @@ class TextAreaViewController: BaseViewController<TextArea> {
override func setupForm(){
super.setupForm()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Read Only", view: readOnlySwitch, pinTrailing: false)
addFormRow(label: "Required", view: requiredSwitch, pinTrailing: false)
addFormRow(label: "Transparent Background", view: transparentBgSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Read Only", view: readOnlySwitch)
addFormRow(label: "Required", view: requiredSwitch)
addFormRow(label: "Transparent Background", view: transparentBgSwitch)
addFormRow(label: "Label Text", view: labelTextField)
addFormRow(label: "Helper Text", view: helperTextField)
addFormRow(label: "Error", view: showErrorSwitch, pinTrailing: false)
addFormRow(label: "Error", view: showErrorSwitch)
addFormRow(label: "Error Text", view: errorTextField)
addFormRow(label: "Width", view: widthTextField)
addFormRow(label: "ToolTip Title", view: tooltipTitleTextField)
@ -101,8 +101,11 @@ class TextAreaViewController: BaseViewController<TextArea> {
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
self?.component.width = number?.cgFloatValue
guard let number else {
self?.component.width = nil
return
}
self?.component.width = number.cgFloatValue
}.store(in: &subscribers)
tooltipTitleTextField
@ -179,8 +182,13 @@ class TextAreaViewController: BaseViewController<TextArea> {
extension TextAreaViewController: ComponentSampleable {
static func makeSample() -> ComponentSample {
let c = Self()
c.setupModel()
return ComponentSample(component: c.component)
let component = Self.makeComponent()
component.width = 328
component.labelText = "Street Address"
component.helperText = "For example: 123 Verizon St"
component.errorText = "Enter a valid address."
component.tooltipModel = .init(title: "Check the formatting of your address",
content:"House/Building number then street name")
return ComponentSample(component: component, trailingPinningType: .lessThanOrEqual)
}
}

View File

@ -34,7 +34,7 @@ class TextLinkCaretViewController: BaseViewController<TextLinkCaret> {
super.setupForm()
addFormRow(label: "Action", view: label)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Label", view: textField)
addFormRow(label: "Caret Position", view: caretPositionPickerSelectorView)

View File

@ -36,7 +36,7 @@ class TextLinkViewController: BaseViewController<TextLink> {
super.setupForm()
addFormRow(label: "Action", view: label)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Label", view: textField)
addFormRow(label: "Size", view: buttonSizePickerSelectorView)

View File

@ -13,6 +13,18 @@ import Combine
class TileContainerViewController: BaseViewController<TileContainer> {
lazy var colorPicker: UIColorPickerViewController = {
let picker = UIColorPickerViewController()
picker.delegate = self
return picker
}()
lazy var backgroundColorPickerSelectorView = {
PickerSelectorView(title: "white",
picker: self.picker,
items: BackgroundColor.allCases)
}()
lazy var imageFallbackColorPickerSelectorView = {
SurfacePickerSelectorView(picker: self.picker)
}()
@ -47,6 +59,12 @@ class TileContainerViewController: BaseViewController<TileContainer> {
var customPaddingRowView: UIView?
var anyCancellable: AnyCancellable?
var contentAreaBackgroundColorButton = Button().with { instance in
instance.size = .small
instance.use = .secondary
instance.text = "Select"
}
var paddingTextField = NumericField().with {
$0.placeholder = "Custom Padding"
}
@ -58,128 +76,75 @@ class TileContainerViewController: BaseViewController<TileContainer> {
$0.placeholder = "Minimum 100px else it will occupy full container"
}
lazy var backgroundColorPickerSelectorView: TokenColorPickerSection = {
TokenColorPickerSection<BackgroundColor>(rowTitle: "Background Color",
picker: self.picker).with {
$0.onSelected = { [weak self] item in
guard let self else { return }
switch item {
case .primary:
component.color = .primary
case .secondary:
component.color = .secondary
case .white:
component.color = .white
case .black:
component.color = .black
default: break;
var colorPickerType: ColorPickerType = .backgroundColor
enum ColorPickerType {
case backgroundColor, gradientColor1, gradientColor2, contentViewBackgroundColor
}
}
$0.onTokenSelected = { [weak self] color in
guard let self else { return }
component.color = .custom(color.uiColor)
}
$0.onColorSelected = { [weak self] color in
guard let self else { return }
component.color = .custom(color)
}
lazy var gradientColorView1: ColorPickerView<ColorPickerType> = {
return .init(with: ColorPickerType.gradientColor1) { [weak self] picker in
self?.colorPickerType = picker.pickerType
self?.selectedColorTapped(picker)
}
}()
lazy var gradientColorView1: ColorPickerView = {
return .init().with {
$0.onColorSelected = { [weak self] _ in
guard let self else { return }
updateGradientColors()
}
}
}()
lazy var gradientColorView2: ColorPickerView = {
return .init().with {
$0.onColorSelected = { [weak self] _ in
guard let self else { return }
updateGradientColors()
}
lazy var gradientColorView2: ColorPickerView<ColorPickerType> = {
return .init(with: ColorPickerType.gradientColor2) { [weak self] picker in
self?.colorPickerType = picker.pickerType
self?.selectedColorTapped(picker)
}
}()
override func viewDidLoad() {
super.viewDidLoad()
let mainView = View()
mainView.backgroundColor = .purple
///top
let topView = View()
topView.backgroundColor = .yellow
let topLabel = Label()
topLabel.text = "Do you want to Register?"
let topButton = Button()
topButton.text = "Register"
topButton.onClick = { c in print("clicked \(c.text!)") }
///bottom
let bottomView = View()
bottomView.backgroundColor = .green
let bottomLabel = Label()
bottomLabel.text = "Forgot your info?"
let bottomButton = Button()
bottomButton.text = "Forgot Password"
bottomButton.onClick = { c in print("clicked \(c.text!)") }
mainView.addSubview(topView)
mainView.addSubview(bottomView)
topView.addSubview(topLabel)
topView.addSubview(topButton)
bottomView.addSubview(bottomLabel)
bottomView.addSubview(bottomButton)
let space: CGFloat = 5
topView
.pinTop(space*2)
.pinLeading(space*2)
.pinTrailing(space*2)
.pinBottom(anchor: bottomView.topAnchor, constant: space*2)
topLabel
.pinTop(space)
.pinLeading(space)
.pinTrailing(space)
.pinBottom(anchor: topButton.topAnchor, constant: space)
topButton
.pinBottom(space)
.pinLeading(space)
.pinTrailingLessThanOrEqualTo(anchor: nil, constant: space)
bottomView
.pinLeading(space*2)
.pinTrailing(space*2)
.pinBottom(space*2)
bottomLabel
.pinTop(space)
.pinLeading(space)
.pinTrailing(space)
.pinBottom(anchor: bottomButton.topAnchor, constant: space)
bottomButton
.pinBottom(space)
.pinLeading(space)
.pinTrailingLessThanOrEqualTo(anchor: nil, constant: space)
addContentTopView(view: .makeWrapper(for: component))
component.width = 300
component.color = .secondary
component.accessibilityLabel = "Tile Container"
addContentTopView(view: component)
component.addContentView(mainView)
let level2View = View()
level2View.backgroundColor = .purple
let level3View = View()
level3View.backgroundColor = .yellow
level2View.addSubview(level3View)
level3View.pinToSuperView(.uniform(15))
let level2label = Label()
level2label.text = "Do you want to Register?"
level3View.addSubview(level2label)
level2label.pinTop().pinLeading()
let level3Button = Button()
level3Button.setTitle("Register", for: .normal)
level3View.addSubview(level3Button)
level3Button.pinTop(anchor: level2label.bottomAnchor, constant: 5)
level3Button.pinLeading()
let level4View = View()
level4View.backgroundColor = .green
level3View.addSubview(level4View)
level4View.pinTop(anchor: level3Button.bottomAnchor, constant: 10)
level4View.pinLeading()
level4View.pinBottom()
level4View.pinTrailing()
let level4Label = Label()
level4Label.text = "Forgot your info?"
level4View.addSubview(level4Label)
level4Label.pinTop().pinLeading()
let level4Button = Button()
level4Button.setTitle("Forgot Password", for: .normal)
level4View.addSubview(level4Button)
level4Button.pinTop(anchor: level4Label.bottomAnchor, constant: 5)
level4Button.pinLeading().pinBottom()
component.addContentView(level2View)
setupPicker()
setupModel()
}
@ -194,18 +159,22 @@ class TileContainerViewController: BaseViewController<TileContainer> {
$0.text = "For testing max width is limited to 85% of view's width & 65% view's height."
})
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Is Link", view: isLinkSwitch, pinTrailing: false)
addFormRow(label: "Clickable", view: clickableSwitch, pinTrailing: false)
addFormRow(label: "Is Link", view: isLinkSwitch)
addFormRow(label: "Clickable", view: clickableSwitch)
addFormRow(label: "Width", view: widthTextField)
addFormRow(label: "Height", view: heightTextField)
addFormRow(label: "Show Border", view: showBorderSwitch, pinTrailing: false)
addFormRow(label: "Show Drop Shadow", view: showDropShadowSwitch, pinTrailing: false)
append(section: backgroundColorPickerSelectorView)
addFormRow(label: "Show Border", view: showBorderSwitch)
addFormRow(label: "Show Drop Shadow", view: showDropShadowSwitch)
addFormRow(label: "Background Color", view: backgroundColorPickerSelectorView)
addFormRow(label: "Padding", view: paddingPickerSelectorView)
customPaddingRowView = addFormRow(label: "Custom Padding", view: paddingTextField)
customPaddingRowView?.isHidden = true
let rowView = addFormRow(label: "Content area BG color(only for padding validation)", view: contentAreaBackgroundColorButton)
if let rowView = rowView as? UIStackView {
rowView.alignment = .top
}
addFormRow(label: "Aspect Ratio", view: scalingTypePickerSelectorView)
addFormRow(label: "Background Image", view: showBackgroundImageSwitch, pinTrailing: false)
addFormRow(label: "Background Image", view: showBackgroundImageSwitch)
addFormRow(label: "Image Fallback Color", view: imageFallbackColorPickerSelectorView)
addFormRow(label: "Background Effect", view: backgroundEffectSelectorView)
//Gradient Section
@ -254,35 +223,20 @@ class TileContainerViewController: BaseViewController<TileContainer> {
heightTextField
.numberPublisher
.sink { [weak self] number in
guard let self, let number = number?.cgFloatValue else {
self?.heightTextField.text = ""
return
}
if number >= 100 && number < self.view.frame.height * 0.65 {
self.component.height = number
} else {
self.component.height = nil
}
if let val = heightTextField.text, val.count > 2, number < 100 {
heightTextField.text = ""
guard let self else { return }
if let value = number?.cgFloatValue, value >= 100 && value < self.view.frame.height * 0.65 {
self.component.height = value
self.component.layoutIfNeeded()
}
}.store(in: &subscribers)
widthTextField
.numberPublisher
.sink { [weak self] number in
self?.updateComponentConstraint(pinTrailing: number == nil)
guard let self, let number = number?.cgFloatValue else {
self?.widthTextField.text = ""
return
}
if number >= 100 && number < self.view.frame.width * 0.85 {
self.component.width = number
} else {
self.component.width = nil
}
if let val = widthTextField.text, val.count > 2, number < 100 {
widthTextField.text = ""
guard let self else { return }
if let value = number?.cgFloatValue, value >= 100 && value < self.view.frame.width * 0.85 {
self.component.width = value
self.component.layoutIfNeeded()
}
}.store(in: &subscribers)
}
@ -290,7 +244,7 @@ class TileContainerViewController: BaseViewController<TileContainer> {
func setupModel() {
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
backgroundColorPickerSelectorView.setDefault(value: backgroundColor)
backgroundColorPickerSelectorView.text = backgroundColor.rawValue
paddingPickerSelectorView.text = padding.rawValue
scalingTypePickerSelectorView.text = component.aspectRatio.rawValue
widthTextField.text = component.width != nil ? "\(component.width!)" : ""
@ -304,6 +258,16 @@ class TileContainerViewController: BaseViewController<TileContainer> {
self?.contentTopView.backgroundColor = item.color
}
backgroundColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
guard let self else { return }
if let color = item.color {
self.component.color = color
} else {
self.colorPickerType = .backgroundColor
self.present(self.colorPicker, animated: true)
}
}
backgroundEffectSelectorView.onPickerDidSelect = { [weak self] in
guard let self else { return }
if let effect = $0.effect {
@ -312,6 +276,7 @@ class TileContainerViewController: BaseViewController<TileContainer> {
self.gradientColorView1.selectedColor = nil
self.gradientColorView2.selectedColor = nil
} else {
self.colorPickerType = .gradientColor1
self.gradientColorsFormStackView.isHidden = false
}
}
@ -335,12 +300,12 @@ class TileContainerViewController: BaseViewController<TileContainer> {
imageFallbackColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.imageFallbackColor = item
}
}
func updateGradientColors(){
if let selectedGradient1Color = gradientColorView1.selectedColor,
let selectedGradient2Color = gradientColorView2.selectedColor{
component.backgroundEffect = .gradient(selectedGradient1Color, selectedGradient2Color)
contentAreaBackgroundColorButton.onClick = { [weak self] _ in
guard let self else { return }
self.colorPickerType = .contentViewBackgroundColor
self.colorPicker.selectedColor = self.component.contentView.backgroundColor ?? .white
self.present(self.colorPicker, animated: true)
}
}
@ -355,6 +320,44 @@ extension TileContainerViewController: ComponentSampleable {
}
}
extension TileContainerViewController: UIColorPickerViewControllerDelegate {
func selectedColorTapped(_ picker: ColorPickerView<ColorPickerType>) {
let selectedColor = picker.selectedColor
if let selectedColor {
colorPicker.selectedColor = selectedColor
}
present(colorPicker, animated: true)
}
func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
dismiss(animated: true)
}
func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
let color = viewController.selectedColor
switch colorPickerType {
case .contentViewBackgroundColor:
component.contentView.backgroundColor = color
case .backgroundColor:
component.color = .custom(color)
case .gradientColor1:
gradientColorView1.selectedColor = viewController.selectedColor
updateGradientColors()
case .gradientColor2:
gradientColorView2.selectedColor = viewController.selectedColor
updateGradientColors()
}
}
func updateGradientColors(){
if let selectedGradient1Color = gradientColorView1.selectedColor,
let selectedGradient2Color = gradientColorView2.selectedColor{
component.backgroundEffect = .gradient(selectedGradient1Color, selectedGradient2Color)
}
}
}
extension TileContainerViewController {
//Created new BackgroundEffect enum for sample app only. Since we defined enum with associated value color defined in TileContainer cannot be RawRepresentable & CaseIterable
@ -387,7 +390,7 @@ extension TileContainerViewController {
//Created new BackgroundColor enum for sample app only. Since we defined enum with associated value color defined in TileContainer cannot be RawRepresentable & CaseIterable
enum BackgroundColor: String, CaseIterable {
case primary, secondary, white, black, token, custom
case primary, secondary, white, black, custom
var color: TileContainer.BackgroundColor? {
switch self {
@ -399,8 +402,6 @@ extension TileContainerViewController {
.white
case .black:
.black
case .token:
nil
case .custom:
nil
}

File diff suppressed because it is too large Load Diff

View File

@ -36,6 +36,21 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
var titleTextField = TextField()
var subTitleTextField = TextField()
/// **********************************************
/// Text Color
lazy var colorPicker: UIColorPickerViewController = {
let picker = UIColorPickerViewController()
picker.delegate = self
return picker
}()
var currentLabelType: LabelType = .title
var colorPickerType: ColorPickerType = .custom
enum LabelType {
case eyebrow, title, subtitle
}
enum TitleTextColor: String, CaseIterable {
case primary, token, custom
}
@ -44,80 +59,80 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
case primary, secondary, token, custom
}
enum ColorPickerType {
case custom
}
/// eyebrow
var eyeBrowTextColor: TitleLockup.TextColor = .primary { didSet { setOtherModels() } }
lazy var eyebrowTextColorFormSection = {
TokenColorPickerSection<TextColor>(rowTitle: "Text Color",
picker: self.picker).with {
$0.onSelected = { [weak self] item in
guard let self else { return }
switch item {
case .primary:
eyeBrowTextColor = .primary
case .secondary:
eyeBrowTextColor = .secondary
default: break
}
}
$0.onTokenSelected = { [weak self] color in
guard let self else { return }
eyeBrowTextColor = .token(color)
}
$0.onColorSelected = { [weak self] color in
guard let self else { return }
eyeBrowTextColor = .custom(color)
}
var eyebrowTokenFormStackView = FormSection().with { $0.isHidden = true }
var eyebrowColorFormStackView = FormSection().with { $0.isHidden = true }
lazy var eyebrowColorPickerSelectorView = {
PickerSelectorView(title: "primary",
picker: self.picker,
items: TextColor.allCases)
}()
lazy var eyebrowTokenColorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: UIColor.VDSColor.allCases)
.with { $0.text = UIColor.VDSColor.paletteBlack.rawValue }
}()
lazy var eyebrowCustomColorView: ColorPickerView<ColorPickerType> = {
return .init(with: ColorPickerType.custom, color: .black) { [weak self] picker in
self?.colorPickerType = picker.pickerType
self?.selectedColorTapped(picker)
}
}()
var subtitleTextColor: TitleLockup.TextColor = .primary { didSet { setOtherModels() } }
lazy var subTitleTextColorFormSection = {
TokenColorPickerSection<TextColor>(rowTitle: "Text Color",
picker: self.picker).with {
$0.onSelected = { [weak self] item in
guard let self else { return }
switch item {
case .primary:
subtitleTextColor = .primary
case .secondary:
subtitleTextColor = .secondary
default: break
}
}
$0.onTokenSelected = { [weak self] color in
guard let self else { return }
subtitleTextColor = .token(color)
}
$0.onColorSelected = { [weak self] color in
guard let self else { return }
subtitleTextColor = .custom(color)
}
/// title
var titleTokenFormStackView = FormSection().with { $0.isHidden = true }
var titleColorFormStackView = FormSection().with { $0.isHidden = true }
lazy var titleColorPickerSelectorView = {
PickerSelectorView(title: "primary",
picker: self.picker,
items: TitleTextColor.allCases)
}()
lazy var titleTokenColorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: UIColor.VDSColor.allCases)
.with { $0.text = UIColor.VDSColor.paletteBlack.rawValue }
}()
lazy var titleCustomColorView: ColorPickerView<ColorPickerType> = {
return .init(with: ColorPickerType.custom, color: .black) { [weak self] picker in
self?.colorPickerType = picker.pickerType
self?.selectedColorTapped(picker)
}
}()
var titleTextColor: TitleLockup.TitleTextColor = .primary { didSet { setTitleModel() } }
lazy var titleTextColorFormSection = {
TokenColorPickerSection<TitleTextColor>(rowTitle: "Text Color",
picker: self.picker).with {
$0.onSelected = { [weak self] item in
guard let self else { return }
switch item {
case .primary:
titleTextColor = .primary
default: break
}
}
$0.onTokenSelected = { [weak self] color in
guard let self else { return }
titleTextColor = .token(color)
}
$0.onColorSelected = { [weak self] color in
guard let self else { return }
titleTextColor = .custom(color)
}
/// subtitle
var subtitleTokenFormStackView = FormSection().with { $0.isHidden = true }
var subtitleColorFormStackView = FormSection().with { $0.isHidden = true }
lazy var subtitleColorPickerSelectorView = {
PickerSelectorView(title: "primary",
picker: self.picker,
items: TextColor.allCases)
}()
lazy var subtitleTokenColorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: UIColor.VDSColor.allCases)
.with { $0.text = UIColor.VDSColor.paletteBlack.rawValue }
}()
lazy var subtitleCustomColorView: ColorPickerView<ColorPickerType> = {
return .init(with: ColorPickerType.custom, color: .black) { [weak self] picker in
self?.colorPickerType = picker.pickerType
self?.selectedColorTapped(picker)
}
}()
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component)
@ -131,32 +146,31 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Text Alignment", view: textAlignmentPickerSelectorView)
append(section: .init().with({
$0.title = "Text Styles"
$0.addFormRow(label: "Title", view: titleStandardStylePickerSelectorView)
$0.addFormRow(label: "Eyebrow/Subtitle", view: otherStandardStylePickerSelectorView)
}))
addFormRow(label: "Eyebrow/Subtitle Style", view: otherStandardStylePickerSelectorView)
addFormRow(label: "Eyebrow is Bold", view: eyebrowIsBold)
addFormRow(label: "Eyebrow Text", view: eyebrowTextField)
addFormRow(label: "Eyebrow Color", view: eyebrowColorPickerSelectorView)
eyebrowTokenFormStackView.addFormRow(label: "Token", view: eyebrowTokenColorView)
eyebrowColorFormStackView.addFormRow(label: "Custom", view: eyebrowCustomColorView)
append(section: eyebrowTokenFormStackView)
append(section: eyebrowColorFormStackView)
append(section: .init().with({
$0.title = "\nEyebrow"
$0.addFormRow(label: "is Bold", view: eyebrowIsBold, pinTrailing: false)
$0.addFormRow(label: "Text", view: eyebrowTextField)
}))
addFormRow(label: "Title is Bold", view: titleIsBold)
addFormRow(label: "Title Style", view: titleStandardStylePickerSelectorView)
addFormRow(label: "Title Text", view: titleTextField)
addFormRow(label: "Title Color", view: titleColorPickerSelectorView)
titleTokenFormStackView.addFormRow(label: "Token", view: titleTokenColorView)
titleColorFormStackView.addFormRow(label: "Custom", view: titleCustomColorView)
append(section: titleTokenFormStackView)
append(section: titleColorFormStackView)
append(section: eyebrowTextColorFormSection)
addFormRow(label: "Subtitle Text", view: subTitleTextField)
addFormRow(label: "Subtitle Color", view: subtitleColorPickerSelectorView)
subtitleTokenFormStackView.addFormRow(label: "Token", view: subtitleTokenColorView)
subtitleColorFormStackView.addFormRow(label: "Custom", view: subtitleCustomColorView)
append(section: subtitleTokenFormStackView)
append(section: subtitleColorFormStackView)
append(section: .init().with({
$0.title = "\nTitle"
$0.addFormRow(label: "is Bold", view: titleIsBold, pinTrailing: false)
$0.addFormRow(label: "Text", view: titleTextField)
}))
append(section: titleTextColorFormSection)
append(section: .init().with({
$0.title = "\nSubtitle"
$0.addFormRow(label: "Subtitle Text", view: subTitleTextField)
}))
append(section: subTitleTextColorFormSection)
eyebrowIsBold.publisher(for: .valueChanged).sink { [weak self] toggle in
self?.setOtherModels()
@ -203,10 +217,6 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
titleTextField.text = titleModel.text
subTitleTextField.text = subTitleModel.text
eyebrowTextColorFormSection.setDefault(value: .primary)
titleTextColorFormSection.setDefault(value: .primary)
subTitleTextColorFormSection.setDefault(value: .primary)
setTitleModel()
updateOtherTextStyles()
}
@ -215,7 +225,21 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
var titleTextStyle: TextStyle?
if let text = titleTextField.text, !text.isEmpty {
component.titleModel = TitleLockup.TitleModel(text: text, textColor: titleTextColor, isBold: titleIsBold.isOn, standardStyle: titleStandardStylePickerSelectorView.selectedItem)
var textColor: TitleLockup.TitleTextColor
switch titleColorPickerSelectorView.selectedItem {
case .primary:
textColor = .primary
case .token:
textColor = .token(titleTokenColorView.selectedItem)
case .custom:
if let color = titleCustomColorView.selectedColor {
textColor = .custom(color)
} else {
textColor = .custom(VDSColor.elementsPrimaryOnlight)
}
}
component.titleModel = TitleLockup.TitleModel(text: text, textColor: textColor, isBold: titleIsBold.isOn, standardStyle: titleStandardStylePickerSelectorView.selectedItem)
titleTextStyle = titleIsBold.isOn ? titleStandardStylePickerSelectorView.selectedItem.value.bold : titleStandardStylePickerSelectorView.selectedItem.value.regular
} else {
component.titleModel = nil
@ -234,14 +258,44 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
let style = otherStandardStylePickerSelectorView.selectedItem
if let text = subTitleTextField.text, !text.isEmpty {
component.subTitleModel = TitleLockup.SubTitleModel(text: text, otherStandardStyle: style, textColor: subtitleTextColor)
var textColor: TitleLockup.TextColor
switch subtitleColorPickerSelectorView.selectedItem {
case .primary:
textColor = .primary
case .secondary:
textColor = .secondary
case .token:
textColor = .token(subtitleTokenColorView.selectedItem)
case .custom:
if let color = subtitleCustomColorView.selectedColor {
textColor = .custom(color)
} else {
textColor = .custom(VDSColor.elementsPrimaryOnlight)
}
}
component.subTitleModel = TitleLockup.SubTitleModel(text: text, otherStandardStyle: style, textColor: textColor)
debug(type: "SubTitle", textStyle: style.value.regular)
} else {
component.subTitleModel = nil
}
if let text = eyebrowTextField.text, !text.isEmpty {
component.eyebrowModel = TitleLockup.EyebrowModel(text: text, textColor: eyeBrowTextColor, isBold: eyebrowIsBold.isOn, standardStyle: style)
var textColor: TitleLockup.TextColor
switch eyebrowColorPickerSelectorView.selectedItem {
case .primary:
textColor = .primary
case .secondary:
textColor = .secondary
case .token:
textColor = .token(eyebrowTokenColorView.selectedItem)
case .custom:
if let color = eyebrowCustomColorView.selectedColor {
textColor = .custom(color)
} else {
textColor = .custom(VDSColor.elementsPrimaryOnlight)
}
}
component.eyebrowModel = TitleLockup.EyebrowModel(text: text, textColor: textColor, isBold: eyebrowIsBold.isOn, standardStyle: style)
debug(type: "EyeBrow", textStyle: eyebrowIsBold.isOn ? style.value.bold : style.value.regular)
} else {
@ -273,6 +327,40 @@ class TitleLockupViewController: BaseViewController<TitleLockup> {
otherStandardStylePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.setOtherModels()
}
eyebrowColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.currentLabelType = .eyebrow
self?.eyebrowTokenFormStackView.isHidden = item != .token
self?.eyebrowColorFormStackView.isHidden = item != .custom
self?.setOtherModels()
}
eyebrowTokenColorView.onPickerDidSelect = { [weak self] item in
self?.setOtherModels()
}
titleColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.currentLabelType = .title
self?.titleTokenFormStackView.isHidden = item != .token
self?.titleColorFormStackView.isHidden = item != .custom
self?.setTitleModel()
}
titleTokenColorView.onPickerDidSelect = { [weak self] item in
self?.setTitleModel()
}
subtitleColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.currentLabelType = .subtitle
self?.subtitleTokenFormStackView.isHidden = item != .token
self?.subtitleColorFormStackView.isHidden = item != .custom
self?.setOtherModels()
}
subtitleTokenColorView.onPickerDidSelect = { [weak self] item in
self?.setOtherModels()
}
}
}
@ -289,3 +377,40 @@ extension TitleLockupViewController: ComponentSampleable {
return ComponentSample(component: component)
}
}
extension TitleLockupViewController: UIColorPickerViewControllerDelegate {
func selectedColorTapped(_ picker: ColorPickerView<ColorPickerType>) {
let selectedColor = picker.selectedColor
if let selectedColor {
colorPicker.selectedColor = selectedColor
}
present(colorPicker, animated: true)
}
func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
dismiss(animated: true)
}
func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
guard let hexString = viewController.selectedColor.hexString else { return }
var colorView: ColorPickerView<ColorPickerType>
switch currentLabelType {
case .eyebrow:
colorView = eyebrowCustomColorView
case .title:
colorView = titleCustomColorView
case .subtitle:
colorView = subtitleCustomColorView
}
colorView.selectedColor = viewController.selectedColor
if currentLabelType == .title {
setTitleModel()
} else {
setOtherModels()
}
}
}

View File

@ -36,7 +36,7 @@ class ToggleViewController: BaseViewController<Toggle> {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: component.makeWrapper(edgeSpacing: 16.0), edgeSpacing: 0)
setupPicker()
}
@ -44,12 +44,12 @@ class ToggleViewController: BaseViewController<Toggle> {
override func setupForm() {
super.setupForm()
addActionRow()
addFormRow(label: "Show Text", view: showTextSwitch, pinTrailing: false)
addFormRow(label: "Show Text", view: showTextSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
//add the hidden elements to textFormStackView
textFormStackView.addFormRow(label: "Bold", view: boldSwitch, pinTrailing: false)
textFormStackView.addFormRow(label: "Bold", view: boldSwitch)
textFormStackView.addFormRow(label: "Text Size", view: textSizePickerSelectorView)
textFormStackView.addFormRow(label: "Text Position", view: textPositionPickerSelectorView)
textFormStackView.addFormRow(label: "On Text", view: onTextField)

View File

@ -32,14 +32,15 @@ class TooltipViewController: BaseViewController<Tooltip> {
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
setupPicker()
setupModel()
}
override func setupForm(){
super.setupForm()
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Size", view: sizePickerSelectorView)
addFormRow(label: "FillColor", view: fillColorPickerSelectorView)

View File

@ -40,15 +40,16 @@ class TrailingTooltipLabelViewController: BaseViewController<TrailingTooltipLabe
override func viewDidLoad() {
super.viewDidLoad()
addContentTopView(view: component, pinTrailing: false)
addContentTopView(view: .makeWrapper(for: component, edgeSpacing: 16.0), edgeSpacing: 0.0)
setupPicker()
setupModel()
}
override func setupForm(){
super.setupForm()
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
addFormRow(label: "Bold", view: boldSwitch, pinTrailing: false)
addFormRow(label: "Disabled", view: disabledSwitch)
addFormRow(label: "Bold", view: boldSwitch)
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Text Alignment", view: textAlignmentPickerSelectorView)
addFormRow(label: "Font Category", view: fontCategoryPickerSelectorView)