From 85f6722d4cf8102d7ec9ee06e1dc88bc9a43e778 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 17 Aug 2022 07:59:31 -0500 Subject: [PATCH] updated action to combine Signed-off-by: Matt Bruce --- .../Label/Attributes/LabelAttributeAction.swift | 8 ++++---- VDS/Components/Label/Label.swift | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/VDS/Components/Label/Attributes/LabelAttributeAction.swift b/VDS/Components/Label/Attributes/LabelAttributeAction.swift index da3e19fa..b9b77e5a 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeAction.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeAction.swift @@ -7,9 +7,10 @@ import Foundation import UIKit +import Combine public protocol LabelAttributeActionable: LabelAttributeModel { - var action: Blocks.ActionBlock { get set } + var action: PassthroughSubject { get set } } public struct LabelAttributeActionModel: LabelAttributeActionable { @@ -19,16 +20,15 @@ public struct LabelAttributeActionModel: LabelAttributeActionable { //-------------------------------------------------- public var location: Int public var length: Int - public var action: Blocks.ActionBlock = {} + public var action = PassthroughSubject() //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(location: Int, length: Int, action: @escaping Blocks.ActionBlock) { + public init(location: Int, length: Int) { self.location = location self.length = length - self.action = action } private enum CodingKeys: String, CodingKey { diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 53eaef6a..cb08b7a9 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -29,7 +29,7 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProt @Proxy(\.model.disabled) open var disabled: Bool - + @Proxy(\.model.attributes) open var attributes: [LabelAttributeModel]? @@ -163,7 +163,7 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProt } } } - + //only enabled if enabled and has actions isUserInteractionEnabled = !viewModel.disabled && !actions.isEmpty @@ -213,14 +213,14 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProt private struct LabelAction { var range: NSRange - var actionBlock: Blocks.ActionBlock + var actionBlock: PassthroughSubject var accessibilityId: Int = 0 func performAction() { - actionBlock() + actionBlock.send() } - init(range: NSRange, actionBlock: @escaping Blocks.ActionBlock, accessibilityID: Int = 0) { + init(range: NSRange, actionBlock: PassthroughSubject, accessibilityID: Int = 0) { self.range = range self.actionBlock = actionBlock self.accessibilityId = accessibilityID