From 2253f0fadbf63d5883bccadb875044b72cc6e3ea Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 5 Jun 2024 10:56:37 -0500 Subject: [PATCH] got titlelockup example working Signed-off-by: Matt Bruce --- .../TileletViewController.swift | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/VDSSample/ViewControllers/TileletViewController.swift b/VDSSample/ViewControllers/TileletViewController.swift index e4e0c10..74329bc 100644 --- a/VDSSample/ViewControllers/TileletViewController.swift +++ b/VDSSample/ViewControllers/TileletViewController.swift @@ -71,7 +71,7 @@ class TileletViewController: BaseViewController { enum ColorPickerType { case backgroundColor case gradientColor1, gradientColor2 - case contentViewBackgroundColor, custom + case contentViewBackgroundColor, token, custom } lazy var gradientColorView1: ColorPickerView = { @@ -114,6 +114,10 @@ class TileletViewController: BaseViewController { case primary, secondary, token, custom } + enum IconColor: String, CaseIterable { + case token, custom + } + /// eyebrow var eyebrowColorsFormStackView = FormSection().with { $0.isHidden = true } lazy var eyebrowColorPickerSelectorView = { @@ -605,14 +609,8 @@ class TileletViewController: BaseViewController { let token = descriptionIconTokenColorView.selectedItem let iconSize = descriptionIconSizePickerSelectorView.selectedItem let iconName = descriptionNamePickerSelectorView.selectedItem - - if let iconColor { - component.descriptiveIconModel = .init(name: iconName, - iconColor: iconColor, size: iconSize) - } else { - component.descriptiveIconModel = .init(name: iconName, - size: iconSize) - } + let iconColor: Tilelet.IconColor = colorPickerType == .token ? .token(token) : .custom(custom) + component.descriptiveIconModel = .init(name: iconName, iconColor: iconColor, size: iconSize) } func setDirectionalIconModel() { @@ -620,12 +618,8 @@ class TileletViewController: BaseViewController { let token = directionalIconTokenColorView.selectedItem let iconType = directionIconPickerSelectorView.selectedItem let iconSize = directionIconSizePickerSelectorView.selectedItem - - if let iconColor { - component.directionalIconModel = .init(iconType: iconType, iconColor: iconColor, size: iconSize) - } else { - component.directionalIconModel = .init(iconType: iconType, size: iconSize) - } + let iconColor: Tilelet.IconColor = colorPickerType == .token ? .token(token) : .custom(custom) + component.directionalIconModel = .init(iconType: iconType, iconColor: iconColor, size: iconSize) } func updateOtherTextStyles() { @@ -731,6 +725,11 @@ class TileletViewController: BaseViewController { self?.setDescriptiveIconModel() } + descriptionIconTokenColorView.onPickerDidSelect = { [weak self] item in + self?.colorPickerType = .token + self?.setDescriptiveIconModel() + } + directionIconPickerSelectorView.onPickerDidSelect = { [weak self] item in self?.setDirectionalIconModel() } @@ -738,6 +737,11 @@ class TileletViewController: BaseViewController { directionIconSizePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.setDirectionalIconModel() } + + directionalIconTokenColorView.onPickerDidSelect = { [weak self] item in + self?.colorPickerType = .token + self?.setDirectionalIconModel() + } } func getTilelet(effect: TileContainer.BackgroundEffect) -> Tilelet.BackgroundEffect { @@ -810,7 +814,6 @@ extension TileletViewController: UIColorPickerViewControllerDelegate { case .gradientColor2: gradientColorView2.selectedColor = viewController.selectedColor updateGradientColors() - case .custom: var colorView: ColorPickerView @@ -839,7 +842,9 @@ extension TileletViewController: UIColorPickerViewControllerDelegate { setDirectionalIconModel() case .descriptionIcon: setDescriptiveIconModel() - } + } + default: + break } }