removing selegate
This commit is contained in:
parent
a2451a523d
commit
19a6ef8a2a
@ -16,13 +16,7 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
|
|
||||||
open private(set) var textView: TextView = {
|
open private(set) var textView: TextView = {
|
||||||
let textView = TextView()
|
let textView = TextView()
|
||||||
textView.isAccessibilityElement = true
|
|
||||||
textView.setContentCompressionResistancePriority(.required, for: .vertical)
|
textView.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
textView.font = Styler.Font.RegularBodyLarge.getFont()
|
|
||||||
textView.textColor = .mvmBlack
|
|
||||||
textView.smartQuotesType = .no
|
|
||||||
textView.smartDashesType = .no
|
|
||||||
textView.smartInsertDeleteType = .no
|
|
||||||
return textView
|
return textView
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -103,9 +97,6 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
// MARK: - Delegate Properties
|
// MARK: - Delegate Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// Holds a reference to the delegating class so this class can internally influence the TextView behavior as well.
|
|
||||||
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 observingTextViewDelegate: ObservingTextFieldDelegate? {
|
public weak var observingTextViewDelegate: ObservingTextFieldDelegate? {
|
||||||
didSet {
|
didSet {
|
||||||
@ -127,10 +118,7 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
/// If you're using a ViewController, you must set this to it
|
/// If you're using a ViewController, you must set this to it
|
||||||
public weak var uiTextViewDelegate: UITextViewDelegate? {
|
public weak var uiTextViewDelegate: UITextViewDelegate? {
|
||||||
get { return textView.delegate }
|
get { return textView.delegate }
|
||||||
set {
|
set { textView.delegate = newValue }
|
||||||
textView.delegate = self
|
|
||||||
proprietorTextDelegate = newValue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func setBothTextDelegates(to delegate: (UITextViewDelegate & ObservingTextFieldDelegate)?) {
|
@objc public func setBothTextDelegates(to delegate: (UITextViewDelegate & ObservingTextFieldDelegate)?) {
|
||||||
@ -160,10 +148,14 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
])
|
])
|
||||||
|
|
||||||
heightConstraint = textView.heightAnchor.constraint(equalToConstant: 0)
|
heightConstraint = textView.heightAnchor.constraint(equalToConstant: 0)
|
||||||
|
|
||||||
accessibilityElements = [titleLabel, textView, feedbackLabel]
|
accessibilityElements = [titleLabel, textView, feedbackLabel]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func updateView(_ size: CGFloat) {
|
||||||
|
super.updateView(size)
|
||||||
|
textView.updateView(size)
|
||||||
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
|
||||||
@ -199,52 +191,8 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
/// Executes on UITextView.textDidEndEditingNotification
|
/// Executes on UITextView.textDidEndEditingNotification
|
||||||
@objc func endInputing() {
|
@objc func endInputing() {
|
||||||
resignFirstResponder()
|
resignFirstResponder()
|
||||||
showError = !isValid
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
|
||||||
// MARK: - UITextViewDelegate
|
|
||||||
//--------------------------------------------------
|
|
||||||
|
|
||||||
@objc public func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
|
|
||||||
|
|
||||||
return proprietorTextDelegate?.textViewShouldBeginEditing?(textView) ?? true
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc public func textViewDidBeginEditing(_ textView: UITextView) {
|
|
||||||
|
|
||||||
isSelected = true
|
|
||||||
proprietorTextDelegate?.textViewDidBeginEditing?(textView)
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
|
|
||||||
|
|
||||||
return proprietorTextDelegate?.textView?(textView, shouldChangeTextIn: range, replacementText: text) ?? true
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc public func textViewDidChange(_ textView: UITextView) {
|
|
||||||
|
|
||||||
validateTextView()
|
|
||||||
proprietorTextDelegate?.textViewDidChange?(textView)
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc public func textViewShouldEndEditing(_ textView: UITextView) -> Bool {
|
|
||||||
|
|
||||||
return proprietorTextDelegate?.textViewShouldEndEditing?(textView) ?? true
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc public func textViewDidEndEditing(_ textView: UITextView) {
|
|
||||||
|
|
||||||
isSelected = false
|
isSelected = false
|
||||||
|
showError = !isValid
|
||||||
if isValid {
|
|
||||||
showError = false
|
|
||||||
entryFieldContainer.bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor
|
|
||||||
} else {
|
|
||||||
showError = true
|
|
||||||
}
|
|
||||||
|
|
||||||
proprietorTextDelegate?.textViewDidEndEditing?(textView)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -291,6 +239,7 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
default: break
|
default: break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// No point in configuring if the TextView is Read-only.
|
||||||
if textView.isEditable {
|
if textView.isEditable {
|
||||||
FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate)
|
FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate)
|
||||||
setupTextViewToolbar()
|
setupTextViewToolbar()
|
||||||
|
|||||||
@ -76,7 +76,9 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open func updateView(_ size: CGFloat) { }
|
open func updateView(_ size: CGFloat) {
|
||||||
|
font = fontStyle.getFont()
|
||||||
|
}
|
||||||
|
|
||||||
/// Will be called only once.
|
/// Will be called only once.
|
||||||
open func setupView() {
|
open func setupView() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user