refactored into VDS.Label extension
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
c7d5cac1af
commit
3689b16339
@ -34,11 +34,7 @@ public typealias ActionBlock = () -> ()
|
|||||||
|
|
||||||
/// A specific text index to use as a unique marker.
|
/// A specific text index to use as a unique marker.
|
||||||
public var hero: Int?
|
public var hero: Int?
|
||||||
|
|
||||||
public var getRange: NSRange {
|
|
||||||
NSRange(location: 0, length: text?.count ?? 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
public var shouldMaskWhileRecording: Bool = false
|
public var shouldMaskWhileRecording: Bool = false
|
||||||
|
|
||||||
public var hasText: Bool {
|
public var hasText: Bool {
|
||||||
@ -378,19 +374,24 @@ extension Label {
|
|||||||
|
|
||||||
// MARK: - Atomization
|
// MARK: - Atomization
|
||||||
extension Label {
|
extension Label {
|
||||||
|
|
||||||
public func needsToBeConstrained() -> Bool { true }
|
public func needsToBeConstrained() -> Bool { true }
|
||||||
|
|
||||||
public func horizontalAlignment() -> UIStackView.Alignment { .leading }
|
public func horizontalAlignment() -> UIStackView.Alignment { .leading }
|
||||||
|
|
||||||
public func copyBackgroundColor() -> Bool { true }
|
public func copyBackgroundColor() -> Bool { true }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Multi-Link Functionality
|
// MARK: - Multi-Link Functionality
|
||||||
extension Label {
|
extension VDS.Label {
|
||||||
|
|
||||||
|
public var getRange: NSRange {
|
||||||
|
NSRange(location: 0, length: text?.count ?? 0)
|
||||||
|
}
|
||||||
|
|
||||||
/// Underlines the tappable region and stores the tap logic for interation.
|
/// Underlines the tappable region and stores the tap logic for interation.
|
||||||
private func setTextLinkState(range: NSRange, actionBlock: @escaping ActionBlock) {
|
internal func setTextLinkState(range: NSRange, actionBlock: @escaping ActionBlock) {
|
||||||
guard let text, text.isValid(range: range) else { return }
|
guard let text, text.isValid(range: range) else { return }
|
||||||
|
|
||||||
var textLink = ActionLabelAttribute(location: range.location, length: range.length)
|
var textLink = ActionLabelAttribute(location: range.location, length: range.length)
|
||||||
@ -417,8 +418,16 @@ extension Label {
|
|||||||
return { [weak self] in
|
return { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|
||||||
if (delegateObject as? MVMCoreUIDelegateObject)?.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true {
|
if let button = self as? MFButtonProtocol {
|
||||||
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
|
if (delegateObject as? MVMCoreUIDelegateObject)?.buttonDelegate?.button?(button, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true {
|
||||||
|
MVMCoreActionHandler.shared()?.handleAction(with: actionMap,
|
||||||
|
additionalData: additionalData,
|
||||||
|
delegateObject: delegateObject)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MVMCoreActionHandler.shared()?.handleAction(with: actionMap,
|
||||||
|
additionalData: additionalData,
|
||||||
|
delegateObject: delegateObject)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user