From 5c3e6b0ea5d81554752ebecef554f782dfbfc6c9 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Sat, 22 Jul 2023 12:12:33 -0500 Subject: [PATCH] refactored label and textfields Signed-off-by: Matt Bruce --- VDSSample/Classes/TextField.swift | 16 +--- .../ViewControllers/LabelViewController.swift | 90 ++++++++++++++----- 2 files changed, 69 insertions(+), 37 deletions(-) diff --git a/VDSSample/Classes/TextField.swift b/VDSSample/Classes/TextField.swift index 8612627..0df3c00 100644 --- a/VDSSample/Classes/TextField.swift +++ b/VDSSample/Classes/TextField.swift @@ -38,7 +38,7 @@ public class TextField: UITextField { public func setup() { keyboardType = .alphabet returnKeyType = .done - + autocorrectionType = .no resigner = publisher(for: .editingDidEndOnExit) .sink { [weak self] _ in self?.shouldResign() @@ -79,19 +79,7 @@ public class NumericField: TextField { public override func setup() { super.setup() - let keypadToolbar: UIToolbar = UIToolbar().with { $0.tintColor = .white; $0.backgroundColor = .white } - - // add a done button to the numberpad - keypadToolbar.items=[ - UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: self, action: nil), - UIBarButtonItem(title: " - (minus sign)", style: .done, target: self, action: #selector(insertMinus)).with { $0.tintColor = .black}, - UIBarButtonItem(title: "Done", style: UIBarButtonItem.Style.done, target: self, action: #selector(shouldResign)).with { $0.tintColor = .black} - ] - keypadToolbar.sizeToFit() - - // add a toolbar with a done button above the number pad - inputAccessoryView = keypadToolbar - keyboardType = .decimalPad + keyboardType = .numbersAndPunctuation } @objc public func insertMinus() { diff --git a/VDSSample/ViewControllers/LabelViewController.swift b/VDSSample/ViewControllers/LabelViewController.swift index 9febc8a..af8ec06 100644 --- a/VDSSample/ViewControllers/LabelViewController.swift +++ b/VDSSample/ViewControllers/LabelViewController.swift @@ -31,6 +31,8 @@ class LabelViewController: BaseViewController