diff --git a/VDS/Components/TextFields/EntryFieldBase.swift b/VDS/Components/TextFields/EntryFieldBase.swift
index 30df7699..ea023736 100644
--- a/VDS/Components/TextFields/EntryFieldBase.swift
+++ b/VDS/Components/TextFields/EntryFieldBase.swift
@@ -376,7 +376,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
if isEnabled {
let optionColorAttr = ColorLabelAttribute(location: oldText.count + 1,
length: 8,
- color: VDSColor.elementsSecondaryOnlight)
+ color: secondaryColorConfiguration.getColor(self))
attributes.append(optionColorAttr)
}
diff --git a/VDS/Components/TextFields/InputField/FieldTypes/CreditCard.swift b/VDS/Components/TextFields/InputField/FieldTypes/CreditCard.swift
index 43fd6309..bd512b50 100644
--- a/VDS/Components/TextFields/InputField/FieldTypes/CreditCard.swift
+++ b/VDS/Components/TextFields/InputField/FieldTypes/CreditCard.swift
@@ -19,6 +19,7 @@ extension InputField {
case dinersClub
case jcb
case unionPay
+ case placeholder
public func imageName(surface: Surface) -> String {
func getImageName(_ surface: Surface, name: String) -> String {
@@ -29,10 +30,11 @@ extension InputField {
case .mastercard: return "mastercard"
case .amex: return "amex"
case .discover: return "discover"
- case .dinersClub: return "dinersClub"//getImageName(surface, name: "dinersClub")
+ case .dinersClub: return getImageName(surface, name: "dinersClub")
case .jcb: return "jcb"
case .unionPay: return getImageName(surface, name: "unionPay")
- default: return getImageName(surface, name: "generic")
+ case .generic: return getImageName(surface, name: "generic")
+ default: return getImageName(surface, name: "placeholder")
}
}
@@ -141,7 +143,7 @@ extension InputField {
override func textFieldDidBeginEditing(_ inputField: InputField, textField: UITextField) {
//reset the textField when you start editing
value = nil
- inputField.cardType = .generic
+ inputField.cardType = .placeholder
textField.text = ""
inputField.validate()
updateLeftImage(inputField)
diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift
index 76cdaa2a..516954cd 100644
--- a/VDS/Components/TextFields/InputField/InputField.swift
+++ b/VDS/Components/TextFields/InputField/InputField.swift
@@ -68,7 +68,11 @@ open class InputField: EntryFieldBase {
//--------------------------------------------------
// MARK: - CreditCard/SecurityCode
//--------------------------------------------------
- open var cardType: CreditCardType = .generic { didSet { setNeedsUpdate() } }
+ open var cardType: CreditCardType = .placeholder {
+ didSet {
+ setNeedsUpdate()
+ }
+ }
//--------------------------------------------------
// MARK: - Password
//--------------------------------------------------
@@ -97,7 +101,7 @@ open class InputField: EntryFieldBase {
/// UITextField shown in the InputField.
open var textField = TextField().with {
$0.translatesAutoresizingMaskIntoConstraints = false
- $0.font = TextStyle.bodyLarge.font
+ $0.textStyle = TextStyle.bodyLarge
}
/// Color configuration for the textField.
@@ -247,7 +251,7 @@ open class InputField: EntryFieldBase {
successLabel.isHidden = false
errorLabel.isHidden = true
statusIcon.name = .checkmarkAlt
- statusIcon.color = VDSColor.paletteBlack
+ statusIcon.color = iconColorConfiguration.getColor(self)
statusIcon.surface = surface
statusIcon.isHidden = !isEnabled
} else {
diff --git a/VDS/Components/TextFields/InputField/TextField.swift b/VDS/Components/TextFields/InputField/TextField.swift
index 0488f0b2..b054741d 100644
--- a/VDS/Components/TextFields/InputField/TextField.swift
+++ b/VDS/Components/TextFields/InputField/TextField.swift
@@ -8,6 +8,7 @@
import Foundation
import UIKit
import Combine
+import VDSTokens
@objc(VDSTextField)
open class TextField: UITextField, ViewProtocol, Errorable {
@@ -46,6 +47,12 @@ open class TextField: UITextField, ViewProtocol, Errorable {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
+ /// TextStyle used on the titleLabel.
+ open var textStyle: TextStyle = .defaultStyle { didSet { setNeedsUpdate() } }
+
+ /// Will determine if a scaled font should be used for the titleLabel font.
+ open var useScaledFont: Bool = false { didSet { setNeedsUpdate() } }
+
/// Key of whether or not updateView() is called in setNeedsUpdate()
open var shouldUpdateView: Bool = true
@@ -55,6 +62,22 @@ open class TextField: UITextField, ViewProtocol, Errorable {
open var errorText: String? { didSet { setNeedsUpdate() } }
+ open var lineBreakMode: NSLineBreakMode = .byClipping { didSet { setNeedsUpdate() } }
+
+ open override var isEnabled: Bool { didSet { setNeedsUpdate() } }
+
+ open var textColorConfiguration: AnyColorable = ViewColorConfiguration().with {
+ $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true)
+ $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false)
+ }.eraseToAnyColorable(){ didSet { setNeedsUpdate() }}
+
+ open override var textColor: UIColor? {
+ get { textColorConfiguration.getColor(self) }
+ set { }
+ }
+
+ override public var text: String! { didSet { setNeedsUpdate() } }
+
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
@@ -63,6 +86,8 @@ open class TextField: UITextField, ViewProtocol, Errorable {
initialSetupPerformed = true
backgroundColor = .clear
translatesAutoresizingMaskIntoConstraints = false
+ setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
+ clipsToBounds = true
setup()
setNeedsUpdate()
}
@@ -84,10 +109,12 @@ open class TextField: UITextField, ViewProtocol, Errorable {
@objc func doneButtonAction() {
// Resigns the first responder status when 'Done' is tapped
- resignFirstResponder()
+ let _ = resignFirstResponder()
}
- open func updateView() {}
+ open func updateView() {
+ updateLabel()
+ }
open func updateAccessibility() {
if let errorText, showError {
@@ -139,6 +166,28 @@ open class TextField: UITextField, ViewProtocol, Errorable {
}
return success
}
+
+ //--------------------------------------------------
+ // MARK: - Private Methods
+ //--------------------------------------------------
+ private func updateLabel() {
+
+ //clear the arrays holding actions
+ accessibilityCustomActions = []
+ if let text, !text.isEmpty {
+ //create the primary string
+ let mutableText = NSMutableAttributedString.mutableText(for: text,
+ textStyle: textStyle,
+ useScaledFont: useScaledFont,
+ textColor: textColor!,
+ alignment: .left,
+ lineBreakMode: lineBreakMode)
+ attributedText = mutableText
+ } else {
+ attributedText = nil
+ }
+ }
+
}
extension UITextField {
diff --git a/VDS/Fonts/Font.swift b/VDS/Fonts/Font.swift
index f4ba798d..6ee9300e 100644
--- a/VDS/Fonts/Font.swift
+++ b/VDS/Fonts/Font.swift
@@ -48,7 +48,7 @@ public enum Font: FontProtocol {
/// - size: Size of the font
/// - Returns: UIFont for the fontName and Size.
public func font(ofSize size: CGFloat) -> UIFont{
- DispatchQueue.once(block: { self.register() })
+ DispatchQueue.once(block: { Self.register() })
switch self {
case .custom(let font):
return font
diff --git a/VDS/Fonts/FontProtocol.swift b/VDS/Fonts/FontProtocol.swift
index df6ac6a3..786436b4 100644
--- a/VDS/Fonts/FontProtocol.swift
+++ b/VDS/Fonts/FontProtocol.swift
@@ -18,7 +18,7 @@ public protocol FontProtocol {
extension FontProtocol {
/// Registers the fonts used in the VDS Framework.
- public func register() {
+ public static func register() {
guard let bundle = Bundle(identifier: "com.vzw.vds") else { return }
Self.allCases.forEach{ font in
if let url = bundle.url(forResource: font.fontName, withExtension: font.fontFileExtension){
@@ -51,7 +51,7 @@ extension FontProtocol {
/// - size: Size of the font
/// - Returns: UIFont for the fontName and Size.
public func font(ofSize size: CGFloat) -> UIFont{
- DispatchQueue.once(block: { self.register() })
+ DispatchQueue.once(block: { Self.register() })
guard let found = UIFont(name: self.fontName, size: size) else { return .systemFont(ofSize: size) }
return found
}
diff --git a/VDS/SupportingFiles/Icons.xcassets/CreditCard/dinersClub-inverted.imageset/Contents.json b/VDS/SupportingFiles/Icons.xcassets/CreditCard/dinersClub-inverted.imageset/Contents.json
index 6c8a6fee..4f70649b 100644
--- a/VDS/SupportingFiles/Icons.xcassets/CreditCard/dinersClub-inverted.imageset/Contents.json
+++ b/VDS/SupportingFiles/Icons.xcassets/CreditCard/dinersClub-inverted.imageset/Contents.json
@@ -1,7 +1,7 @@
{
"images" : [
{
- "filename" : "DCI_Horizontal-2_onlight.svg",
+ "filename" : "DCI_Horizontal-2_ondark-2.svg",
"idiom" : "universal"
}
],
diff --git a/VDS/SupportingFiles/Icons.xcassets/CreditCard/dinersClub-inverted.imageset/DCI_Horizontal-2_ondark-2.svg b/VDS/SupportingFiles/Icons.xcassets/CreditCard/dinersClub-inverted.imageset/DCI_Horizontal-2_ondark-2.svg
new file mode 100644
index 00000000..4d2cd6c6
--- /dev/null
+++ b/VDS/SupportingFiles/Icons.xcassets/CreditCard/dinersClub-inverted.imageset/DCI_Horizontal-2_ondark-2.svg
@@ -0,0 +1,62 @@
+
+
\ No newline at end of file
diff --git a/VDS/SupportingFiles/Icons.xcassets/CreditCard/dinersClub-inverted.imageset/DCI_Horizontal-2_onlight.svg b/VDS/SupportingFiles/Icons.xcassets/CreditCard/dinersClub-inverted.imageset/DCI_Horizontal-2_onlight.svg
deleted file mode 100644
index 569a32c0..00000000
--- a/VDS/SupportingFiles/Icons.xcassets/CreditCard/dinersClub-inverted.imageset/DCI_Horizontal-2_onlight.svg
+++ /dev/null
@@ -1,819 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-]>
-
diff --git a/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic-inverted.imageset/Contents.json b/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic-inverted.imageset/Contents.json
index 28c8b212..ce49c66f 100644
--- a/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic-inverted.imageset/Contents.json
+++ b/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic-inverted.imageset/Contents.json
@@ -1,7 +1,7 @@
{
"images" : [
{
- "filename" : "generic-inverted.svg",
+ "filename" : "generic_inverted.svg",
"idiom" : "universal"
}
],
diff --git a/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic-inverted.imageset/generic-inverted.svg b/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic-inverted.imageset/generic-inverted.svg
deleted file mode 100644
index 42904015..00000000
--- a/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic-inverted.imageset/generic-inverted.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
diff --git a/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic-inverted.imageset/generic_inverted.svg b/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic-inverted.imageset/generic_inverted.svg
new file mode 100644
index 00000000..d7c2ff67
--- /dev/null
+++ b/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic-inverted.imageset/generic_inverted.svg
@@ -0,0 +1,20 @@
+
+
+
diff --git a/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic.imageset/generic.svg b/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic.imageset/generic.svg
index 38b925ee..75bb826b 100644
--- a/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic.imageset/generic.svg
+++ b/VDS/SupportingFiles/Icons.xcassets/CreditCard/generic.imageset/generic.svg
@@ -1,17 +1,19 @@
-