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 VDSColorTokens
|
||||||
import Combine
|
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
|
// MARK: - Combine Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@Published public var model: LabelModel = DefaultLabelModel()
|
@Published public var model: LabelModel = ModelType()
|
||||||
private var cancellable: AnyCancellable?
|
private var cancellable: AnyCancellable?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -123,6 +125,15 @@ open class Label: UILabel, ModelHandlerable, Initable, Resettable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Functions
|
// 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 {
|
private func getTextColor(for disabled: Bool, surface: Surface) -> UIColor {
|
||||||
if disabled {
|
if disabled {
|
||||||
if surface == .light {
|
if surface == .light {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import UIKit
|
|||||||
|
|
||||||
extension UITapGestureRecognizer {
|
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 }
|
guard let abstractContainer = label.abstractTextContainer() else { return false }
|
||||||
let textContainer = abstractContainer.0
|
let textContainer = abstractContainer.0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user