updated documentation
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
08fd42fcb9
commit
ba9e5f912f
@ -42,6 +42,8 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private var initialSetupPerformed = false
|
private var initialSetupPerformed = false
|
||||||
|
|
||||||
|
private var edgeInsets: UIEdgeInsets { textStyle.edgeInsets }
|
||||||
|
|
||||||
private var tapGesture: UITapGestureRecognizer? {
|
private var tapGesture: UITapGestureRecognizer? {
|
||||||
willSet {
|
willSet {
|
||||||
if let tapGesture = tapGesture, newValue == nil {
|
if let tapGesture = tapGesture, newValue == nil {
|
||||||
@ -99,11 +101,13 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
/// 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
|
||||||
|
|
||||||
|
/// Determines if the label should use its own attributedText property instead of rendering the attributedText propert
|
||||||
|
/// based of other local properties, such as textStyle, textColor, surface, etc... The default value is false.
|
||||||
open var useAttributedText: Bool = false
|
open var useAttributedText: Bool = false
|
||||||
|
|
||||||
|
/// Will determine if a scaled font should be used for the font.
|
||||||
open var useScaledFont: Bool = false { didSet { setNeedsUpdate() }}
|
open var useScaledFont: Bool = false { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
/// Current Surface and this is used to pass down to child objects that implement Surfacable
|
|
||||||
open var surface: Surface = .light { didSet { setNeedsUpdate() }}
|
open var surface: Surface = .light { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
/// Array of LabelAttributeModel objects used in rendering the text.
|
/// Array of LabelAttributeModel objects used in rendering the text.
|
||||||
@ -112,18 +116,21 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
/// TextStyle used on the this label.
|
/// TextStyle used on the this label.
|
||||||
open var textStyle: TextStyle = .defaultStyle { didSet { setNeedsUpdate() }}
|
open var textStyle: TextStyle = .defaultStyle { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
open var edgeInsets: UIEdgeInsets { textStyle.edgeInsets }
|
/// The alignment of the text within the label.
|
||||||
|
|
||||||
open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }}
|
open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
open var userInfo = [String: Primitive]()
|
open var userInfo = [String: Primitive]()
|
||||||
|
|
||||||
|
/// Number of lines the label can render out, default is set to 0.
|
||||||
open override var numberOfLines: Int { didSet { setNeedsUpdate() }}
|
open override var numberOfLines: Int { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
/// Line break mode for the label, default is set to word wrapping.
|
||||||
open override var lineBreakMode: NSLineBreakMode { didSet { setNeedsUpdate() }}
|
open override var lineBreakMode: NSLineBreakMode { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
/// Text that will be used in the label.
|
||||||
override open var text: String? {
|
override open var text: String? {
|
||||||
didSet {
|
didSet {
|
||||||
|
useAttributedText = false
|
||||||
attributes = nil
|
attributes = nil
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
@ -135,6 +142,8 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration Properties
|
// MARK: - Configuration Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
/// Color configuration use for text color. This is a configuration that will provide a color based
|
||||||
|
/// of local properties such as surface and isEnabled.
|
||||||
open var textColorConfiguration: AnyColorable = ViewColorConfiguration().with {
|
open var textColorConfiguration: AnyColorable = ViewColorConfiguration().with {
|
||||||
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true)
|
$0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true)
|
||||||
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false)
|
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false)
|
||||||
@ -180,7 +189,6 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used to make changes to the View based off a change events or from local properties.
|
|
||||||
open func updateView() {
|
open func updateView() {
|
||||||
if !useAttributedText {
|
if !useAttributedText {
|
||||||
if let text = text {
|
if let text = text {
|
||||||
@ -215,15 +223,18 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Overrides
|
// MARK: - Overrides
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
/// We are drawing using edgeInsets based off the textStyle.
|
||||||
open override func drawText(in rect: CGRect) {
|
open override func drawText(in rect: CGRect) {
|
||||||
super.drawText(in: rect.inset(by: edgeInsets))
|
super.drawText(in: rect.inset(by: edgeInsets))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// We are applying action attributes after the views layout to ensure correct positioning of the text.
|
||||||
open override func layoutSubviews() {
|
open override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
applyActions()
|
applyActions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Addig custom accessibillty actions from the collection of attributes.
|
||||||
open override func accessibilityActivate() -> Bool {
|
open override func accessibilityActivate() -> Bool {
|
||||||
|
|
||||||
guard let accessibleActions = accessibilityCustomActions else { return false }
|
guard let accessibleActions = accessibilityCustomActions else { return false }
|
||||||
|
|||||||
@ -30,10 +30,12 @@ open class Line: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Enums
|
// MARK: - Enums
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
/// Style of the line that will be displayed.
|
||||||
public enum Style: String, CaseIterable {
|
public enum Style: String, CaseIterable {
|
||||||
case primary, secondary
|
case primary, secondary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Orientation that will be displayed.
|
||||||
public enum Orientation: String, CaseIterable {
|
public enum Orientation: String, CaseIterable {
|
||||||
case horizontal, vertical
|
case horizontal, vertical
|
||||||
}
|
}
|
||||||
@ -41,8 +43,10 @@ open class Line: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
/// Style of the line that will be displayed.
|
||||||
open var style: Style = .primary { didSet { setNeedsUpdate() } }
|
open var style: Style = .primary { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
|
/// Allows to render the line vertically.
|
||||||
open var orientation: Orientation = .horizontal { didSet { setNeedsUpdate() } }
|
open var orientation: Orientation = .horizontal { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// The natural size for the receiving view, considering only properties of the view itself.
|
/// The natural size for the receiving view, considering only properties of the view itself.
|
||||||
@ -57,6 +61,8 @@ open class Line: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
/// Color configuration use for text color. This is a configuration that will provide a color based
|
||||||
|
/// of local properties such as style and surface.
|
||||||
open var lineViewColorConfiguration: AnyColorable = {
|
open var lineViewColorConfiguration: AnyColorable = {
|
||||||
let config = KeyedColorConfiguration<Line, Style>(keyPath: \.style)
|
let config = KeyedColorConfiguration<Line, Style>(keyPath: \.style)
|
||||||
config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forKey: .primary)
|
config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forKey: .primary)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user