refactored to a generic label/labelbase

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-08-04 15:33:27 -05:00
parent fd4b9a1b28
commit 64778d7951
2 changed files with 14 additions and 3 deletions

View File

@ -10,12 +10,14 @@ import UIKit
import VDSColorTokens
import Combine
open class Label: UILabel, ModelHandlerable, Initable, Resettable {
public class Label:LabelBase<DefaultLabelModel>{}
open class LabelBase<ModelType: LabelModel & Initable>: UILabel, ModelHandlerable, Initable, Resettable {
//--------------------------------------------------
// MARK: - Combine Properties
//--------------------------------------------------
@Published public var model: LabelModel = DefaultLabelModel()
@Published public var model: LabelModel = ModelType()
private var cancellable: AnyCancellable?
//--------------------------------------------------
@ -123,6 +125,15 @@ open class Label: UILabel, ModelHandlerable, Initable, Resettable {
//--------------------------------------------------
// MARK: - Private Functions
//--------------------------------------------------
private var textColorHelper: ModelSingleColorHelper<DefaultLabelModel> = {
let helper = ModelSingleColorHelper<DefaultLabelModel>()
helper.disabled.lightColor = VDSColor.elementsSecondaryOnlight
helper.disabled.darkColor = VDSColor.elementsSecondaryOndark
helper.enabled.lightColor = VDSColor.elementsPrimaryOnlight
helper.enabled.darkColor = VDSColor.elementsPrimaryOndark
return helper
} ()
private func getTextColor(for disabled: Bool, surface: Surface) -> UIColor {
if disabled {
if surface == .light {

View File

@ -10,7 +10,7 @@ import UIKit
extension UITapGestureRecognizer {
public func didTapAttributedTextInLabel(_ label: Label, inRange targetRange: NSRange) -> Bool {
public func didTapAttributedTextInLabel(_ label: UILabel, inRange targetRange: NSRange) -> Bool {
guard let abstractContainer = label.abstractTextContainer() else { return false }
let textContainer = abstractContainer.0