refactored label text
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
15c173d998
commit
0ace568f7d
@ -50,10 +50,26 @@ open class VDSLabel: UILabel, Modelable {
|
||||
}
|
||||
}
|
||||
|
||||
private func getTextColor(for disabled: Bool, surface: Surface) -> UIColor {
|
||||
if disabled {
|
||||
if surface == .light {
|
||||
return VDSColor.elementsSecondaryOnlight
|
||||
} else {
|
||||
return VDSColor.elementsSecondaryOndark
|
||||
}
|
||||
} else {
|
||||
if surface == .light {
|
||||
return VDSColor.elementsPrimaryOnlight
|
||||
} else {
|
||||
return VDSColor.elementsPrimaryOndark
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//functions
|
||||
private func onStateChange(viewModel: VDSLabelModel) {
|
||||
textAlignment = viewModel.textPosition.textAlignment
|
||||
textColor = viewModel.surface == .dark ? VDSColor.elementsPrimaryOndark : VDSColor.elementsPrimaryOnlight
|
||||
textColor = getTextColor(for: viewModel.disabled, surface: viewModel.surface)
|
||||
|
||||
guard let vdsFont = try? VDSFontStyle.font(for: viewModel.fontCategory, fontWeight: viewModel.fontWeight, fontSize: viewModel.fontSize) else {
|
||||
font = VDSFontStyle.RegularBodyLarge.font
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
public protocol VDSLabelModel: Labelable, Surfaceable {
|
||||
public protocol VDSLabelModel: Labelable, Surfaceable, Disabling {
|
||||
}
|
||||
|
||||
open class DefaultLabelModel: VDSLabelModel {
|
||||
@ -17,5 +17,6 @@ open class DefaultLabelModel: VDSLabelModel {
|
||||
public var fontWeight: VDSFontWeight = .regular
|
||||
public var textPosition: VDSTextPosition = .left
|
||||
public var surface: Surface = .light
|
||||
public var disabled: Bool = false
|
||||
required public init(){}
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ extension VDSToggle {
|
||||
}
|
||||
}
|
||||
|
||||
public protocol VDSToggleModel: VDSLabelModel, FormFieldable, DataTrackable, Disabling, Accessable {
|
||||
public protocol VDSToggleModel: VDSLabelModel, FormFieldable, DataTrackable, Accessable {
|
||||
var id: String? { get set }
|
||||
var showText: Bool { get set }
|
||||
var on: Bool { get set }
|
||||
@ -32,7 +32,6 @@ extension VDSToggleModel {
|
||||
public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
|
||||
public var id: String?
|
||||
public var inputId: String?
|
||||
public var disabled: Bool = false
|
||||
public var showText: Bool = false
|
||||
public var on: Bool = false
|
||||
public var offText: String = "Off"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user