Compare commits

...

7 Commits

Author SHA1 Message Date
Matt Bruce
e484d95d81 added device ipad
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-10-17 16:14:28 -05:00
Matt Bruce
be7d68636a updated samples
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-10-09 16:30:26 -05:00
Matt Bruce
48c9c087f8 slight refactor
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-10-09 13:11:06 -05:00
Matt Bruce
2e55d2d231 removed tilelet maker
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-10-09 12:40:53 -05:00
Matt Bruce
0af044be4b helper to build tilelet
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-10-09 12:40:36 -05:00
Matt Bruce
de8151eefc Merge branch 'develop' into feature/tileletGroup
# Conflicts:
#	VDSSample.xcodeproj/project.pbxproj

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-10-09 08:46:15 -05:00
Matt Bruce
977a376ce3 initial work
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-10-09 08:20:32 -05:00
7 changed files with 201 additions and 33 deletions

View File

@ -107,6 +107,7 @@
EAF7F0CC289DA24F00B287F5 /* DownloadArtifactoryItems.sh in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C8289DA24F00B287F5 /* DownloadArtifactoryItems.sh */; }; EAF7F0CC289DA24F00B287F5 /* DownloadArtifactoryItems.sh in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C8289DA24F00B287F5 /* DownloadArtifactoryItems.sh */; };
EAF7F0CD289DA24F00B287F5 /* Artifactory.sh in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C9289DA24F00B287F5 /* Artifactory.sh */; }; EAF7F0CD289DA24F00B287F5 /* Artifactory.sh in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F0C9289DA24F00B287F5 /* Artifactory.sh */; };
EAF7F11A28A14A0E00B287F5 /* RadioButtonGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F11928A14A0E00B287F5 /* RadioButtonGroupViewController.swift */; }; EAF7F11A28A14A0E00B287F5 /* RadioButtonGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F11928A14A0E00B287F5 /* RadioButtonGroupViewController.swift */; };
EAFD5AA42CB5D95600C87DE1 /* TileletGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAFD5AA32CB5D95600C87DE1 /* TileletGroupViewController.swift */; };
EAFD5A9D2CB4609900C87DE1 /* TokenColorPickerFormSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAFD5A9C2CB4609900C87DE1 /* TokenColorPickerFormSection.swift */; }; EAFD5A9D2CB4609900C87DE1 /* TokenColorPickerFormSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAFD5A9C2CB4609900C87DE1 /* TokenColorPickerFormSection.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -214,6 +215,7 @@
EAF7F0C8289DA24F00B287F5 /* DownloadArtifactoryItems.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = DownloadArtifactoryItems.sh; sourceTree = "<group>"; }; 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>"; }; 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>"; }; EAF7F11928A14A0E00B287F5 /* RadioButtonGroupViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonGroupViewController.swift; sourceTree = "<group>"; };
EAFD5AA32CB5D95600C87DE1 /* TileletGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileletGroupViewController.swift; sourceTree = "<group>"; };
EAFD5A9C2CB4609900C87DE1 /* TokenColorPickerFormSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenColorPickerFormSection.swift; sourceTree = "<group>"; }; EAFD5A9C2CB4609900C87DE1 /* TokenColorPickerFormSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenColorPickerFormSection.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -374,6 +376,7 @@
EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */, EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */,
EA5E304F294D11540082B959 /* TileContainerViewController.swift */, EA5E304F294D11540082B959 /* TileContainerViewController.swift */,
EA5E305B295111050082B959 /* TileletViewController.swift */, EA5E305B295111050082B959 /* TileletViewController.swift */,
EAFD5AA32CB5D95600C87DE1 /* TileletGroupViewController.swift */,
EA5E30542950EA6E0082B959 /* TitleLockupViewController.swift */, EA5E30542950EA6E0082B959 /* TitleLockupViewController.swift */,
EA3C3BB328996775000CA526 /* ToggleViewController.swift */, EA3C3BB328996775000CA526 /* ToggleViewController.swift */,
EAB2375F29E88D5D00AABE9A /* TooltipViewController.swift */, EAB2375F29E88D5D00AABE9A /* TooltipViewController.swift */,
@ -541,6 +544,7 @@
EA5E3050294D11540082B959 /* TileContainerViewController.swift in Sources */, EA5E3050294D11540082B959 /* TileContainerViewController.swift in Sources */,
445BA07A29C088470036A7C5 /* NotificationViewController.swift in Sources */, 445BA07A29C088470036A7C5 /* NotificationViewController.swift in Sources */,
EAEEEC942B1F824500531FC2 /* Bundle.swift in Sources */, EAEEEC942B1F824500531FC2 /* Bundle.swift in Sources */,
EAFD5AA42CB5D95600C87DE1 /* TileletGroupViewController.swift in Sources */,
EAF7F11A28A14A0E00B287F5 /* RadioButtonGroupViewController.swift in Sources */, EAF7F11A28A14A0E00B287F5 /* RadioButtonGroupViewController.swift in Sources */,
EA89204628B66CE2006B9984 /* ScrollViewController.swift in Sources */, EA89204628B66CE2006B9984 /* ScrollViewController.swift in Sources */,
EA471F402A97BEAA00CE9E58 /* CustomRotorable.swift in Sources */, EA471F402A97BEAA00CE9E58 /* CustomRotorable.swift in Sources */,

