added textArea
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
56b3954f84
commit
c1af6729f2
@ -63,6 +63,7 @@
|
||||
EA985C19296CC73D00F2FF2E /* VDSIcons.bundle in Embed PlugIns */ = {isa = PBXBuildFile; fileRef = EA985C14296CC5EE00F2FF2E /* VDSIcons.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
EA985C1B296CC74A00F2FF2E /* VDSIcons.bundle in Resources */ = {isa = PBXBuildFile; fileRef = EA985C14296CC5EE00F2FF2E /* VDSIcons.bundle */; };
|
||||
EA985C20296DECF600F2FF2E /* IconName.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C1F296DECF600F2FF2E /* IconName.swift */; };
|
||||
EA985C25296E06EA00F2FF2E /* TextAreaViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C24296E06EA00F2FF2E /* TextAreaViewController.swift */; };
|
||||
EAA5EEAD28EB6924003B3210 /* InputFieldViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEAC28EB6924003B3210 /* InputFieldViewController.swift */; };
|
||||
EAB1D2C928AAAA1D00DAE764 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2C828AAAA1D00DAE764 /* BaseViewController.swift */; };
|
||||
EAB1D2D428AC409F00DAE764 /* LabelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */; };
|
||||
@ -143,6 +144,7 @@
|
||||
EA985C00296CC21C00F2FF2E /* IconViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IconViewController.swift; sourceTree = "<group>"; };
|
||||
EA985C14296CC5EE00F2FF2E /* VDSIcons.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = VDSIcons.bundle; path = SharedFrameworks/VDSIcons.bundle; sourceTree = "<group>"; };
|
||||
EA985C1F296DECF600F2FF2E /* IconName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconName.swift; sourceTree = "<group>"; };
|
||||
EA985C24296E06EA00F2FF2E /* TextAreaViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextAreaViewController.swift; sourceTree = "<group>"; };
|
||||
EAA5EEAC28EB6924003B3210 /* InputFieldViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputFieldViewController.swift; sourceTree = "<group>"; };
|
||||
EAB1D2C828AAAA1D00DAE764 /* BaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = "<group>"; };
|
||||
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelViewController.swift; sourceTree = "<group>"; };
|
||||
@ -281,12 +283,13 @@
|
||||
EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */,
|
||||
EAF7F09B2899B92400B287F5 /* CheckboxViewController.swift */,
|
||||
EA985C00296CC21C00F2FF2E /* IconViewController.swift */,
|
||||
EAA5EEAC28EB6924003B3210 /* InputFieldViewController.swift */,
|
||||
EAC9257F29119FC400091998 /* TextLinkViewController.swift */,
|
||||
EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */,
|
||||
EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */,
|
||||
EAF7F11928A14A0E00B287F5 /* RadioButtonViewController.swift */,
|
||||
EA84F76128BE4AE500D67ABC /* RadioSwatchGroupViewController.swift */,
|
||||
EAA5EEAC28EB6924003B3210 /* InputFieldViewController.swift */,
|
||||
EA985C24296E06EA00F2FF2E /* TextAreaViewController.swift */,
|
||||
EA0FC2C02912DC5500DF80B4 /* TextLinkCaretViewController.swift */,
|
||||
EA5E304F294D11540082B959 /* TileContainerViewController.swift */,
|
||||
EA5E305B295111050082B959 /* TiletViewController.swift */,
|
||||
@ -463,6 +466,7 @@
|
||||
EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */,
|
||||
EA89204E28B67332006B9984 /* CheckBoxGroupViewController.swift in Sources */,
|
||||
EAA5EEAD28EB6924003B3210 /* InputFieldViewController.swift in Sources */,
|
||||
EA985C25296E06EA00F2FF2E /* TextAreaViewController.swift in Sources */,
|
||||
EA985C20296DECF600F2FF2E /* IconName.swift in Sources */,
|
||||
EA89204928B66CE2006B9984 /* KeyboardFrameChangeListening.swift in Sources */,
|
||||
EA985C01296CC21C00F2FF2E /* IconViewController.swift in Sources */,
|
||||
|
||||
@ -82,6 +82,7 @@ class MenuViewController: UITableViewController {
|
||||
MenuComponent(title: "RadioBoxGroup", completed: true, viewController: RadioBoxGroupViewController.self),
|
||||
MenuComponent(title: "RadioButtonGroup", completed: true, viewController: RadioButtonViewController.self),
|
||||
MenuComponent(title: "RadioSwatchGroup", completed: true, viewController: RadioSwatchGroupViewController.self),
|
||||
MenuComponent(title: "TextArea", completed: false, viewController: TextAreaViewController.self),
|
||||
MenuComponent(title: "TextLink", completed: true, viewController: TextLinkViewController.self),
|
||||
MenuComponent(title: "TextLinkCaret", completed: true, viewController: TextLinkCaretViewController.self),
|
||||
MenuComponent(title: "TileContainer", completed: false, viewController: TileContainerViewController.self),
|
||||
|
||||
150
VDSSample/ViewControllers/TextAreaViewController.swift
Normal file
150
VDSSample/ViewControllers/TextAreaViewController.swift
Normal file
@ -0,0 +1,150 @@
|
||||
//
|
||||
// TextAreaViewController.swift
|
||||
// VDSSample
|
||||
//
|
||||
// Created by Matt Bruce on 1/10/23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class TextAreaViewController: BaseViewController {
|
||||
|
||||
var disabledSwitch = Toggle()
|
||||
var requiredSwitch = Toggle()
|
||||
var labelTextField = TextField()
|
||||
var errorTextField = TextField()
|
||||
var helperTextField = TextField()
|
||||
var widthTextField = NumericField()
|
||||
var showErrorSwitch = Toggle()
|
||||
var tooltipTitleTextField = TextField()
|
||||
var tooltipContentTextField = TextField()
|
||||
|
||||
var textArea = TextArea()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: textArea)
|
||||
setupForm()
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
|
||||
override func allTextFields() -> [TextField]? { [labelTextField, errorTextField, helperTextField, widthTextField, tooltipTitleTextField, tooltipContentTextField] }
|
||||
|
||||
func setupForm(){
|
||||
addFormRow(label: "Disabled", view: .makeWrapper(for: disabledSwitch))
|
||||
addFormRow(label: "Required", view: .makeWrapper(for: requiredSwitch))
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "Label Text", view: labelTextField)
|
||||
addFormRow(label: "Helper Text", view: helperTextField)
|
||||
addFormRow(label: "Error", view: .makeWrapper(for: showErrorSwitch))
|
||||
addFormRow(label: "Error Text", view: errorTextField)
|
||||
addFormRow(label: "Width", view: widthTextField)
|
||||
addFormRow(label: "ToolTip Title", view: tooltipTitleTextField)
|
||||
addFormRow(label: "ToolTip Content", view: tooltipContentTextField)
|
||||
|
||||
requiredSwitch
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { [weak self] sender in
|
||||
self?.textArea.required = sender.isOn
|
||||
}.store(in: &subscribers)
|
||||
|
||||
showErrorSwitch
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { [weak self] sender in
|
||||
guard let self else { return }
|
||||
self.textArea.showError = sender.isOn
|
||||
if self.textArea.showError != sender.isOn {
|
||||
self.showErrorSwitch.isOn = self.textArea.showError
|
||||
}
|
||||
}.store(in: &subscribers)
|
||||
|
||||
disabledSwitch
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { [weak self] sender in
|
||||
self?.textArea.disabled = sender.isOn
|
||||
}.store(in: &subscribers)
|
||||
|
||||
labelTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.textArea.labelText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
helperTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.textArea.helperText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
errorTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.textArea.errorText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
widthTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] width in
|
||||
guard let width = Float(width) else { return }
|
||||
self?.textArea.width = CGFloat(width)
|
||||
}.store(in: &subscribers)
|
||||
|
||||
tooltipTitleTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.textArea.tooltipTitle = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
tooltipContentTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.textArea.tooltipContent = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
textArea.width = 328
|
||||
textArea.labelText = "Street Address"
|
||||
textArea.helperText = "For example: 123 Verizon St"
|
||||
textArea.errorText = "Enter a valid address."
|
||||
textArea.tooltipTitle = "Check the formatting of your address"
|
||||
textArea.tooltipContent = "House/Building number then street name"
|
||||
|
||||
textArea
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { textArea in
|
||||
if let text = textArea.value {
|
||||
print("text entry: \(text)")
|
||||
} else {
|
||||
print("text entry: null")
|
||||
}
|
||||
}.store(in: &subscribers)
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = textArea.surface.rawValue
|
||||
disabledSwitch.isOn = textArea.disabled
|
||||
requiredSwitch.isOn = textArea.required
|
||||
labelTextField.text = textArea.labelText
|
||||
helperTextField.text = textArea.helperText
|
||||
showErrorSwitch.isOn = textArea.showError
|
||||
errorTextField.text = textArea.errorText
|
||||
tooltipTitleTextField.text = textArea.tooltipTitle
|
||||
tooltipContentTextField.text = textArea.tooltipContent
|
||||
}
|
||||
|
||||
//Picker
|
||||
func setupPicker(){
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.textArea.surface = item
|
||||
self?.contentTopView.backgroundColor = item.color
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user