Merge branch 'feature/entryFields' into 'develop'
refactored picker base See merge request BPHV_MIPS/vds_ios_sample!3
This commit is contained in:
commit
0e8201543f
@ -53,6 +53,7 @@
|
||||
EA89204C28B66CE2006B9984 /* ScrollWrapperView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89204528B66CE2006B9984 /* ScrollWrapperView.swift */; };
|
||||
EA89204E28B67332006B9984 /* CheckBoxGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */; };
|
||||
EA89205128B68307006B9984 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89205028B68307006B9984 /* TextField.swift */; };
|
||||
EAA5EEAD28EB6924003B3210 /* TextEntryFieldViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEAC28EB6924003B3210 /* TextEntryFieldViewController.swift */; };
|
||||
EAB1D2C928AAAA1D00DAE764 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2C828AAAA1D00DAE764 /* BaseViewController.swift */; };
|
||||
EAB1D2D428AC409F00DAE764 /* LabelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2D328AC409F00DAE764 /* LabelViewController.swift */; };
|
||||
EAF7F07D2899698800B287F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAF7F07B2899698800B287F5 /* Assets.xcassets */; };
|
||||
@ -116,6 +117,7 @@
|
||||
EA89204528B66CE2006B9984 /* ScrollWrapperView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollWrapperView.swift; sourceTree = "<group>"; };
|
||||
EA89204D28B67332006B9984 /* CheckBoxGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckBoxGroupViewController.swift; sourceTree = "<group>"; };
|
||||
EA89205028B68307006B9984 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = "<group>"; };
|
||||
EAA5EEAC28EB6924003B3210 /* TextEntryFieldViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryFieldViewController.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>"; };
|
||||
EAF7F07B2899698800B287F5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
@ -256,6 +258,7 @@
|
||||
EA89201828B56DF5006B9984 /* RadioBoxGroupViewController.swift */,
|
||||
EAF7F11928A14A0E00B287F5 /* RadioButtonViewController.swift */,
|
||||
EA84F76128BE4AE500D67ABC /* RadioSwatchGroupViewController.swift */,
|
||||
EAA5EEAC28EB6924003B3210 /* TextEntryFieldViewController.swift */,
|
||||
EA3C3BB328996775000CA526 /* ToggleViewController.swift */,
|
||||
);
|
||||
path = ViewControllers;
|
||||
@ -419,6 +422,7 @@
|
||||
EA89204828B66CE2006B9984 /* ScrollViewKeyboardAvoiding.swift in Sources */,
|
||||
EAF7F09C2899B92400B287F5 /* CheckboxViewController.swift in Sources */,
|
||||
EA89204E28B67332006B9984 /* CheckBoxGroupViewController.swift in Sources */,
|
||||
EAA5EEAD28EB6924003B3210 /* TextEntryFieldViewController.swift in Sources */,
|
||||
EA89204928B66CE2006B9984 /* KeyboardFrameChangeListening.swift in Sources */,
|
||||
EAB1D2D428AC409F00DAE764 /* LabelViewController.swift in Sources */,
|
||||
EA89204B28B66CE2006B9984 /* ScrollViewKeyboardAvoider.swift in Sources */,
|
||||
|
||||
@ -27,7 +27,7 @@ class MenuViewController: UITableViewController {
|
||||
MenuComponent(title: "RadioButtonGroup", viewController: RadioButtonViewController.self),
|
||||
MenuComponent(title: "RadioBoxGroup", viewController: RadioBoxGroupViewController.self),
|
||||
MenuComponent(title: "RadioSwatchGroup", viewController: RadioSwatchGroupViewController.self),
|
||||
//MenuComponent(title: "TextEntryField", viewController: TextEntryFieldViewController.self),
|
||||
MenuComponent(title: "TextEntryField", viewController: TextEntryFieldViewController.self),
|
||||
MenuComponent(title: "Toggle", viewController: ToggleViewController.self)
|
||||
]
|
||||
|
||||
|
||||
171
VDSSample/ViewControllers/TextEntryFieldViewController.swift
Normal file
171
VDSSample/ViewControllers/TextEntryFieldViewController.swift
Normal file
@ -0,0 +1,171 @@
|
||||
//
|
||||
// TextEntryFieldViewController.swift
|
||||
// VDSSample
|
||||
//
|
||||
// Created by Matt Bruce on 10/3/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDS
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
class TextEntryFieldViewController: BaseViewController {
|
||||
|
||||
lazy var helperTextPlacementPickerSelectorView = {
|
||||
PickerSelectorView(title: "",
|
||||
picker: self.picker,
|
||||
items: HelperTextPlacement.allCases)
|
||||
}()
|
||||
|
||||
var disabledSwitch = UISwitch()
|
||||
var requiredSwitch = UISwitch()
|
||||
var labelTextField = TextField()
|
||||
var errorTextField = TextField()
|
||||
var successTextField = TextField()
|
||||
var helperTextField = TextField()
|
||||
var widthTextField = TextField()
|
||||
var showErrorSwitch = UISwitch()
|
||||
var showSuccessSwitch = UISwitch()
|
||||
var tooltipTitleTextField = TextField()
|
||||
var tooltipContentTextField = TextField()
|
||||
|
||||
var textEntryField = TextEntryField()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: textEntryField)
|
||||
setupForm()
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
|
||||
func setupForm(){
|
||||
addFormRow(label: "Disabled", view: disabledSwitch)
|
||||
addFormRow(label: "Required", view: requiredSwitch)
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "Label Text", view: labelTextField)
|
||||
addFormRow(label: "Helper Text Placement", view: helperTextPlacementPickerSelectorView)
|
||||
addFormRow(label: "Helper Text", view: helperTextField)
|
||||
addFormRow(label: "Error", view: showErrorSwitch)
|
||||
addFormRow(label: "Error Text", view: errorTextField)
|
||||
addFormRow(label: "Success", view: showSuccessSwitch)
|
||||
addFormRow(label: "Success Text", view: successTextField)
|
||||
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?.textEntryField.required = sender.isOn
|
||||
}.store(in: &subscribers)
|
||||
|
||||
showErrorSwitch
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { [weak self] sender in
|
||||
self?.textEntryField.showError = sender.isOn
|
||||
}.store(in: &subscribers)
|
||||
|
||||
showSuccessSwitch
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { [weak self] sender in
|
||||
self?.textEntryField.showSuccess = sender.isOn
|
||||
}.store(in: &subscribers)
|
||||
|
||||
disabledSwitch
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { [weak self] sender in
|
||||
self?.textEntryField.disabled = sender.isOn
|
||||
}.store(in: &subscribers)
|
||||
|
||||
labelTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.textEntryField.labelText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
helperTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.textEntryField.helperText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
errorTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.textEntryField.errorText = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
widthTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] width in
|
||||
guard let width = Float(width) else { return }
|
||||
self?.textEntryField.width = CGFloat(width)
|
||||
}.store(in: &subscribers)
|
||||
|
||||
tooltipTitleTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.textEntryField.tooltipTitle = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
tooltipContentTextField
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.textEntryField.tooltipContent = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
textEntryField.type = .text
|
||||
textEntryField.width = 328
|
||||
textEntryField.labelText = "Street Address"
|
||||
textEntryField.helperText = "For example: 123 Verizon St"
|
||||
textEntryField.errorText = "Enter a valid address."
|
||||
textEntryField.successText = "Good job entering a valid address!"
|
||||
textEntryField.tooltipTitle = "Check the formatting of your address"
|
||||
textEntryField.tooltipContent = "House/Building number then street name"
|
||||
|
||||
textEntryField
|
||||
.publisher(for: .valueChanged)
|
||||
.sink { textEntryField in
|
||||
if let text = textEntryField.value {
|
||||
print("text entry: \(text)")
|
||||
} else {
|
||||
print("text entry: null")
|
||||
}
|
||||
}.store(in: &subscribers)
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = textEntryField.surface.rawValue
|
||||
disabledSwitch.isOn = textEntryField.disabled
|
||||
requiredSwitch.isOn = textEntryField.required
|
||||
labelTextField.text = textEntryField.labelText
|
||||
helperTextField.text = textEntryField.helperText
|
||||
showErrorSwitch.isOn = textEntryField.showError
|
||||
errorTextField.text = textEntryField.errorText
|
||||
showSuccessSwitch.isOn = textEntryField.showSuccess
|
||||
successTextField.text = textEntryField.successText
|
||||
tooltipTitleTextField.text = textEntryField.tooltipTitle
|
||||
tooltipContentTextField.text = textEntryField.tooltipContent
|
||||
if let width = textEntryField.width {
|
||||
widthTextField.text = String(describing: width)
|
||||
}
|
||||
}
|
||||
|
||||
//Picker
|
||||
func setupPicker(){
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.textEntryField.surface = item
|
||||
self?.contentTopView.backgroundColor = item.color
|
||||
}
|
||||
|
||||
helperTextPlacementPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.textEntryField.helperTextPlacement = item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user