View File

@ -16,12 +16,9 @@ public class ColorPickerView: UIStackView, UIColorPickerViewControllerDelegate {
} }
} }
private var colorPicker: UIColorPickerViewController = { public var onColorSelected: ((UIColor) -> Void)?
let picker = UIColorPickerViewController()
return picker
}()
var selectedColorView: UIView = { private var selectedColorView: UIView = {
let view = UIView() let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false view.translatesAutoresizingMaskIntoConstraints = false
view.widthAnchor.constraint(equalToConstant: 20).isActive = true view.widthAnchor.constraint(equalToConstant: 20).isActive = true
@ -29,25 +26,16 @@ public class ColorPickerView: UIStackView, UIColorPickerViewControllerDelegate {
return view return view
}() }()
var button = Button().with { private var button = Button().with {
$0.size = .small $0.size = .small
$0.use = .secondary $0.use = .secondary
$0.text = "Select" $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(color: UIColor? = nil) {
super.init(frame: .zero) super.init(frame: .zero)
if let color { self.selectedColor = color
selectedColor = color
}
colorPicker.delegate = self
setup() setup()
button.onClick = { _ in
UIApplication.topViewController()?.present(self.colorPicker, animated: true)
}
} }
required init(coder: NSCoder) { required init(coder: NSCoder) {
@ -66,7 +54,6 @@ public class ColorPickerView: UIStackView, UIColorPickerViewControllerDelegate {
indicatorWrapper.pinLeading() indicatorWrapper.pinLeading()
indicatorWrapper.pinBottom() indicatorWrapper.pinBottom()
indicatorWrapper.pinTrailingGreaterThanOrEqualTo(anchor: indicatorWrapper.trailingAnchor) indicatorWrapper.pinTrailingGreaterThanOrEqualTo(anchor: indicatorWrapper.trailingAnchor)
addArrangedSubview(indicatorWrapper) addArrangedSubview(indicatorWrapper)
let buttonWrapper = View() let buttonWrapper = View()
@ -77,16 +64,23 @@ public class ColorPickerView: UIStackView, UIColorPickerViewControllerDelegate {
button.pinBottom() button.pinBottom()
button.pinLeadingGreaterThanOrEqualTo(anchor: buttonWrapper.leadingAnchor) button.pinLeadingGreaterThanOrEqualTo(anchor: buttonWrapper.leadingAnchor)
addArrangedSubview(buttonWrapper) addArrangedSubview(buttonWrapper)
button.onClick = { [weak self] _ in
guard let self = self else { return }
let colorPicker = UIColorPickerViewController()
colorPicker.title = "Select a Color"
colorPicker.delegate = self
if let selectedColor = self.selectedColor {
colorPicker.selectedColor = selectedColor
}
UIApplication.topViewController()?.present(colorPicker, animated: true)
}
} }
// MARK: - UIColorPickerViewControllerDelegate // MARK: - UIColorPickerViewControllerDelegate
public func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) { public func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
selectedColor = viewController.selectedColor selectedColor = viewController.selectedColor
onColorSelected?(viewController.selectedColor) onColorSelected?(viewController.selectedColor)
} }
public func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
UIApplication.topViewController()?.dismiss(animated: true)
}
} }

