Merge branch 'develop' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui into develop
This commit is contained in:
commit
9c6b5ba55d
@ -26,6 +26,11 @@
|
||||
case action
|
||||
}
|
||||
|
||||
open override func setDefaults() {
|
||||
super.setDefaults()
|
||||
enableClipboardActions = false
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Codec
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -83,6 +83,9 @@ import Foundation
|
||||
case shouldMaskRecordedView
|
||||
}
|
||||
|
||||
/// Sets the default values. Should be called on init.
|
||||
open func setDefaults() { }
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Validation Methods
|
||||
//--------------------------------------------------
|
||||
@ -119,6 +122,7 @@ import Foundation
|
||||
baseValue = text
|
||||
self.titleStateLabel = FormLabelModel(text: "")
|
||||
self.feedbackStateLabel = FormLabelModel(text: "")
|
||||
setDefaults()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -157,6 +161,7 @@ import Foundation
|
||||
self.feedbackStateLabel = FormLabelModel(model: LabelModel(text: feedback ?? "",
|
||||
fontStyle: FormLabelModel.defaultFontStyle,
|
||||
textColor: Color(uiColor: .mvmCoolGray6)))
|
||||
setDefaults()
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
|
||||
@ -338,6 +338,7 @@ import UIKit
|
||||
placeholder = model.placeholder
|
||||
|
||||
textField.shouldMaskWhileRecording = model.shouldMaskRecordedView ?? true
|
||||
textField.enableClipboardActions = model.enableClipboardActions
|
||||
|
||||
switch model.type {
|
||||
case .password, .secure:
|
||||
|
||||
@ -37,6 +37,7 @@
|
||||
public var clearTextOnTap: Bool = false
|
||||
public var displayFormat: String?
|
||||
public var displayMask: String?
|
||||
public var enableClipboardActions: Bool = true
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
@ -112,6 +113,7 @@
|
||||
case clearTextOnTap
|
||||
case displayFormat
|
||||
case displayMask
|
||||
case enableClipboardActions
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -143,6 +145,10 @@
|
||||
if let textAlignment = try typeContainer.decodeIfPresent(NSTextAlignment.self, forKey: .textAlignment) {
|
||||
self.textAlignment = textAlignment
|
||||
}
|
||||
|
||||
if let enableClipboardActions = try typeContainer.decodeIfPresent(Bool.self, forKey: .enableClipboardActions) {
|
||||
self.enableClipboardActions = enableClipboardActions
|
||||
}
|
||||
}
|
||||
|
||||
open override func encode(to encoder: Encoder) throws {
|
||||
@ -157,5 +163,6 @@
|
||||
try container.encode(enabledTextColor, forKey: .enabledTextColor)
|
||||
try container.encode(disabledTextColor, forKey: .disabledTextColor)
|
||||
try container.encode(clearTextOnTap, forKey: .clearTextOnTap)
|
||||
try container.encode(enableClipboardActions, forKey: .enableClipboardActions)
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,18 +241,7 @@ public typealias ActionBlock = () -> ()
|
||||
case left
|
||||
}
|
||||
|
||||
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject? = nil, _ additionalData: [AnyHashable: Any]? = nil) {
|
||||
|
||||
clauses = []
|
||||
text = nil
|
||||
attributedText = nil
|
||||
originalAttributedString = nil
|
||||
shouldMaskWhileRecording = model.shouldMaskRecordedView ?? false
|
||||
|
||||
guard let labelModel = model as? LabelModel else { return }
|
||||
|
||||
text = labelModel.text
|
||||
|
||||
@objc public func resetAttributeStyle() {
|
||||
/*
|
||||
* This is to address a reuse issue with iOS 13 and up.
|
||||
* Even if you set text & attributedText to nil, the moment you set text with a value,
|
||||
@ -274,6 +263,21 @@ public typealias ActionBlock = () -> ()
|
||||
|
||||
self.attributedText = attributedString
|
||||
}
|
||||
}
|
||||
|
||||
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject? = nil, _ additionalData: [AnyHashable: Any]? = nil) {
|
||||
|
||||
clauses = []
|
||||
text = nil
|
||||
attributedText = nil
|
||||
originalAttributedString = nil
|
||||
shouldMaskWhileRecording = model.shouldMaskRecordedView ?? false
|
||||
|
||||
guard let labelModel = model as? LabelModel else { return }
|
||||
|
||||
text = labelModel.text
|
||||
|
||||
resetAttributeStyle()
|
||||
|
||||
hero = labelModel.hero
|
||||
Label.setLabel(self, withHTML: labelModel.html)
|
||||
|
||||
@ -41,7 +41,6 @@ import Foundation
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
isAccessibilityElement = true
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -53,7 +52,8 @@ import Foundation
|
||||
|
||||
guard let model = model as? ListOneColumnTextWithWhitespaceDividerTallModel else { return }
|
||||
stack.updateContainedMolecules(with: [model.headline, model.body], delegateObject, additionalData)
|
||||
updateAccessibilityLabel()
|
||||
|
||||
updateAccessibilityLabel(model: model)
|
||||
}
|
||||
|
||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
@ -64,24 +64,25 @@ import Foundation
|
||||
super.reset()
|
||||
headline.setFontStyle(.BoldTitleMedium)
|
||||
body.setFontStyle(.RegularBodySmall)
|
||||
accessibilityLabel = nil
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
// MARK: - Accessibility
|
||||
//----------------------------------------------------
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
|
||||
func updateAccessibilityLabel(model: ListOneColumnTextWithWhitespaceDividerTallModel) {
|
||||
|
||||
var message = ""
|
||||
|
||||
if let headlineLabel = headline.text, !headlineLabel.isEmpty {
|
||||
|
||||
if let headlineLabel = model.headline.accessibilityText ?? headline.text, !headlineLabel.isEmpty {
|
||||
message += headlineLabel + ", "
|
||||
}
|
||||
|
||||
if let bodyLabel = body.text, !bodyLabel.isEmpty {
|
||||
|
||||
if let bodyLabel = model.body?.accessibilityText ?? body.text, !bodyLabel.isEmpty {
|
||||
message += bodyLabel
|
||||
}
|
||||
|
||||
|
||||
accessibilityLabel = message
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ public protocol TextInputDidDeleteProtocol: AnyObject {
|
||||
|
||||
/// Set to true to hide the blinking textField cursor.
|
||||
public var hideBlinkingCaret = false
|
||||
|
||||
public var enableClipboardActions: Bool = true
|
||||
public var shouldMaskWhileRecording: Bool = true
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -74,6 +74,8 @@ public protocol TextInputDidDeleteProtocol: AnyObject {
|
||||
super.deleteBackward()
|
||||
didDeleteDelegate?.textInputDidDelete()
|
||||
}
|
||||
|
||||
open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { enableClipboardActions }
|
||||
}
|
||||
|
||||
/// MARK:- MVMCoreViewProtocol
|
||||
@ -91,7 +93,7 @@ extension TextField: MVMCoreViewProtocol {
|
||||
/// MARK:- MoleculeViewProtocol
|
||||
extension TextField: MoleculeViewProtocol {
|
||||
|
||||
open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
|
||||
if let color = model.backgroundColor?.uiColor {
|
||||
backgroundColor = color
|
||||
|
||||
@ -106,7 +106,7 @@ public final class Color: Codable {
|
||||
if colorString.hasPrefix("#") {
|
||||
hex = colorString.replacingOccurrences(of: "#", with: "")
|
||||
} else {
|
||||
guard let hexString = UIColor.names[colorString]?.hex else { throw ColorError.badName(reason: "Check the spelling of your color.") }
|
||||
guard let hexString = UIColor.names[colorString]?.hex else { throw ColorError.badName(reason: "Check the spelling of your color: \(colorString)") }
|
||||
hex = hexString.replacingOccurrences(of: "#", with: "")
|
||||
name = colorString
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user