From aedf4eb52020c69127df3c34abf2b0b6281f668e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 14 Jun 2024 15:44:23 -0500 Subject: [PATCH 1/9] added token/custom color ui changes Signed-off-by: Matt Bruce --- .../TileContainerViewController.swift | 58 ++++++++++++++---- .../TileletViewController.swift | 61 +++++++++++++++---- 2 files changed, 93 insertions(+), 26 deletions(-) diff --git a/VDSSample/ViewControllers/TileContainerViewController.swift b/VDSSample/ViewControllers/TileContainerViewController.swift index 9a8d81c..0c3a530 100644 --- a/VDSSample/ViewControllers/TileContainerViewController.swift +++ b/VDSSample/ViewControllers/TileContainerViewController.swift @@ -19,12 +19,6 @@ class TileContainerViewController: BaseViewController { return picker }() - lazy var backgroundColorPickerSelectorView = { - PickerSelectorView(title: "white", - picker: self.picker, - items: BackgroundColor.allCases) - }() - lazy var imageFallbackColorPickerSelectorView = { SurfacePickerSelectorView(picker: self.picker) }() @@ -76,9 +70,9 @@ class TileContainerViewController: BaseViewController { $0.placeholder = "Minimum 100px else it will occupy full container" } - var colorPickerType: ColorPickerType = .backgroundColor + var colorPickerType: ColorPickerType = .gradientColor1 enum ColorPickerType { - case backgroundColor, gradientColor1, gradientColor2, contentViewBackgroundColor + case custom, gradientColor1, gradientColor2, contentViewBackgroundColor } lazy var gradientColorView1: ColorPickerView = { @@ -95,6 +89,30 @@ class TileContainerViewController: BaseViewController { } }() + var backgroundColorTokenFormStackView = FormSection().with { $0.isHidden = true } + var backgroundColorFormStackView = FormSection().with { $0.isHidden = true } + + lazy var backgroundColorPickerSelectorView = { + PickerSelectorView(title: "", + picker: self.picker, + items: BackgroundColor.allCases) + .with { $0.text = BackgroundColor.white.rawValue } + }() + + lazy var backgroundColorTokenColorView = { + PickerSelectorView(title: "", + picker: self.picker, + items: UIColor.VDSColor.allCases) + .with { $0.text = UIColor.VDSColor.paletteWhite.rawValue } + }() + + lazy var backgroundColorCustomColorView: ColorPickerView = { + return .init(with: ColorPickerType.custom, color: .white) { [weak self] picker in + self?.colorPickerType = picker.pickerType + self?.selectedColorTapped(picker) + } + }() + override func viewDidLoad() { super.viewDidLoad() addContentTopView(view: .makeWrapper(for: component)) @@ -166,6 +184,13 @@ class TileContainerViewController: BaseViewController { addFormRow(label: "Show Border", view: showBorderSwitch) addFormRow(label: "Show Drop Shadow", view: showDropShadowSwitch) addFormRow(label: "Background Color", view: backgroundColorPickerSelectorView) + + backgroundColorTokenFormStackView.addFormRow(label: "Token", view: backgroundColorTokenColorView) + backgroundColorFormStackView.addFormRow(label: "Custom", view: backgroundColorCustomColorView) + append(section: backgroundColorTokenFormStackView) + append(section: backgroundColorFormStackView) + + addFormRow(label: "Padding", view: paddingPickerSelectorView) customPaddingRowView = addFormRow(label: "Custom Padding", view: paddingTextField) customPaddingRowView?.isHidden = true @@ -263,11 +288,15 @@ class TileContainerViewController: BaseViewController { if let color = item.color { self.component.color = color } else { - self.colorPickerType = .backgroundColor - self.present(self.colorPicker, animated: true) + backgroundColorTokenFormStackView.isHidden = item != .token + backgroundColorFormStackView.isHidden = item != .custom } } + backgroundColorTokenColorView.onPickerDidSelect = { [weak self] item in + self?.component.color = .token(item) + } + backgroundEffectSelectorView.onPickerDidSelect = { [weak self] in guard let self else { return } if let effect = $0.effect { @@ -339,14 +368,15 @@ extension TileContainerViewController: UIColorPickerViewControllerDelegate { 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() + case .custom: + backgroundColorCustomColorView.selectedColor = color + component.color = .custom(color) } } @@ -390,7 +420,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, custom + case primary, secondary, white, black, token, custom var color: TileContainer.BackgroundColor? { switch self { @@ -402,6 +432,8 @@ extension TileContainerViewController { .white case .black: .black + case .token: + nil case .custom: nil } diff --git a/VDSSample/ViewControllers/TileletViewController.swift b/VDSSample/ViewControllers/TileletViewController.swift index 5f6eb0c..e2fd6db 100644 --- a/VDSSample/ViewControllers/TileletViewController.swift +++ b/VDSSample/ViewControllers/TileletViewController.swift @@ -67,9 +67,8 @@ class TileletViewController: BaseViewController { return picker }() - var colorPickerType: ColorPickerType = .backgroundColor + var colorPickerType: ColorPickerType = .custom enum ColorPickerType { - case backgroundColor case gradientColor1, gradientColor2 case contentViewBackgroundColor, token, custom } @@ -88,12 +87,31 @@ class TileletViewController: BaseViewController { } }() + var backgroundColorTokenFormStackView = FormSection().with { $0.isHidden = true } + var backgroundColorFormStackView = FormSection().with { $0.isHidden = true } lazy var backgroundColorPickerSelectorView = { - PickerSelectorView(title: "white", + PickerSelectorView(title: "", picker: self.picker, items: BackgroundColor.allCases) + .with { $0.text = BackgroundColor.white.rawValue } }() + lazy var backgroundColorCustomColorView: ColorPickerView = { + return .init(with: ColorPickerType.custom, color: .white) { [weak self] picker in + self?.currentSurfaceColorType = .background + self?.colorPickerType = picker.pickerType + self?.selectedColorTapped(picker) + } + }() + + lazy var backgroundColorTokenColorView = { + PickerSelectorView(title: "", + picker: self.picker, + items: UIColor.VDSColor.allCases) + .with { $0.text = UIColor.VDSColor.paletteWhite.rawValue } + }() + + lazy var textAlignmentPickerSelectorView = { PickerSelectorView(title: "left", picker: self.picker, @@ -103,7 +121,7 @@ class TileletViewController: BaseViewController { /// titleLockup var currentSurfaceColorType: SurfaceColorType = .title enum SurfaceColorType { - case eyebrow, title, subtitle, directionalIcon, descriptionIcon + case background, eyebrow, title, subtitle, directionalIcon, descriptionIcon } enum TitleTextColor: String, CaseIterable { @@ -319,6 +337,13 @@ class TileletViewController: BaseViewController { addFormRow(label: "Text Percentage", view: textPercentageTextField) addFormRow(label: "Text Position", tooltip: .init(title:"Text Position", content: "Minimum height is configurable"), view: textPositionPickerSelectorView) addFormRow(label: "Background Color", tooltip: .init(title:"Background Color", content: "This color takes precedence over surface and will set all children's surface property to this value."), view: backgroundColorPickerSelectorView) + + backgroundColorTokenFormStackView.addFormRow(label: "Token", view: backgroundColorTokenColorView) + backgroundColorFormStackView.addFormRow(label: "Custom", view: backgroundColorCustomColorView) + append(section: backgroundColorTokenFormStackView) + append(section: backgroundColorFormStackView) + + addFormRow(label: "Background Image", view: showBackgroundImageSwitch) addFormRow(label: "Show Drop Shadow", view: showDropShadowSwitch) addFormRow(label: "Image Fallback Color", view: imageFallbackColorPickerSelectorView) @@ -394,7 +419,7 @@ class TileletViewController: BaseViewController { directionalIconFormStackView.addFormRow(label: "Size", view: directionIconSizePickerSelectorView) directionalIconFormStackView.addFormRow(label: "Color", view: directionalIconColorPickerSelectorView) directionalIconTokenFormStackView.addFormRow(label: "Token", view: directionalIconTokenColorView) - directionalIconColorFormStackView.addFormRow(label: "Dark", view: directionalIconCustomColorView) + directionalIconColorFormStackView.addFormRow(label: "Custom", view: directionalIconCustomColorView) append(section: directionalIconTokenFormStackView) append(section: directionalIconColorFormStackView) @@ -777,14 +802,18 @@ class TileletViewController: BaseViewController { backgroundColorPickerSelectorView.onPickerDidSelect = { [weak self] item in guard let self else { return } - if let color = self.getTilelet(backgroundColor: item) { - self.component.color = color + if let color = getTilelet(backgroundColor: item) { + component.color = color } else { - self.colorPickerType = .backgroundColor - self.present(self.colorPicker, animated: true) - } + backgroundColorTokenFormStackView.isHidden = item != .token + backgroundColorFormStackView.isHidden = item != .custom + } } + backgroundColorTokenColorView.onPickerDidSelect = { [weak self] item in + self?.component.color = .token(item) + } + eyebrowColorPickerSelectorView.onPickerDidSelect = { [weak self] item in self?.currentSurfaceColorType = .eyebrow self?.eyebrowTokenFormStackView.isHidden = item != .token @@ -878,6 +907,8 @@ class TileletViewController: BaseViewController { .black case .custom: nil + case .token: + nil } } } @@ -917,8 +948,6 @@ extension TileletViewController: UIColorPickerViewControllerDelegate { switch colorPickerType { case .contentViewBackgroundColor: component.contentView.backgroundColor = color - case .backgroundColor: - component.color = .custom(color) case .gradientColor1: gradientColorView1.selectedColor = viewController.selectedColor updateGradientColors() @@ -929,6 +958,8 @@ extension TileletViewController: UIColorPickerViewControllerDelegate { var colorView: ColorPickerView switch currentSurfaceColorType { + case .background: + colorView = backgroundColorCustomColorView case .eyebrow: colorView = eyebrowCustomColorView case .title: @@ -943,6 +974,8 @@ extension TileletViewController: UIColorPickerViewControllerDelegate { colorView.selectedColor = viewController.selectedColor switch currentSurfaceColorType { + case .background: + component.color = .custom(color) case .eyebrow: setEyebrowModel() case .title: @@ -971,7 +1004,7 @@ extension TileletViewController { enum BackgroundColor: String, CaseIterable { - case primary, secondary, white, black, custom + case primary, secondary, white, black, token, custom var color: TileContainer.BackgroundColor? { switch self { @@ -983,6 +1016,8 @@ extension TileletViewController { .white case .black: .black + case .token: + nil case .custom: nil } From b7185c5ffad80d0059422c0fe89aa9c3ca27a0bc Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 14 Jun 2024 15:52:24 -0500 Subject: [PATCH 2/9] refactored titlelockup into sections Signed-off-by: Matt Bruce --- .../TitleLockupViewController.swift | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/VDSSample/ViewControllers/TitleLockupViewController.swift b/VDSSample/ViewControllers/TitleLockupViewController.swift index 1c5ddb1..16702e4 100644 --- a/VDSSample/ViewControllers/TitleLockupViewController.swift +++ b/VDSSample/ViewControllers/TitleLockupViewController.swift @@ -146,31 +146,40 @@ class TitleLockupViewController: BaseViewController { addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Text Alignment", view: textAlignmentPickerSelectorView) - 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) + append(section: .init().with({ + $0.title = "\nEyebrow" + $0.addFormRow(label: "TextStyle (Subtitle)", view: otherStandardStylePickerSelectorView) + $0.addFormRow(label: "is Bold", view: eyebrowIsBold) + $0.addFormRow(label: "Text", view: eyebrowTextField) + $0.addFormRow(label: "Color", view: eyebrowColorPickerSelectorView) + })) + eyebrowTokenFormStackView.addFormRow(label: "Token", view: eyebrowTokenColorView) eyebrowColorFormStackView.addFormRow(label: "Custom", view: eyebrowCustomColorView) append(section: eyebrowTokenFormStackView) append(section: eyebrowColorFormStackView) - 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) + append(section: .init().with({ + $0.title = "\nTitle" + $0.addFormRow(label: "TextStyle", view: titleStandardStylePickerSelectorView) + $0.addFormRow(label: "is Bold", view: titleIsBold) + $0.addFormRow(label: "Text", view: titleTextField) + $0.addFormRow(label: "Color", view: titleColorPickerSelectorView) + })) titleTokenFormStackView.addFormRow(label: "Token", view: titleTokenColorView) titleColorFormStackView.addFormRow(label: "Custom", view: titleCustomColorView) append(section: titleTokenFormStackView) append(section: titleColorFormStackView) - addFormRow(label: "Subtitle Text", view: subTitleTextField) - addFormRow(label: "Subtitle Color", view: subtitleColorPickerSelectorView) + append(section: .init().with({ + $0.title = "\nSubtitle" + $0.addFormRow(label: "Subtitle Text", view: subTitleTextField) + $0.addFormRow(label: "Subtitle Color", view: subtitleColorPickerSelectorView) + })) subtitleTokenFormStackView.addFormRow(label: "Token", view: subtitleTokenColorView) subtitleColorFormStackView.addFormRow(label: "Custom", view: subtitleCustomColorView) append(section: subtitleTokenFormStackView) append(section: subtitleColorFormStackView) - eyebrowIsBold.publisher(for: .valueChanged).sink { [weak self] toggle in self?.setOtherModels() From 5303fae3f655d66dea35c2fbaef6e631704bf12d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 14 Jun 2024 16:17:28 -0500 Subject: [PATCH 3/9] updated version Signed-off-by: Matt Bruce --- VDSSample.xcodeproj/project.pbxproj | 6 ++---- VDSSample/ViewControllers/MenuViewController.swift | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/VDSSample.xcodeproj/project.pbxproj b/VDSSample.xcodeproj/project.pbxproj index 6438140..7486d35 100644 --- a/VDSSample.xcodeproj/project.pbxproj +++ b/VDSSample.xcodeproj/project.pbxproj @@ -46,8 +46,6 @@ 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 */; }; @@ -715,7 +713,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 66; + CURRENT_PROJECT_VERSION = 67; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = FCMA4QKS77; GENERATE_INFOPLIST_FILE = YES; @@ -751,7 +749,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 66; + CURRENT_PROJECT_VERSION = 67; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = FCMA4QKS77; GENERATE_INFOPLIST_FILE = YES; diff --git a/VDSSample/ViewControllers/MenuViewController.swift b/VDSSample/ViewControllers/MenuViewController.swift index aec4cba..4ce88ab 100644 --- a/VDSSample/ViewControllers/MenuViewController.swift +++ b/VDSSample/ViewControllers/MenuViewController.swift @@ -111,12 +111,13 @@ class MenuViewController: UITableViewController, TooltipLaunchable { } override func viewDidLoad() { - title = "VDS Sample: Build \(Bundle.main.build ?? "none")" + let build = Bundle.main.build ?? "none" + title = "VDS Sample: Build \(build)" let content = VDSHelper.releaseNotes() if !content.isEmpty { let tooltip = VDS.Tooltip() - tooltip.title = "Release Notes: \(VDSHelper.version)" + tooltip.title = "Release Notes: \(build)" tooltip.content = content navigationItem.rightBarButtonItem = UIBarButtonItem(customView: tooltip) } From 69ed21aa65425783a4579a753e80e4f776777bdc Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 19 Jun 2024 17:29:10 -0500 Subject: [PATCH 4/9] updated samples Signed-off-by: Matt Bruce --- VDSSample/Extensions/Bundle.swift | 2 +- .../ViewControllers/BaseViewController.swift | 2 +- .../CheckboxItemViewController.swift | 15 ++++++++++++--- .../RadioBoxGroupViewController.swift | 15 +++++++++++++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/VDSSample/Extensions/Bundle.swift b/VDSSample/Extensions/Bundle.swift index d73f7d7..f6ca51a 100644 --- a/VDSSample/Extensions/Bundle.swift +++ b/VDSSample/Extensions/Bundle.swift @@ -45,7 +45,7 @@ struct VDSHelper { return bundle.contents("ReleaseNotes") ?? "" } - static func changeLog(for component: ViewProtocol.Type) -> String? { + static func changeLog(for component: any ViewProtocol.Type) -> String? { return bundle.contents("\(component.self)ChangeLog") } } diff --git a/VDSSample/ViewControllers/BaseViewController.swift b/VDSSample/ViewControllers/BaseViewController.swift index 631eeac..6048bac 100644 --- a/VDSSample/ViewControllers/BaseViewController.swift +++ b/VDSSample/ViewControllers/BaseViewController.swift @@ -177,7 +177,7 @@ public class BaseViewController: UIViewController, Initable , open override func viewDidLoad() { super.viewDidLoad() - if let component = component as? ViewProtocol, let content = VDSHelper.changeLog(for: type(of: component)) { + if let component = component as? (any ViewProtocol), let content = VDSHelper.changeLog(for: type(of: component)) { let tooltip = VDS.Tooltip() tooltip.title = "ChangeLog" tooltip.content = content diff --git a/VDSSample/ViewControllers/CheckboxItemViewController.swift b/VDSSample/ViewControllers/CheckboxItemViewController.swift index 7bc3e8f..aba9883 100644 --- a/VDSSample/ViewControllers/CheckboxItemViewController.swift +++ b/VDSSample/ViewControllers/CheckboxItemViewController.swift @@ -71,10 +71,19 @@ class CheckboxItemViewController: BaseViewController { } func setupModel() { - component.labelText = "Terms and conditions" - component.childText = "I agree to Verizon's terms and conditions click here" + let fullText = "I accept the Terms and Conditions" + let linkText = "Terms and Conditions" 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 disabledSwitch.isOn = !component.isEnabled diff --git a/VDSSample/ViewControllers/RadioBoxGroupViewController.swift b/VDSSample/ViewControllers/RadioBoxGroupViewController.swift index f795d45..fc458bf 100644 --- a/VDSSample/ViewControllers/RadioBoxGroupViewController.swift +++ b/VDSSample/ViewControllers/RadioBoxGroupViewController.swift @@ -78,8 +78,19 @@ class RadioBoxGroupViewController: BaseViewController{ radioBox2.inputId = "model2" radioBox2.value = "model 2 Value" radioBox2.text = "iPhone 11 Bundle 2" - radioBox2.subText = "Apple iPhone 11 - 128 GB\nOtterbox Case Black\nScreen Protector" + 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] + } + component.selectorModels = [radioBox1, radioBox2] component.onChange = { [weak self] group in @@ -120,7 +131,7 @@ extension RadioBoxGroupViewController: ComponentSampleable { radioBox1.text = "iPhone 11 Bundle 1" radioBox1.subText = "Apple iPhone 11 - 64 GB\nOtterbox Case Red\nScreen Protector" radioBox1.subTextRight = "Right Text" - + var radioBox2 = RadioBoxGroup.RadioBoxItemModel() radioBox2.inputId = "model2" radioBox2.value = "model 2 Value" From 1ba09ee3667e8332e80b63581666fe9572e48618 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Jun 2024 15:00:03 -0500 Subject: [PATCH 5/9] added calendar Signed-off-by: Matt Bruce --- VDSSample/ViewControllers/CheckboxViewController.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/VDSSample/ViewControllers/CheckboxViewController.swift b/VDSSample/ViewControllers/CheckboxViewController.swift index bd223ad..1d28267 100644 --- a/VDSSample/ViewControllers/CheckboxViewController.swift +++ b/VDSSample/ViewControllers/CheckboxViewController.swift @@ -29,7 +29,9 @@ class CheckboxViewController: BaseViewController { addFormRow(label: "Disabled", view: disabledSwitch) addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Error", view: showErrorSwitch) - + addFormRow(label: "Calendar", view: VDS.DatePicker().with { + $0.calendarModel = .init(minDate: Date().startOfMonth, maxDate: Calendar.current.date(byAdding: .month, value: 2, to: Date())!) + }) showErrorSwitch.onChange = { [weak self] sender in guard let self else { return } self.component.showError = sender.isOn From f979ead3cf0a8a1df461215b1b3c113592610543 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 25 Jun 2024 11:38:04 -0500 Subject: [PATCH 6/9] added UITesting for positioning in a scrollview Signed-off-by: Matt Bruce --- .../DatePickerViewController.swift | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/VDSSample/ViewControllers/DatePickerViewController.swift b/VDSSample/ViewControllers/DatePickerViewController.swift index b3c8303..76a2170 100644 --- a/VDSSample/ViewControllers/DatePickerViewController.swift +++ b/VDSSample/ViewControllers/DatePickerViewController.swift @@ -93,6 +93,18 @@ class DatePickerViewController: BaseViewController { 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: "", view: View().with{$0.width(20);$0.height(400)}) + $0.addFormRow(label: "Above Test", view: datePicker()) + })) + disabledSwitch.onChange = { [weak self] sender in self?.component.isEnabled = !sender.isOn } @@ -154,7 +166,6 @@ class DatePickerViewController: BaseViewController { .sink { [weak self] text in self?.updateTooltip() }.store(in: &subscribers) - } func setupModel() { @@ -227,8 +238,7 @@ extension DatePickerViewController { section.addFormRow(label: "Indicator One Date", view: indicatorOnePicker) section.addFormRow(label: "Indicator Two Date", view: indicatorTwoPicker) section.addFormRow(label: "Indicator Three Date", view: indicatorThreePicker) - - + containerBorderSwitch.onChange = { [weak self] sender in self?.updateCalendarModel() } From 02503308ceacf6999fcc38e93e752924f3b88512 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 25 Jun 2024 14:03:13 -0500 Subject: [PATCH 7/9] updated version Signed-off-by: Matt Bruce --- VDSSample.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VDSSample.xcodeproj/project.pbxproj b/VDSSample.xcodeproj/project.pbxproj index 7486d35..ed7249e 100644 --- a/VDSSample.xcodeproj/project.pbxproj +++ b/VDSSample.xcodeproj/project.pbxproj @@ -713,7 +713,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 67; + CURRENT_PROJECT_VERSION = 68; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = FCMA4QKS77; GENERATE_INFOPLIST_FILE = YES; @@ -749,7 +749,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 67; + CURRENT_PROJECT_VERSION = 68; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = FCMA4QKS77; GENERATE_INFOPLIST_FILE = YES; From 5ffea5050a5b7e9d2a50714e54946bfbe872e3ae Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 25 Jun 2024 15:23:14 -0500 Subject: [PATCH 8/9] updated version/test Signed-off-by: Matt Bruce --- VDSSample.xcodeproj/project.pbxproj | 4 ++-- .../DatePickerViewController.swift | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/VDSSample.xcodeproj/project.pbxproj b/VDSSample.xcodeproj/project.pbxproj index ed7249e..b211632 100644 --- a/VDSSample.xcodeproj/project.pbxproj +++ b/VDSSample.xcodeproj/project.pbxproj @@ -713,7 +713,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 68; + CURRENT_PROJECT_VERSION = 69; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = FCMA4QKS77; GENERATE_INFOPLIST_FILE = YES; @@ -749,7 +749,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 68; + CURRENT_PROJECT_VERSION = 69; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = FCMA4QKS77; GENERATE_INFOPLIST_FILE = YES; diff --git a/VDSSample/ViewControllers/DatePickerViewController.swift b/VDSSample/ViewControllers/DatePickerViewController.swift index 76a2170..7c48959 100644 --- a/VDSSample/ViewControllers/DatePickerViewController.swift +++ b/VDSSample/ViewControllers/DatePickerViewController.swift @@ -101,7 +101,26 @@ class DatePickerViewController: BaseViewController { } $0.title = "UI Testing" $0.addFormRow(label: "Below Test", view: datePicker()) - $0.addFormRow(label: "", view: View().with{$0.width(20);$0.height(400)}) + $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()) })) From 2b978ffd03e2e1b118f6f019ccd0cbb14d8cdae0 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 28 Jun 2024 18:09:57 -0500 Subject: [PATCH 9/9] updated samples Signed-off-by: Matt Bruce --- .../TileContainerViewController.swift | 143 +++++++++++------- .../TileletViewController.swift | 32 ++-- 2 files changed, 113 insertions(+), 62 deletions(-) diff --git a/VDSSample/ViewControllers/TileContainerViewController.swift b/VDSSample/ViewControllers/TileContainerViewController.swift index 0c3a530..b32e7d5 100644 --- a/VDSSample/ViewControllers/TileContainerViewController.swift +++ b/VDSSample/ViewControllers/TileContainerViewController.swift @@ -115,54 +115,77 @@ class TileContainerViewController: BaseViewController { override func viewDidLoad() { super.viewDidLoad() - addContentTopView(view: .makeWrapper(for: component)) - component.width = 300 + + 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.setTitle("Register", for: .normal) + + ///bottom + let bottomView = View() + bottomView.backgroundColor = .green + + let bottomLabel = Label() + bottomLabel.text = "Forgot your info?" + + let bottomButton = Button() + bottomButton.setTitle("Forgot Password", for: .normal) + + 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) + component.color = .secondary component.accessibilityLabel = "Tile Container" - - 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) + addContentTopView(view: .makeWrapper(for: component)) + component.addContentView(mainView) setupPicker() setupModel() } @@ -248,20 +271,34 @@ class TileContainerViewController: BaseViewController { heightTextField .numberPublisher .sink { [weak self] number in - 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() + 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 = "" } }.store(in: &subscribers) widthTextField .numberPublisher .sink { [weak self] number in - 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() + 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 = "" } }.store(in: &subscribers) } diff --git a/VDSSample/ViewControllers/TileletViewController.swift b/VDSSample/ViewControllers/TileletViewController.swift index e2fd6db..cbd35e7 100644 --- a/VDSSample/ViewControllers/TileletViewController.swift +++ b/VDSSample/ViewControllers/TileletViewController.swift @@ -440,20 +440,34 @@ class TileletViewController: BaseViewController { heightTextField .numberPublisher .sink { [weak self] number in - 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() + 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 = "" } }.store(in: &subscribers) - + widthTextField .numberPublisher .sink { [weak self] number in - 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() + 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 = "" } }.store(in: &subscribers)