moving validator to parent
This commit is contained in:
parent
868836b963
commit
fb7760a329
@ -49,6 +49,9 @@ import UIKit
|
||||
|
||||
public var isValid: Bool = false
|
||||
|
||||
/// Validate on each entry in the textField. Default: true
|
||||
public var validateEachCharacter: Bool = true
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Computed Properties
|
||||
//--------------------------------------------------
|
||||
@ -229,6 +232,32 @@ import UIKit
|
||||
entryFieldContainer.updateView(size)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Validation
|
||||
//--------------------------------------------------
|
||||
|
||||
/// Executes on .textDidBeginEditingNotification
|
||||
@objc func startEditing() {
|
||||
isSelected = true
|
||||
}
|
||||
|
||||
/// Executes on .textDidChangeNotification (each character entry)
|
||||
@objc func valueChanged() {
|
||||
guard validateEachCharacter else { return }
|
||||
}
|
||||
|
||||
/// Executes on .textDidEndEditingNotification
|
||||
@objc func endInputing() {
|
||||
isSelected = false
|
||||
resignFirstResponder()
|
||||
|
||||
// Don't show error till user starts typing.
|
||||
guard text?.count ?? 0 != 0 else {
|
||||
showError = false
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - MoleculeViewProtocol
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -51,9 +51,6 @@ import UIKit
|
||||
|
||||
private var observingForChange: Bool = false
|
||||
|
||||
/// Validate on each entry in the textField. Default: true
|
||||
public var validateEachCharacter: Bool = true
|
||||
|
||||
/// Validate when user resigns editing. Default: true
|
||||
public var validateWhenDoneEditing: Bool = true
|
||||
|
||||
@ -261,27 +258,20 @@ import UIKit
|
||||
}
|
||||
|
||||
/// Executes on UITextField.textDidBeginEditingNotification
|
||||
@objc func startEditing() {
|
||||
isSelected = true
|
||||
@objc override func startEditing() {
|
||||
super.startEditing()
|
||||
textField.becomeFirstResponder()
|
||||
}
|
||||
|
||||
/// Executes on UITextField.textDidChangeNotification (each character entry)
|
||||
@objc func valueChanged() {
|
||||
guard validateEachCharacter else { return }
|
||||
isSelected = true
|
||||
@objc override func valueChanged() {
|
||||
super.valueChanged()
|
||||
validateTextField()
|
||||
}
|
||||
|
||||
/// Executes on UITextField.textDidEndEditingNotification
|
||||
@objc func endInputing() {
|
||||
resignFirstResponder()
|
||||
|
||||
// Don't show error till user starts typing.
|
||||
guard text?.count ?? 0 != 0 else {
|
||||
showError = false
|
||||
return
|
||||
}
|
||||
@objc override func endInputing() {
|
||||
super.endInputing()
|
||||
|
||||
if let isValid = textEntryFieldModel?.isValid {
|
||||
self.isValid = isValid
|
||||
|
||||
@ -24,9 +24,6 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
/// Validate on each entry in the textView. Default: true
|
||||
public var validateEachCharacter: Bool = true
|
||||
|
||||
private var observingForChange: Bool = false
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -194,27 +191,20 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
||||
}
|
||||
|
||||
/// Executes on UITextView.textDidBeginEditingNotification
|
||||
@objc func startEditing() {
|
||||
isSelected = true
|
||||
@objc override func startEditing() {
|
||||
super.startEditing()
|
||||
_ = textView.becomeFirstResponder()
|
||||
}
|
||||
|
||||
/// Executes on UITextView.textDidChangeNotification (each character entry)
|
||||
@objc func valueChanged() {
|
||||
guard validateEachCharacter else { return }
|
||||
@objc override func valueChanged() {
|
||||
super.valueChanged()
|
||||
validateTextView()
|
||||
}
|
||||
|
||||
/// Executes on UITextView.textDidEndEditingNotification
|
||||
@objc func endInputing() {
|
||||
isSelected = false
|
||||
resignFirstResponder()
|
||||
|
||||
// Don't show error till user starts typing.
|
||||
guard text?.count ?? 0 != 0 else {
|
||||
showError = false
|
||||
return
|
||||
}
|
||||
@objc override func endInputing() {
|
||||
super.endInputing()
|
||||
|
||||
if let isValid = textViewEntryFieldModel?.isValid {
|
||||
self.isValid = isValid
|
||||
|
||||
Loading…
Reference in New Issue
Block a user