CXTDT-565117 - Input Field - Overflow not clipped
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
772863ff73
commit
0207b70a20
@ -101,7 +101,7 @@ open class InputField: EntryFieldBase {
|
|||||||
/// UITextField shown in the InputField.
|
/// UITextField shown in the InputField.
|
||||||
open var textField = TextField().with {
|
open var textField = TextField().with {
|
||||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
$0.font = TextStyle.bodyLarge.font
|
$0.textStyle = TextStyle.bodyLarge
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color configuration for the textField.
|
/// Color configuration for the textField.
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
|
import VDSTokens
|
||||||
|
|
||||||
@objc(VDSTextField)
|
@objc(VDSTextField)
|
||||||
open class TextField: UITextField, ViewProtocol, Errorable {
|
open class TextField: UITextField, ViewProtocol, Errorable {
|
||||||
@ -46,6 +47,12 @@ open class TextField: UITextField, ViewProtocol, Errorable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// 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()
|
/// Key of whether or not updateView() is called in setNeedsUpdate()
|
||||||
open var shouldUpdateView: Bool = true
|
open var shouldUpdateView: Bool = true
|
||||||
|
|
||||||
@ -55,6 +62,22 @@ open class TextField: UITextField, ViewProtocol, Errorable {
|
|||||||
|
|
||||||
open var errorText: String? { didSet { setNeedsUpdate() } }
|
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
|
// MARK: - Lifecycle
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -63,6 +86,8 @@ open class TextField: UITextField, ViewProtocol, Errorable {
|
|||||||
initialSetupPerformed = true
|
initialSetupPerformed = true
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
translatesAutoresizingMaskIntoConstraints = false
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
||||||
|
clipsToBounds = true
|
||||||
setup()
|
setup()
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
@ -84,10 +109,12 @@ open class TextField: UITextField, ViewProtocol, Errorable {
|
|||||||
|
|
||||||
@objc func doneButtonAction() {
|
@objc func doneButtonAction() {
|
||||||
// Resigns the first responder status when 'Done' is tapped
|
// Resigns the first responder status when 'Done' is tapped
|
||||||
resignFirstResponder()
|
let _ = resignFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
open func updateView() {}
|
open func updateView() {
|
||||||
|
updateLabel()
|
||||||
|
}
|
||||||
|
|
||||||
open func updateAccessibility() {
|
open func updateAccessibility() {
|
||||||
if let errorText, showError {
|
if let errorText, showError {
|
||||||
@ -139,6 +166,28 @@ open class TextField: UITextField, ViewProtocol, Errorable {
|
|||||||
}
|
}
|
||||||
return success
|
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 {
|
extension UITextField {
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
----------------
|
----------------
|
||||||
- CXTDT-565087 - Input Field - Text - OnDark colors
|
- CXTDT-565087 - Input Field - Text - OnDark colors
|
||||||
- CXTDT-565112 - Input Field - Credit Card icons
|
- CXTDT-565112 - Input Field - Credit Card icons
|
||||||
|
- CXTDT-565117 - Input Field - Overflow not clipped
|
||||||
|
|
||||||
1.0.65
|
1.0.65
|
||||||
----------------
|
----------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user