value change
This commit is contained in:
parent
f1466763b7
commit
4f3f52195e
@ -100,19 +100,19 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
private weak var proprietorTextDelegate: UITextViewDelegate?
|
private weak var proprietorTextDelegate: UITextViewDelegate?
|
||||||
|
|
||||||
/// The delegate and block for validation. Validates if the text that the user has entered.
|
/// The delegate and block for validation. Validates if the text that the user has entered.
|
||||||
public weak var observingTextFieldDelegate: ObservingTextFieldDelegate? {
|
public weak var observingTextViewdDelegate: ObservingTextFieldDelegate? {
|
||||||
didSet {
|
didSet {
|
||||||
if observingTextFieldDelegate != nil && !observingForChange {
|
if observingTextViewdDelegate != nil && !observingForChange {
|
||||||
observingForChange = true
|
observingForChange = true
|
||||||
// NotificationCenter.default.addObserver(self, selector: #selector(valueChanged), name: UITextView.textDidChangeNotification, object: textView)
|
NotificationCenter.default.addObserver(self, selector: #selector(valueChanged), name: UITextView.textDidChangeNotification, object: textView)
|
||||||
// NotificationCenter.default.addObserver(self, selector: #selector(endInputing), name: UITextView.textDidEndEditingNotification, object: textView)
|
NotificationCenter.default.addObserver(self, selector: #selector(endInputing), name: UITextView.textDidEndEditingNotification, object: textView)
|
||||||
// NotificationCenter.default.addObserver(self, selector: #selector(startEditing), name: UITextView.textDidBeginEditingNotification, object: textView)
|
NotificationCenter.default.addObserver(self, selector: #selector(startEditing), name: UITextView.textDidBeginEditingNotification, object: textView)
|
||||||
|
|
||||||
} else if observingTextFieldDelegate == nil && observingForChange {
|
} else if observingTextViewdDelegate == nil && observingForChange {
|
||||||
observingForChange = false
|
observingForChange = false
|
||||||
// NotificationCenter.default.removeObserver(self, name: UITextView.textDidChangeNotification, object: textView)
|
NotificationCenter.default.removeObserver(self, name: UITextView.textDidChangeNotification, object: textView)
|
||||||
// NotificationCenter.default.removeObserver(self, name: UITextView.textDidEndEditingNotification, object: textView)
|
NotificationCenter.default.removeObserver(self, name: UITextView.textDidEndEditingNotification, object: textView)
|
||||||
// NotificationCenter.default.removeObserver(self, name: UITextView.textDidBeginEditingNotification, object: textView)
|
NotificationCenter.default.removeObserver(self, name: UITextView.textDidBeginEditingNotification, object: textView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,12 +127,12 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc public func setBothTextDelegates(to delegate: (UITextViewDelegate & ObservingTextFieldDelegate)?) {
|
@objc public func setBothTextDelegates(to delegate: (UITextViewDelegate & ObservingTextFieldDelegate)?) {
|
||||||
observingTextFieldDelegate = delegate
|
observingTextViewdDelegate = delegate
|
||||||
uiTextViewDelegate = delegate
|
uiTextViewDelegate = delegate
|
||||||
}
|
}
|
||||||
|
|
||||||
open func setupTextViewToolbar() {
|
open func setupTextViewToolbar() {
|
||||||
let observingDelegate = observingTextFieldDelegate ?? self
|
let observingDelegate = observingTextViewdDelegate ?? self
|
||||||
textView.inputAccessoryView = UIToolbar.getToolbarWithDoneButton(delegate: observingDelegate,
|
textView.inputAccessoryView = UIToolbar.getToolbarWithDoneButton(delegate: observingDelegate,
|
||||||
action: #selector(observingDelegate.dismissFieldInput))
|
action: #selector(observingDelegate.dismissFieldInput))
|
||||||
}
|
}
|
||||||
@ -154,9 +154,6 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
|
|
||||||
heightConstraint = textView.heightAnchor.constraint(equalToConstant: 0)
|
heightConstraint = textView.heightAnchor.constraint(equalToConstant: 0)
|
||||||
|
|
||||||
// let tap = UITapGestureRecognizer(target: self, action: #selector(startEditing))
|
|
||||||
// entryFieldContainer.addGestureRecognizer(tap)
|
|
||||||
|
|
||||||
accessibilityElements = [titleLabel, textView, feedbackLabel]
|
accessibilityElements = [titleLabel, textView, feedbackLabel]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,38 +175,36 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Methods
|
// MARK: - Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
//
|
|
||||||
// /// Executes on UITextField.textDidBeginEditingNotification
|
/// Validates the text of the entry field.
|
||||||
// @objc func startEditing() {
|
|
||||||
// textView.becomeFirstResponder()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /// Executes on UITextField.textDidChangeNotification (each character entry)
|
|
||||||
// @objc func valueChanged() {
|
|
||||||
// guard validateEachCharacter else { return }
|
|
||||||
// isSelected = true
|
|
||||||
// validateTextField()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /// Validates the text of the entry field.
|
|
||||||
@objc public func validateTextField() {
|
@objc public func validateTextField() {
|
||||||
text = textView.text
|
text = textView.text
|
||||||
_ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
|
_ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// /// Executes on UITextField.textDidEndEditingNotification
|
|
||||||
// @objc func endInputing() {
|
|
||||||
// resignFirstResponder()
|
|
||||||
// if isValid {
|
|
||||||
// showError = false
|
|
||||||
// entryFieldContainer.bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @objc public func dismissFieldInput(_ sender: Any?) {
|
|
||||||
// resignFirstResponder()
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
/// Executes on UITextField.textDidBeginEditingNotification
|
||||||
|
@objc func startEditing() {
|
||||||
|
isSelected = true
|
||||||
|
textView.becomeFirstResponder()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Executes on UITextField.textDidChangeNotification (each character entry)
|
||||||
|
@objc func valueChanged() {
|
||||||
|
guard validateEachCharacter else { return }
|
||||||
|
isSelected = true
|
||||||
|
validateTextField()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Executes on UITextField.textDidEndEditingNotification
|
||||||
|
@objc func endInputing() {
|
||||||
|
resignFirstResponder()
|
||||||
|
if isValid {
|
||||||
|
showError = false
|
||||||
|
entryFieldContainer.bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - UITextViewDelegate
|
// MARK: - UITextViewDelegate
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user