View File

@ -112,4 +112,35 @@ extension BaseViewController {
$0.labelPublisher(label) $0.labelPublisher(label)
} }
} }
func makeTilelet(badge: String? = nil, eyebrow: String? = nil, title: String? = nil, subTitle: String? = nil) -> Tilelet {
var badgeModel: Tilelet.BadgeModel?
if let badge {
badgeModel = Tilelet.BadgeModel(text: badge)
}
var eyebrowModel: Tilelet.EyebrowModel?
if let eyebrow {
eyebrowModel = Tilelet.EyebrowModel(text: eyebrow)
}
var titleModel: Tilelet.TitleModel?
if let title {
titleModel = Tilelet.TitleModel(text: title)
}
var subTitleModel: Tilelet.SubTitleModel?
if let subTitle {
subTitleModel = Tilelet.SubTitleModel(text: subTitle)
}
return .init().with {
$0.surface = .light
$0.badgeModel = badgeModel
$0.eyebrowModel = eyebrowModel
$0.titleModel = titleModel
$0.subTitleModel = subTitleModel
$0.directionalIconModel = .init(iconColor: .token(.paletteWhite), size: .small)
}
}
} }

View File

@ -85,19 +85,19 @@ public class TokenColorPickerSection<EnumType: RawRepresentable & CaseIterable>:
let isToken = item.rawValue == "token" let isToken = item.rawValue == "token"
let isCustom = item.rawValue == "custom" let isCustom = item.rawValue == "custom"
if isToken { if isToken {
self.onTokenSelected?(self.tokenColorView.selectedItem) onTokenSelected?(self.tokenColorView.selectedItem)
} else if let selectedItem = self.customColorView.selectedColor, isCustom { } else if let selectedItem = self.customColorView.selectedColor, isCustom {
self.onColorSelected?(selectedItem) onColorSelected?(selectedItem)
} else { } else {
self.onSelected?(item) onSelected?(item)
} }
self.tokenColorRow?.isHidden = !isToken tokenColorRow?.isHidden = !isToken
self.customColorRow?.isHidden = !isCustom customColorRow?.isHidden = !isCustom
} }
tokenColorView.onPickerDidSelect = { [weak self] item in tokenColorView.onPickerDidSelect = { [weak self] item in
guard let self else { return } guard let self else { return }
self.onTokenSelected?(item) onTokenSelected?(item)
} }
} }

View File

