refactored label text

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-08-01 15:42:50 -05:00
parent 15c173d998
commit 0ace568f7d
3 changed files with 20 additions and 4 deletions

View File

@ -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 //functions
private func onStateChange(viewModel: VDSLabelModel) { private func onStateChange(viewModel: VDSLabelModel) {
textAlignment = viewModel.textPosition.textAlignment 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 { guard let vdsFont = try? VDSFontStyle.font(for: viewModel.fontCategory, fontWeight: viewModel.fontWeight, fontSize: viewModel.fontSize) else {
font = VDSFontStyle.RegularBodyLarge.font font = VDSFontStyle.RegularBodyLarge.font

View File

@ -8,7 +8,7 @@
import Foundation import Foundation
import UIKit import UIKit
public protocol VDSLabelModel: Labelable, Surfaceable { public protocol VDSLabelModel: Labelable, Surfaceable, Disabling {
} }
open class DefaultLabelModel: VDSLabelModel { open class DefaultLabelModel: VDSLabelModel {
@ -17,5 +17,6 @@ open class DefaultLabelModel: VDSLabelModel {
public var fontWeight: VDSFontWeight = .regular public var fontWeight: VDSFontWeight = .regular
public var textPosition: VDSTextPosition = .left public var textPosition: VDSTextPosition = .left
public var surface: Surface = .light public var surface: Surface = .light
public var disabled: Bool = false
required public init(){} required public init(){}
} }

View File

@ -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 id: String? { get set }
var showText: Bool { get set } var showText: Bool { get set }
var on: Bool { get set } var on: Bool { get set }
@ -32,7 +32,6 @@ extension VDSToggleModel {
public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel { public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
public var id: String? public var id: String?
public var inputId: String? public var inputId: String?
public var disabled: Bool = false
public var showText: Bool = false public var showText: Bool = false
public var on: Bool = false public var on: Bool = false
public var offText: String = "Off" public var offText: String = "Off"