added password field

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-04-30 13:51:05 -05:00
parent 05d2e448d3
commit 75297a2f77

View File

@ -19,6 +19,12 @@ class InputFieldViewController: BaseViewController<InputField> {
items: InputField.HelperTextPlacement.allCases) items: InputField.HelperTextPlacement.allCases)
}() }()
lazy var inputTypePickerSelectorView = {
PickerSelectorView(title: "",
picker: self.picker,
items: InputField.FieldType.allCases)
}()
var disabledSwitch = Toggle() var disabledSwitch = Toggle()
var requiredSwitch = Toggle() var requiredSwitch = Toggle()
var labelTextField = TextField() var labelTextField = TextField()
@ -31,6 +37,18 @@ class InputFieldViewController: BaseViewController<InputField> {
var tooltipTitleTextField = TextField() var tooltipTitleTextField = TextField()
var tooltipContentTextField = TextField() var tooltipContentTextField = TextField()
//FieldType sections
//password
var hidePasswordButtonTextField = TextField()
var showPasswordButtonTextField = TextField()
lazy var passwordSection = FormSection().with {
$0.title = "Password Settings"
$0.addFormRow(label: "Hide Button", view: hidePasswordButtonTextField)
$0.addFormRow(label: "Show Button", view: showPasswordButtonTextField)
$0.isHidden = true
}
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
addContentTopView(view: component) addContentTopView(view: component)
@ -53,6 +71,9 @@ class InputFieldViewController: BaseViewController<InputField> {
addFormRow(label: "Width", view: widthTextField) addFormRow(label: "Width", view: widthTextField)
addFormRow(label: "ToolTip Title", view: tooltipTitleTextField) addFormRow(label: "ToolTip Title", view: tooltipTitleTextField)
addFormRow(label: "ToolTip Content", view: tooltipContentTextField) addFormRow(label: "ToolTip Content", view: tooltipContentTextField)
addFormRow(label: "Field Type", view: inputTypePickerSelectorView)
append(section: passwordSection)
requiredSwitch.onChange = { [weak self] sender in requiredSwitch.onChange = { [weak self] sender in
self?.component.required = sender.isOn self?.component.required = sender.isOn
@ -114,6 +135,19 @@ class InputFieldViewController: BaseViewController<InputField> {
self?.updateTooltip() self?.updateTooltip()
}.store(in: &subscribers) }.store(in: &subscribers)
//field types
//password
hidePasswordButtonTextField
.textPublisher
.sink { [weak self] text in
self?.component.hidePasswordButtonText = text
}.store(in: &subscribers)
showPasswordButtonTextField
.textPublisher
.sink { [weak self] text in
self?.component.showPasswordButtonText = text
}.store(in: &subscribers)
} }
func setupModel() { func setupModel() {
@ -137,6 +171,7 @@ class InputFieldViewController: BaseViewController<InputField> {
//setup UI //setup UI
surfacePickerSelectorView.text = component.surface.rawValue surfacePickerSelectorView.text = component.surface.rawValue
helperTextPlacementPickerSelectorView.text = component.helperTextPlacement.rawValue helperTextPlacementPickerSelectorView.text = component.helperTextPlacement.rawValue
inputTypePickerSelectorView.text = component.fieldType.rawValue
disabledSwitch.isOn = !component.isEnabled disabledSwitch.isOn = !component.isEnabled
requiredSwitch.isOn = component.required requiredSwitch.isOn = component.required
labelTextField.text = component.labelText labelTextField.text = component.labelText
@ -162,6 +197,11 @@ class InputFieldViewController: BaseViewController<InputField> {
helperTextPlacementPickerSelectorView.onPickerDidSelect = { [weak self] item in helperTextPlacementPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.helperTextPlacement = item self?.component.helperTextPlacement = item
} }
inputTypePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.fieldType = item
self?.updateFormSections()
}
} }
func updateTooltip() { func updateTooltip() {
@ -171,6 +211,39 @@ class InputFieldViewController: BaseViewController<InputField> {
component.tooltipModel = !title.isEmpty || !content.isEmpty ? .init(title: title, component.tooltipModel = !title.isEmpty || !content.isEmpty ? .init(title: title,
content: content) : nil content: content) : nil
} }
func updateFormSections() {
passwordSection.isHidden = true
switch component.fieldType {
case .text:
break
case .number:
break
case .inlineAction:
break
case .password:
passwordSection.isHidden = false
case .creditCard:
break
case .tel:
break
case .date:
break
case .securityCode:
break
@unknown default:
break
}
}
} }