@ -109,7 +109,7 @@ class LabelViewController: BaseViewController<Label> {
let fullText = "Here is a sample of text that has an inline text link that you can click on!" let fullText = "Here is a sample of text that has an inline text link that you can click on!"
let linkText = "inline text link" let linkText = "that has an inline text link that you"
sampleLabel.textStyle = .titleLarge sampleLabel.textStyle = .titleLarge
sampleLabel.text = fullText sampleLabel.text = fullText

View File

@ -106,6 +106,7 @@ class MenuViewController: UITableViewController, TooltipLaunchable {
MenuComponent(title: "TextLinkCaret", completed: true, viewController: TextLinkCaretViewController.self), MenuComponent(title: "TextLinkCaret", completed: true, viewController: TextLinkCaretViewController.self),
MenuComponent(title: "TileContainer", completed: true, viewController: TileContainerViewController.self), MenuComponent(title: "TileContainer", completed: true, viewController: TileContainerViewController.self),
MenuComponent(title: "Tilelet", completed: true, viewController: TileletViewController.self), MenuComponent(title: "Tilelet", completed: true, viewController: TileletViewController.self),
MenuComponent(title: "TileletGroup", completed: true, viewController: TileletGroupViewController.self),
MenuComponent(title: "TitleLockup", completed: true, viewController: TitleLockupViewController.self), MenuComponent(title: "TitleLockup", completed: true, viewController: TitleLockupViewController.self),
MenuComponent(title: "Toggle", completed: true, viewController: ToggleViewController.self), MenuComponent(title: "Toggle", completed: true, viewController: ToggleViewController.self),
MenuComponent(title: "Tooltip", completed: true, viewController: TooltipViewController.self), MenuComponent(title: "Tooltip", completed: true, viewController: TooltipViewController.self),

View File

@ -0,0 +1,138 @@
//
// TileletGroupViewController.swift
// VDSSample
//
// Created by Matt Bruce on 10/8/24.
//
import Foundation
import UIKit
import VDS
import VDSCoreTokens
class TileletGroupViewController: BaseViewController<TileletGroup> {
var collectionView: UICollectionView!
public enum RowQuantity: String, CaseIterable {
case one, two, three
case four, five, six
init(quantity: Int){
if quantity == 1 {
self = .one
} else if quantity == 2 {
self = .two
} else if quantity == 3 {
self = .three
} else if quantity == 4 {
self = .four
} else if quantity == 5 {
self = .five
} else if quantity == 6 {
self = .six
} else {
self = UIDevice.isIPad ? .six : .three
}
}
var intValue: Int {
switch self {
case .one:
return 1
case .two:
return 2
case .three:
return 3
case .four:
return 4
case .five:
return 5
case .six:
return 6
}
}
public static var allCases: [TileletGroupViewController.RowQuantity] {
UIDevice.isIPad ? Self.allCases : [.one, .two, .three]
}
}
lazy var rowQuantitySelectorView = {
PickerSelectorView<RowQuantity>(title: "",
picker: self.picker,
items: RowQuantity.allCases)
}()
lazy var paddingSelectorView = {
PickerSelectorView<TileletGroup.Padding>(title: "",
picker: self.picker,
items: TileletGroup.Padding.allCases)
}()
var disabledSwitch = Toggle()
override func viewDidLoad() {
super.viewDidLoad()
resetTilets()
addContentTopView(view: component)
setupPicker()
setupModel()
debugViewSwitch.onChange = { [weak self] sender in
self?.component.debugBorder(show: sender.isOn, color: .blue)
}
}
func resetTilets() {
component.tilelets = [
makeTilelet(badge: "Here's the badge", title: "Title goes here"),
makeTilelet(title: "Title goes here"),
makeTilelet(subTitle: "Here's the subTitle"),
makeTilelet(eyebrow: "Here's the eyebrow", subTitle: "Here's the subTitle")
]
}
override func setupForm(){
super.setupForm()
addActionRow()
addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Disabled", view: disabledSwitch, pinTrailing: false)
if UIDevice.isIPad {
addFormRow(label: "Padding", view: paddingSelectorView)
}
addFormRow(label: "Row Quantity", view: rowQuantitySelectorView)
disabledSwitch.onChange = { [weak self] sender in
self?.component.isEnabled = !sender.isOn
}
}
func setupModel() {
//setup UI
surfacePickerSelectorView.text = component.surface.rawValue
disabledSwitch.isOn = !component.isEnabled
rowQuantitySelectorView.text = RowQuantity(quantity: component.rowQuantity).rawValue
}
func setupPicker(){
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.surface = item
self?.contentTopView.backgroundColor = item.color
}
paddingSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.padding = item
}
rowQuantitySelectorView.onPickerDidSelect = { [weak self] item in
if UIDevice.isIPad {
self?.component.rowQuantityTablet = item.intValue
} else {
self?.component.rowQuantityPhone = item.intValue
}
self?.resetTilets()
}
}
}