general working order
This commit is contained in:
parent
7085122b1b
commit
66c638a1b4
@ -96,6 +96,9 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
||||
// MARK: - Delegate Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
/// Holds a reference to the delegating class so this class can internally influence the TextField behavior as well.
|
||||
private weak var proprietorTextDelegate: UITextViewDelegate?
|
||||
|
||||
/// The delegate and block for validation. Validates if the text that the user has entered.
|
||||
public weak var observingTextFieldDelegate: ObservingTextFieldDelegate? {
|
||||
didSet {
|
||||
@ -117,7 +120,10 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
||||
/// If you're using a ViewController, you must set this to it
|
||||
public weak var uiTextViewDelegate: UITextViewDelegate? {
|
||||
get { return textView.delegate }
|
||||
set { textView.delegate = newValue }
|
||||
set {
|
||||
textView.delegate = self
|
||||
proprietorTextDelegate = newValue
|
||||
}
|
||||
}
|
||||
|
||||
@objc public func setBothTextDelegates(to delegate: (UITextViewDelegate & ObservingTextFieldDelegate)?) {
|
||||
@ -128,7 +134,7 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
||||
open func setupTextViewToolbar() {
|
||||
let observingDelegate = observingTextFieldDelegate ?? self
|
||||
textView.inputAccessoryView = UIToolbar.getToolbarWithDoneButton(delegate: observingDelegate,
|
||||
action: #selector(observingDelegate.dismissFieldInput))
|
||||
action: #selector(observingDelegate.dismissFieldInput))
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -137,7 +143,6 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
||||
|
||||
@objc open override func setupFieldContainerContent(_ container: UIView) {
|
||||
|
||||
textView.delegate = self
|
||||
container.addSubview(textView)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
@ -176,7 +181,6 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
||||
|
||||
/// Executes on UITextField.textDidBeginEditingNotification
|
||||
@objc func startEditing() {
|
||||
isSelected = true
|
||||
textView.becomeFirstResponder()
|
||||
}
|
||||
|
||||
@ -206,6 +210,44 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
||||
resignFirstResponder()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - UITextViewDelegate
|
||||
//--------------------------------------------------
|
||||
|
||||
@objc public func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
|
||||
|
||||
return proprietorTextDelegate?.textViewShouldBeginEditing?(textView) ?? true
|
||||
}
|
||||
|
||||
@objc public func textViewDidBeginEditing(_ textView: UITextView) {
|
||||
|
||||
self.textView.setTextAppearance()
|
||||
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) {
|
||||
|
||||
proprietorTextDelegate?.textViewDidChange?(textView)
|
||||
}
|
||||
|
||||
@objc public func textViewShouldEndEditing(_ textView: UITextView) -> Bool {
|
||||
|
||||
return proprietorTextDelegate?.textViewShouldEndEditing?(textView) ?? true
|
||||
}
|
||||
|
||||
@objc public func textViewDidEndEditing(_ textView: UITextView) {
|
||||
|
||||
self.textView.setPlaceholderIfAvailable()
|
||||
isSelected = false
|
||||
proprietorTextDelegate?.textViewDidEndEditing?(textView)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - MoleculeViewProtocol
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -30,9 +30,7 @@ import UIKit
|
||||
public var placeholderTextColor: UIColor = .mvmCoolGray3
|
||||
|
||||
public var isEnabled: Bool = true {
|
||||
didSet {
|
||||
isUserInteractionEnabled = isEnabled
|
||||
}
|
||||
didSet { isUserInteractionEnabled = isEnabled }
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -42,18 +40,6 @@ import UIKit
|
||||
/// Holds a reference to the delegating class so this class can internally influence the TextField behavior as well.
|
||||
public weak var didDeleteDelegate: TextInputDidDeleteProtocol?
|
||||
|
||||
/// Holds a reference to the delegating class so this class can internally influence the TextField behavior as well.
|
||||
private weak var proprietorTextDelegate: UITextViewDelegate?
|
||||
|
||||
/// If you're using a ViewController, you must set this to it.
|
||||
public weak var uiTextViewDelegate: UITextViewDelegate? {
|
||||
get { return delegate }
|
||||
set {
|
||||
delegate = self
|
||||
proprietorTextDelegate = newValue
|
||||
}
|
||||
}
|
||||
|
||||
var delegateObject: MVMCoreUIDelegateObject?
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -116,7 +102,6 @@ import UIKit
|
||||
showsVerticalScrollIndicator = false
|
||||
showsHorizontalScrollIndicator = false
|
||||
isSecureTextEntry = false
|
||||
// textContainerInset = UIEdgeInsets(top: Padding.Three, left: Padding.Three, bottom: Padding.Three, right: Padding.Three)
|
||||
backgroundColor = .mvmWhite
|
||||
clipsToBounds = true
|
||||
smartQuotesType = .no
|
||||
@ -201,40 +186,4 @@ import UIKit
|
||||
|
||||
resignFirstResponder()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - UITextViewDelegate
|
||||
//--------------------------------------------------
|
||||
|
||||
@objc public func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
|
||||
|
||||
return proprietorTextDelegate?.textViewShouldBeginEditing?(textView) ?? true
|
||||
}
|
||||
|
||||
@objc public func textViewDidBeginEditing(_ textView: UITextView) {
|
||||
|
||||
setTextAppearance()
|
||||
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) {
|
||||
|
||||
proprietorTextDelegate?.textViewDidChange?(textView)
|
||||
}
|
||||
|
||||
@objc public func textViewShouldEndEditing(_ textView: UITextView) -> Bool {
|
||||
|
||||
return proprietorTextDelegate?.textViewShouldEndEditing?(textView) ?? true
|
||||
}
|
||||
|
||||
@objc public func textViewDidEndEditing(_ textView: UITextView) {
|
||||
|
||||
setPlaceholderIfAvailable()
|
||||
proprietorTextDelegate?.textViewDidEndEditing?(textView)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user