made public/open
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
0abc903793
commit
fedf1760ec
@ -9,7 +9,7 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import VDS
|
import VDS
|
||||||
|
|
||||||
class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFieldDelegate {
|
open class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFieldDelegate, ViewMaskingProtocol {
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
@ -18,9 +18,9 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi
|
|||||||
open var additionalData: [AnyHashable : Any]?
|
open var additionalData: [AnyHashable : Any]?
|
||||||
|
|
||||||
// Form Validation
|
// Form Validation
|
||||||
var fieldKey: String?
|
open var fieldKey: String?
|
||||||
var fieldValue: JSONValue?
|
open var fieldValue: JSONValue?
|
||||||
var groupName: String?
|
open var groupName: String?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Stored Properties
|
// MARK: - Stored Properties
|
||||||
@ -36,15 +36,12 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Computed Properties
|
// MARK: - Computed Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
/// The text of this textView.
|
open var shouldMaskWhileRecording: Bool {
|
||||||
open override var text: String? {
|
return viewModel.shouldMaskRecordedView ?? false
|
||||||
didSet {
|
|
||||||
viewModel?.text = text
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Placeholder access for the textView.
|
/// Placeholder access for the textView.
|
||||||
public var placeholder: String? {
|
open var placeholder: String? {
|
||||||
get { viewModel?.placeholder }
|
get { viewModel?.placeholder }
|
||||||
set {
|
set {
|
||||||
textView.placeholder = newValue ?? ""
|
textView.placeholder = newValue ?? ""
|
||||||
@ -52,26 +49,34 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override var errorText: String? {
|
/// The text of this textView.
|
||||||
|
open override var text: String? {
|
||||||
|
didSet {
|
||||||
|
viewModel?.text = text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open override var errorText: String? {
|
||||||
get {
|
get {
|
||||||
viewModel.dynamicErrorMessage ?? viewModel.errorMessage
|
viewModel.dynamicErrorMessage ?? viewModel.errorMessage
|
||||||
}
|
}
|
||||||
set {}
|
set {}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Delegate Properties
|
// MARK: - Delegate Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// 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?
|
open weak var observingTextViewDelegate: ObservingTextFieldDelegate?
|
||||||
|
|
||||||
/// 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? {
|
open weak var uiTextViewDelegate: UITextViewDelegate? {
|
||||||
get { textView.delegate }
|
get { textView.delegate }
|
||||||
set { textView.delegate = newValue }
|
set { textView.delegate = newValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func setBothTextDelegates(to delegate: (UITextViewDelegate & ObservingTextFieldDelegate)?) {
|
@objc open func setBothTextDelegates(to delegate: (UITextViewDelegate & ObservingTextFieldDelegate)?) {
|
||||||
observingTextViewDelegate = delegate
|
observingTextViewDelegate = delegate
|
||||||
uiTextViewDelegate = delegate
|
uiTextViewDelegate = delegate
|
||||||
}
|
}
|
||||||
@ -79,7 +84,7 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
//turn off internal required rule
|
//turn off internal required rule
|
||||||
useRequiredRule = false
|
useRequiredRule = false
|
||||||
@ -135,29 +140,33 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi
|
|||||||
uiTextViewDelegate = delegateObject?.uiTextViewDelegate
|
uiTextViewDelegate = delegateObject?.uiTextViewDelegate
|
||||||
observingTextViewDelegate = delegateObject?.observingTextFieldDelegate
|
observingTextViewDelegate = delegateObject?.observingTextFieldDelegate
|
||||||
|
|
||||||
if let accessibilityText = model.accessibilityText {
|
if let accessibilityText = viewModel.accessibilityText {
|
||||||
accessibilityLabel = accessibilityText
|
accessibilityLabel = accessibilityText
|
||||||
}
|
}
|
||||||
|
containerView.accessibilityIdentifier = viewModel.accessibilityIdentifier
|
||||||
textView.isEditable = viewModel.editable
|
textView.isEditable = viewModel.editable
|
||||||
textView.textAlignment = viewModel.textAlignment
|
textView.textAlignment = viewModel.textAlignment
|
||||||
textView.accessibilityIdentifier = model.accessibilityIdentifier
|
|
||||||
textView.placeholder = viewModel.placeholder ?? ""
|
textView.placeholder = viewModel.placeholder ?? ""
|
||||||
|
|
||||||
switch viewModel.type {
|
switch viewModel.type {
|
||||||
case .secure, .password:
|
case .secure, .password:
|
||||||
textView.isSecureTextEntry = true
|
textView.isSecureTextEntry = true
|
||||||
|
textView.shouldMaskWhileRecording = true
|
||||||
|
|
||||||
case .numberSecure:
|
case .numberSecure:
|
||||||
textView.isSecureTextEntry = true
|
textView.isSecureTextEntry = true
|
||||||
textView.keyboardType = .numberPad
|
textView.keyboardType = .numberPad
|
||||||
|
textView.shouldMaskWhileRecording = true
|
||||||
|
|
||||||
case .number:
|
case .number:
|
||||||
textView.keyboardType = .numberPad
|
textView.keyboardType = .numberPad
|
||||||
|
|
||||||
case .email:
|
case .email:
|
||||||
textView.keyboardType = .emailAddress
|
textView.keyboardType = .emailAddress
|
||||||
|
|
||||||
|
// case .securityCode, .creditCard:
|
||||||
|
// textView.shouldMaskWhileRecording = true
|
||||||
|
|
||||||
default: break
|
default: break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,3 +227,19 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal struct ViewMasking {
|
||||||
|
static var shouldMaskWhileRecording: UInt8 = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
extension VDS.TextView: ViewMaskingProtocol {
|
||||||
|
public var shouldMaskWhileRecording: Bool {
|
||||||
|
get {
|
||||||
|
return (objc_getAssociatedObject(self, &ViewMasking.shouldMaskWhileRecording) as? Bool) ?? false
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
objc_setAssociatedObject(self, &ViewMasking.shouldMaskWhileRecording, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import VDS
|
import VDS
|
||||||
|
|
||||||
class TextViewEntryFieldModel: TextEntryFieldModel {
|
public class TextViewEntryFieldModel: TextEntryFieldModel {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user