From c6ffa5736d00d97276a9dc3216916b47e0a0e809 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 10 Jan 2023 16:49:39 -0600 Subject: [PATCH] updated entry field Signed-off-by: Matt Bruce --- .../TextFields/EntryField/EntryField.swift | 2 +- .../TextFields/InputField/InputField.swift | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index 3cc7fc4a..b5f6193e 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -93,7 +93,7 @@ open class EntryField: Control, Accessable { // MARK: - Configuration Properties //-------------------------------------------------- // Sizes are from InVision design specs. - internal let containerSize = CGSize(width: 45, height: 44) + internal var containerSize: CGSize { CGSize(width: 45, height: 44) } internal let primaryColorConfig = ViewColorConfiguration().with { $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true) diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index d3cb99e0..e4e84be1 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -16,7 +16,7 @@ public enum InputFieldType: String, CaseIterable { } @objc(VDSInputField) -public class InputField: EntryField { +public class InputField: EntryField, UITextFieldDelegate { //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- @@ -102,7 +102,6 @@ public class InputField: EntryField { $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false) }.eraseToAnyColorable() - internal var minWidthConstraint: NSLayoutConstraint? //-------------------------------------------------- @@ -117,6 +116,13 @@ public class InputField: EntryField { controlContainerView.addSubview(textField) textField.pinToSuperView() textField.heightAnchor.constraint(equalToConstant: 20).isActive = true + textField + .textPublisher + .sink { [weak self] text in + self?.value = text + self?.sendActions(for: .valueChanged) + + }.store(in: &subscribers) stackView.addArrangedSubview(successLabel) stackView.setCustomSpacing(8, after: successLabel) @@ -130,6 +136,9 @@ public class InputField: EntryField { public override func reset() { super.reset() + textField.text = "" + textField.delegate = self + successLabel.reset() successLabel.textPosition = .left successLabel.typograpicalStyle = .BodySmall @@ -204,6 +213,7 @@ public class InputField: EntryField { } } } + } extension InputFieldType {