initial commit for datePicker

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-04-11 16:50:54 -05:00
parent 842485fb49
commit e666a792e0
4 changed files with 146 additions and 1 deletions

View File

@ -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 = "<group>"; };
EA0D1C322A673FD400E5C127 /* RadioButtonItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonItemViewController.swift; sourceTree = "<group>"; };
EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextLinkCaretViewController.swift; sourceTree = "<group>"; };
EA1758452BC8893700A5C0D9 /* DatePickerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerViewController.swift; sourceTree = "<group>"; };
EA297A672A02F5320031ED56 /* TableViewTestController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewTestController.swift; sourceTree = "<group>"; };
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 = "<group>"; };
@ -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 */,

View File

@ -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")

View File

@ -0,0 +1,141 @@
//
// DatePickerViewController.swift
// VDSSample
//
// Created by Matt Bruce on 4/11/24.
//
import Foundation
import VDS
class DatePickerViewController: BaseViewController<DatePicker> {
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
}
}

View File

@ -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),