updated action to combine
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
cade12b0cd
commit
85f6722d4c
@ -7,9 +7,10 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import Combine
|
||||||
|
|
||||||
public protocol LabelAttributeActionable: LabelAttributeModel {
|
public protocol LabelAttributeActionable: LabelAttributeModel {
|
||||||
var action: Blocks.ActionBlock { get set }
|
var action: PassthroughSubject<Void, Never> { get set }
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct LabelAttributeActionModel: LabelAttributeActionable {
|
public struct LabelAttributeActionModel: LabelAttributeActionable {
|
||||||
@ -19,16 +20,15 @@ public struct LabelAttributeActionModel: LabelAttributeActionable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
public var location: Int
|
public var location: Int
|
||||||
public var length: Int
|
public var length: Int
|
||||||
public var action: Blocks.ActionBlock = {}
|
public var action = PassthroughSubject<Void, Never>()
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public init(location: Int, length: Int, action: @escaping Blocks.ActionBlock) {
|
public init(location: Int, length: Int) {
|
||||||
self.location = location
|
self.location = location
|
||||||
self.length = length
|
self.length = length
|
||||||
self.action = action
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
|||||||
@ -29,7 +29,7 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProt
|
|||||||
|
|
||||||
@Proxy(\.model.disabled)
|
@Proxy(\.model.disabled)
|
||||||
open var disabled: Bool
|
open var disabled: Bool
|
||||||
|
|
||||||
@Proxy(\.model.attributes)
|
@Proxy(\.model.attributes)
|
||||||
open var attributes: [LabelAttributeModel]?
|
open var attributes: [LabelAttributeModel]?
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//only enabled if enabled and has actions
|
//only enabled if enabled and has actions
|
||||||
isUserInteractionEnabled = !viewModel.disabled && !actions.isEmpty
|
isUserInteractionEnabled = !viewModel.disabled && !actions.isEmpty
|
||||||
|
|
||||||
@ -213,14 +213,14 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProt
|
|||||||
|
|
||||||
private struct LabelAction {
|
private struct LabelAction {
|
||||||
var range: NSRange
|
var range: NSRange
|
||||||
var actionBlock: Blocks.ActionBlock
|
var actionBlock: PassthroughSubject<Void, Never>
|
||||||
var accessibilityId: Int = 0
|
var accessibilityId: Int = 0
|
||||||
|
|
||||||
func performAction() {
|
func performAction() {
|
||||||
actionBlock()
|
actionBlock.send()
|
||||||
}
|
}
|
||||||
|
|
||||||
init(range: NSRange, actionBlock: @escaping Blocks.ActionBlock, accessibilityID: Int = 0) {
|
init(range: NSRange, actionBlock: PassthroughSubject<Void, Never>, accessibilityID: Int = 0) {
|
||||||
self.range = range
|
self.range = range
|
||||||
self.actionBlock = actionBlock
|
self.actionBlock = actionBlock
|
||||||
self.accessibilityId = accessibilityID
|
self.accessibilityId = accessibilityID
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user