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