From 1d08842d47e7916c0e916470eb5ca7e30248c779 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 18 Nov 2019 15:40:11 -0500 Subject: [PATCH] wip. --- .../TextFields/DateDropdownEntryField.swift | 2 ++ MVMCoreUI/Atoms/TextFields/DigitEntryField.swift | 12 ++++-------- .../TextFields/ItemDropdownEntryField.swift | 16 +++++++++++++++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift index 97bb8740..a6bd390e 100644 --- a/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DateDropdownEntryField.swift @@ -103,5 +103,7 @@ extension DateDropdownEntryField { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) guard let dictionary = json, !dictionary.isEmpty else { return } + + } } diff --git a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift index f8a2ccbf..b352a89b 100644 --- a/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/DigitEntryField.swift @@ -306,10 +306,10 @@ import UIKit return enabledTextFields } - - //-------------------------------------------------- - // MARK: - Text Field Delegate - //-------------------------------------------------- +} + +// MARK: - TextField Delegate +extension DigitEntryField { @objc public func textFieldShouldReturn(_ textField: UITextField) -> Bool { @@ -381,10 +381,6 @@ import UIKit return uiTextFieldDelegate?.textFieldShouldClear?(textField) ?? true } - //-------------------------------------------------- - // MARK: - Passed Along TextField delegate - //-------------------------------------------------- - @objc public func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { return uiTextFieldDelegate?.textFieldShouldBeginEditing?(textField) ?? true diff --git a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift index 33345a55..8f689e6b 100644 --- a/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/ItemDropdownEntryField.swift @@ -42,10 +42,20 @@ open class ItemDropdownEntryField: DropdownEntryField { // MARK: - Initializer //-------------------------------------------------- + public convenience init() { + self.init(frame: .zero) + setup() + } + public convenience init(pickerData: [String]) { self.init(frame: .zero) self.pickerData = pickerData + setup() + } + + private func setup() { + pickerView = MVMCoreUICommonViewsUtility.addPicker(to: textField, delegate: self) textField.hideBlinkingCaret = true uiTextFieldDelegate = self @@ -55,7 +65,7 @@ open class ItemDropdownEntryField: DropdownEntryField { // MARK: - Methods //-------------------------------------------------- - public func setPickerDelegate(delegate: UIPickerViewDelegate & UIPickerViewDataSource) { + public func setPickerDelegates(delegate: UIPickerViewDelegate & UIPickerViewDataSource) { pickerView?.delegate = delegate pickerView?.dataSource = delegate @@ -102,6 +112,10 @@ extension ItemDropdownEntryField { super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) guard let dictionary = json, !dictionary.isEmpty else { return } + + if let options = dictionary["options"] as? [String] { + pickerData = options + } } }