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