refactored to a generic label/labelbase
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
fd4b9a1b28
commit
64778d7951
@ -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 {
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user