From 64778d7951ffeaff7bcd17afaec8d2fffc0f6254 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 4 Aug 2022 15:33:27 -0500 Subject: [PATCH] refactored to a generic label/labelbase Signed-off-by: Matt Bruce --- VDS/Components/Label/Label.swift | 15 +++++++++++++-- VDS/Extensions/UITapGestureRecognizer.swift | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index c4405146..5c93cfdb 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -10,12 +10,14 @@ import UIKit import VDSColorTokens import Combine -open class Label: UILabel, ModelHandlerable, Initable, Resettable { +public class Label:LabelBase{} + +open class LabelBase: 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 = { + let helper = ModelSingleColorHelper() + 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 { diff --git a/VDS/Extensions/UITapGestureRecognizer.swift b/VDS/Extensions/UITapGestureRecognizer.swift index 8cdf8d08..cf4121ba 100644 --- a/VDS/Extensions/UITapGestureRecognizer.swift +++ b/VDS/Extensions/UITapGestureRecognizer.swift @@ -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