general working order
This commit is contained in:
parent
7085122b1b
commit
66c638a1b4
@ -96,6 +96,9 @@ 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 TextField 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 observingTextFieldDelegate: ObservingTextFieldDelegate? {
|
public weak var observingTextFieldDelegate: ObservingTextFieldDelegate? {
|
||||||
didSet {
|
didSet {
|
||||||
@ -117,7 +120,10 @@ 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 { textView.delegate = newValue }
|
set {
|
||||||
|
textView.delegate = self
|
||||||
|
proprietorTextDelegate = newValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func setBothTextDelegates(to delegate: (UITextViewDelegate & ObservingTextFieldDelegate)?) {
|
@objc public func setBothTextDelegates(to delegate: (UITextViewDelegate & ObservingTextFieldDelegate)?) {
|
||||||
@ -128,7 +134,7 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
open func setupTextViewToolbar() {
|
open func setupTextViewToolbar() {
|
||||||
let observingDelegate = observingTextFieldDelegate ?? self
|
let observingDelegate = observingTextFieldDelegate ?? self
|
||||||
textView.inputAccessoryView = UIToolbar.getToolbarWithDoneButton(delegate: observingDelegate,
|
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) {
|
@objc open override func setupFieldContainerContent(_ container: UIView) {
|
||||||
|
|
||||||
textView.delegate = self
|
|
||||||
container.addSubview(textView)
|
container.addSubview(textView)
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
@ -176,7 +181,6 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
|
|
||||||
/// Executes on UITextField.textDidBeginEditingNotification
|
/// Executes on UITextField.textDidBeginEditingNotification
|
||||||
@objc func startEditing() {
|
@objc func startEditing() {
|
||||||
isSelected = true
|
|
||||||
textView.becomeFirstResponder()
|
textView.becomeFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,6 +210,44 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
|||||||
resignFirstResponder()
|
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
|
// MARK: - MoleculeViewProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -30,9 +30,7 @@ import UIKit
|
|||||||
public var placeholderTextColor: UIColor = .mvmCoolGray3
|
public var placeholderTextColor: UIColor = .mvmCoolGray3
|
||||||
|
|
||||||
public var isEnabled: Bool = true {
|
public var isEnabled: Bool = true {
|
||||||
didSet {
|
didSet { isUserInteractionEnabled = isEnabled }
|
||||||
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.
|
/// Holds a reference to the delegating class so this class can internally influence the TextField behavior as well.
|
||||||
public weak var didDeleteDelegate: TextInputDidDeleteProtocol?
|
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?
|
var delegateObject: MVMCoreUIDelegateObject?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -116,7 +102,6 @@ import UIKit
|
|||||||
showsVerticalScrollIndicator = false
|
showsVerticalScrollIndicator = false
|
||||||
showsHorizontalScrollIndicator = false
|
showsHorizontalScrollIndicator = false
|
||||||
isSecureTextEntry = false
|
isSecureTextEntry = false
|
||||||
// textContainerInset = UIEdgeInsets(top: Padding.Three, left: Padding.Three, bottom: Padding.Three, right: Padding.Three)
|
|
||||||
backgroundColor = .mvmWhite
|
backgroundColor = .mvmWhite
|
||||||
clipsToBounds = true
|
clipsToBounds = true
|
||||||
smartQuotesType = .no
|
smartQuotesType = .no
|
||||||
@ -201,40 +186,4 @@ import UIKit
|
|||||||
|
|
||||||
resignFirstResponder()
|
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