diff --git a/VDSSample.xcodeproj/project.pbxproj b/VDSSample.xcodeproj/project.pbxproj index 128bc3d..e5cf453 100644 --- a/VDSSample.xcodeproj/project.pbxproj +++ b/VDSSample.xcodeproj/project.pbxproj @@ -43,6 +43,7 @@ EA0D1C312A673F3500E5C127 /* RadioButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */; }; 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 */; }; 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 */; }; @@ -142,6 +143,7 @@ EA0D1C302A673F3500E5C127 /* RadioButtonViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonViewController.swift; sourceTree = ""; }; EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonItemViewController.swift; sourceTree = ""; }; EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextLinkCaretViewController.swift; sourceTree = ""; }; + EA1758452BC8893700A5C0D9 /* DatePickerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerViewController.swift; sourceTree = ""; }; EA297A672A02F5320031ED56 /* TableViewTestController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewTestController.swift; sourceTree = ""; }; EA3C3B99289966EF000CA526 /* VDSSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VDSSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; EA3C3B9C289966EF000CA526 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -330,6 +332,7 @@ EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */, EAF7F09B2899B92400B287F5 /* CheckboxItemViewController.swift */, EA0D1C2E2A66CFE900E5C127 /* CheckboxViewController.swift */, + EA1758452BC8893700A5C0D9 /* DatePickerViewController.swift */, 186D13CC2BBA990800986B53 /* DropdownSelectViewController.swift */, EA985C00296CC21C00F2FF2E /* IconViewController.swift */, EAA5EEAC28EB6924003B3210 /* InputFieldViewController.swift */, @@ -524,6 +527,7 @@ EA3C3BB428996775000CA526 /* PickerBase.swift in Sources */, EAB2376C29E9E74900AABE9A /* TrailingTooltipLabelViewController.swift in Sources */, EAB1D2C928AAAA1D00DAE764 /* BaseViewController.swift in Sources */, + EA1758462BC8893700A5C0D9 /* DatePickerViewController.swift in Sources */, EAD062AD2A3B86950015965D /* BadgeIndicatorViewController.swift in Sources */, EA5E305C295111050082B959 /* TileletViewController.swift in Sources */, EAD062A32A3913920015965D /* DropShawdowViewController.swift in Sources */, diff --git a/VDSSample/Extensions/IconName.swift b/VDSSample/Extensions/IconName.swift index 8dc6b69..7e96269 100644 --- a/VDSSample/Extensions/IconName.swift +++ b/VDSSample/Extensions/IconName.swift @@ -62,7 +62,6 @@ extension Icon.Name { public static let bucketTruck = Icon.Name(name: "bucket-truck") public static let bug = Icon.Name(name: "bug") public static let businessContinuity = Icon.Name(name: "business-continuity") - public static let calendar = Icon.Name(name: "calendar") public static let calibrate = Icon.Name(name: "calibrate") public static let callDisconnected = Icon.Name(name: "call-disconnected") public static let callerId = Icon.Name(name: "caller-id") diff --git a/VDSSample/ViewControllers/DatePickerViewController.swift b/VDSSample/ViewControllers/DatePickerViewController.swift new file mode 100644 index 0000000..70b2bdf --- /dev/null +++ b/VDSSample/ViewControllers/DatePickerViewController.swift @@ -0,0 +1,141 @@ +// +// DatePickerViewController.swift +// VDSSample +// +// Created by Matt Bruce on 4/11/24. +// + +import Foundation +import VDS + +class DatePickerViewController: BaseViewController { + + var disabledSwitch = Toggle() + var requiredSwitch = Toggle() + var labelTextField = TextField() + var errorTextField = TextField() + var helperTextField = TextField() + var inlineLabelSwitch = Toggle() + var readonlySwitch = Toggle() + var transparentBgSwitch = Toggle() + var errorSwitch = Toggle() + var tooltipTitleTextField = TextField() + var tooltipContentTextField = TextField() + + override func viewDidLoad() { + super.viewDidLoad() + addContentTopView(view: component) + setupModel() + setupPicker() + } + + override func setupForm(){ + addFormRow(label: "Surface", view: surfacePickerSelectorView) + addFormRow(label: "Disabled", view: disabledSwitch) + addFormRow(label: "Required", view: requiredSwitch) + addFormRow(label: "Label Text", view: labelTextField) + addFormRow(label: "Helper Text", view: helperTextField) + addFormRow(label: "Readonly", view: readonlySwitch) + addFormRow(label: "Transparent Background", view: transparentBgSwitch) + addFormRow(label: "Error", view: .makeWrapper(for: errorSwitch)) + addFormRow(label: "Error Text", view: errorTextField) + addFormRow(label: "ToolTip Title", view: tooltipTitleTextField) + addFormRow(label: "ToolTip Content", view: tooltipContentTextField) + + disabledSwitch.onChange = { [weak self] sender in + self?.component.isEnabled = !sender.isOn + } + + requiredSwitch.onChange = { [weak self] sender in + self?.component.required = sender.isOn + } + + readonlySwitch.onChange = { [weak self] sender in + self?.component.readOnly = sender.isOn + } + + transparentBgSwitch.onChange = { [weak self] sender in + self?.component.transparentBackground = sender.isOn + } + + errorSwitch + .publisher(for: .valueChanged) + .sink { [weak self] sender in + guard let self else { return } + component.showError = sender.isOn + if component.showError != sender.isOn { + self.errorSwitch.isOn = self.component.showError + } + }.store(in: &subscribers) + + 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) + + 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.labelText = "Date" + component.helperText = "Pick a date for your needs." + component.errorText = "Enter a date." + component.tooltipModel = .init(title: "Check your date.", content:"Here is the content for your date component") + + component.onChange = { c in + print("selected value: \(c.value ?? "no date selected")") + } + + //setup UI + disabledSwitch.isOn = !component.isEnabled + requiredSwitch.isOn = component.required + surfacePickerSelectorView.text = component.surface.rawValue + labelTextField.text = component.labelText + helperTextField.text = component.helperText + readonlySwitch.isOn = false + transparentBgSwitch.isOn = false + errorSwitch.isOn = component.showError + errorTextField.text = component.errorText + 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 + } + } + + func updateTooltip() { + let title = tooltipTitleTextField.text ?? "" + let content = tooltipContentTextField.text ?? "" + + component.tooltipModel = !title.isEmpty || !content.isEmpty ? .init(title: title, + content: content) : nil + } +} diff --git a/VDSSample/ViewControllers/MenuViewController.swift b/VDSSample/ViewControllers/MenuViewController.swift index 86484c6..2916b7d 100644 --- a/VDSSample/ViewControllers/MenuViewController.swift +++ b/VDSSample/ViewControllers/MenuViewController.swift @@ -78,6 +78,7 @@ class MenuViewController: UITableViewController, TooltipLaunchable { 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: false, viewController: DatePickerViewController.self), MenuComponent(title: "DropdownSelect", completed: true, viewController: DropdownSelectViewController.self), MenuComponent(title: "Icon", completed: true, viewController: IconViewController.self), MenuComponent(title: "InputField", completed: false, viewController: InputFieldViewController.self),