more changes.

This commit is contained in:
Kevin G Christiano 2019-10-13 12:00:36 -04:00
parent d4df5745f4
commit 10692ee21e

View File

@ -9,7 +9,7 @@
import UIKit
@objc protocol TextFieldDelegate: NSObjectProtocol {
@objc public protocol MFTextFieldDelegate: NSObjectProtocol {
/// Called when the entered text becomes valid based on the validation block
@objc optional func entryIsValid(_ textfield: TextField?)
/// Called when the entered text becomes invalid based on the validation block
@ -49,10 +49,8 @@ import UIKit
weak var label: UILabel?
//accesories
weak var pickerView: UIPickerView?
//utility
var observingForChanges = false
var errorShowing = false
var hasDropDown = false
@ -338,10 +336,10 @@ import UIKit
DispatchQueue.main.async { [weak self] in
self?.separatorHeightConstraint!.constant = 1
self?.separatorView?.backgroundColor = UIColor.black
self?.separatorView?.backgroundColor = .black
self?.layoutIfNeeded()
self?.errorShowing = false
self?.label?.textColor = UIColor.black
self?.label?.textColor = .black
self?.label?.text = ""
self?.textField?.accessibilityValue = nil
self?.setNeedsDisplay()
@ -349,11 +347,9 @@ import UIKit
}
}
// MARK: - Setters
func setPlaceholder(_ placeholder: String?, with color: UIColor?) {
customPlaceHolderColor = color
// fixed crash issue
if placeholder != nil {
if let color = color {
textField!.attributedPlaceholder = NSAttributedString(string: placeholder ?? "", attributes: [
@ -600,12 +596,12 @@ import UIKit
self.errorMessage = errMessage
}
if mfTextFieldDelegate.responds(to: #selector(entryIsInvalid(_:))) {
mfTextFieldDelegate?.entryIsInvalid(self)
mfTextFieldDelegate?.entryIsInvalid!(self)
}
} else if !previousValidity && valid {
hideError()
if mfTextFieldDelegate.responds(to: #selector(entryIsValid(_:))) {
mfTextFieldDelegate.entryIsValid(self)
if mfTextFieldDelegate?.responds(to: #selector(entryIsValid(_:))) {
mfTextFieldDelegate?.entryIsValid!(self)
}
}
}
@ -613,19 +609,19 @@ import UIKit
func endInputing() {
if isValid {
hideError()
separatorView.backgroundColor = .black
separatorView!.backgroundColor = .black
} else {
if errMessage {
if (errMessage != nil) {
self.errorMessage = errMessage
}
}
}
func startEditing() {
textField.becomeFirstResponder()
textField?.becomeFirstResponder()
if !errorShowing {
separatorView?.backgroundColor = .black
separatorHeightConstraint.constant = 1
separatorHeightConstraint?.constant = 1
}
}
@ -645,13 +641,13 @@ extension TextField {
override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
if (delegateObject is MVMCoreUIDelegateObject) {
FormValidator.setupValidation(withMolecule: self, delegate: delegateObject?.formValidationProtocol)
let formValidator = FormValidator.getForDelegate(delegateObject?.formValidationProtocol)
if let delegateObject = delegateObject{
FormValidator.setupValidation(molecule: self, delegate: delegateObject.formValidationProtocol)
let formValidator = FormValidator.getForDelegate(delegateObject.formValidationProtocol)
self.withMap = json
mfTextFieldDelegate = formValidator
uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate
uiTextFieldDelegate = delegateObject.uiTextFieldDelegate
MVMCoreUICommonViewsUtility.addDismissToolbar(textField!, delegate: uiTextFieldDelegate)
}
}