requested changes.
This commit is contained in:
parent
d83cc8f8ae
commit
dadfc83744
@ -166,9 +166,9 @@ public typealias ActionBlock = () -> Void
|
||||
|
||||
- Parameters:
|
||||
- label: The label to be set.
|
||||
- html: The url link to be applied as an attributed link.
|
||||
- html: any html string.
|
||||
*/
|
||||
@objc public static func setLabel(_ label: UILabel?, with html: String?) {
|
||||
@objc public static func setLabel(_ label: UILabel?, withHTML html: String?) {
|
||||
|
||||
guard let data = html?.data(using: .utf8) else { return }
|
||||
|
||||
@ -195,11 +195,11 @@ public typealias ActionBlock = () -> Void
|
||||
*/
|
||||
@objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
|
||||
guard let label = label as? Label else { return }
|
||||
guard let label = label else { return }
|
||||
|
||||
label.text = json?.optionalStringForKey(KeyText)
|
||||
|
||||
setLabel(label, with: json?.optionalStringForKey("html"))
|
||||
setLabel(label, withHTML: json?.optionalStringForKey("html"))
|
||||
|
||||
if let textColorHex = json?.optionalStringForKey(KeyTextColor), !textColorHex.isEmpty {
|
||||
label.textColor = UIColor.mfGet(forHex: textColorHex)
|
||||
@ -257,8 +257,10 @@ public typealias ActionBlock = () -> Void
|
||||
attributedString.addAttribute(.font, value: font, range: range)
|
||||
}
|
||||
case "actions":
|
||||
let actions = attribute.arrayForKey("actions")
|
||||
guard let text = json?.optionalStringForKey(KeyText) else { continue }
|
||||
guard let actionLabel = label as? Label,
|
||||
let text = actionLabel.text,
|
||||
let actions = attribute.optionalArrayForKey("actions")
|
||||
else { continue }
|
||||
|
||||
for case let action as [String: Any] in actions {
|
||||
guard let actionLocation = action["location"] as? Int,
|
||||
@ -266,20 +268,20 @@ public typealias ActionBlock = () -> Void
|
||||
let subStringRange = Range(NSRange(location: actionLocation, length: actionLength), in: text)
|
||||
else { continue }
|
||||
|
||||
label.clauses.append(ActionableClause(location: actionLocation,
|
||||
length: actionLength,
|
||||
actionText: String(text[subStringRange]),
|
||||
actionBlock: { [weak delegate] in
|
||||
var willPerform = true
|
||||
|
||||
if let buttonDelegate = (delegate as? MVMCoreUIDelegateObject)?.buttonDelegate,
|
||||
buttonDelegate.responds(to: #selector(ButtonObjectDelegate.button(_:shouldPerformActionWithMap:additionalData:))) {
|
||||
willPerform = buttonDelegate.button?(label, shouldPerformActionWithMap: json, additionalData: additionalData) ?? false
|
||||
}
|
||||
|
||||
if willPerform {
|
||||
MVMCoreActionHandler.shared()?.handleAction(with: json, additionalData: additionalData, delegateObject: delegate)
|
||||
} }))
|
||||
actionLabel.clauses.append(ActionableClause(location: actionLocation,
|
||||
length: actionLength,
|
||||
actionText: String(text[subStringRange]),
|
||||
actionBlock: { [weak delegate] in
|
||||
var willPerform = true
|
||||
|
||||
if let buttonDelegate = (delegate as? MVMCoreUIDelegateObject)?.buttonDelegate,
|
||||
buttonDelegate.responds(to: #selector(ButtonObjectDelegate.button(_:shouldPerformActionWithMap:additionalData:))) {
|
||||
willPerform = buttonDelegate.button?(actionLabel, shouldPerformActionWithMap: json, additionalData: additionalData) ?? false
|
||||
}
|
||||
|
||||
if willPerform {
|
||||
MVMCoreActionHandler.shared()?.handleAction(with: json, additionalData: additionalData, delegateObject: delegate)
|
||||
} }))
|
||||
}
|
||||
default:
|
||||
continue
|
||||
@ -391,8 +393,8 @@ extension Label {
|
||||
|
||||
- Attention: This method expects text to be set first. Otherwise, it will do nothing.
|
||||
- Parameters:
|
||||
- range: The range of text to be tapped.
|
||||
- actionBlock: The code triggered when tapping the range of text.
|
||||
- range: The range of text to be tapped.
|
||||
- actionBlock: The code triggered when tapping the range of text.
|
||||
*/
|
||||
@objc public func addTappableLinkAttribute(range: NSRange, actionBlock: @escaping ActionBlock) {
|
||||
|
||||
@ -411,10 +413,10 @@ extension Label {
|
||||
|
||||
- Attention: This method expects text to be set first. Otherwise, it will do nothing.
|
||||
- Parameters:
|
||||
- range: The range of text to be tapped.
|
||||
- actionMap:
|
||||
- delegate:
|
||||
- additionalData:
|
||||
- range: The range of text to be tapped.
|
||||
- actionMap:
|
||||
- delegate:
|
||||
- additionalData:
|
||||
*/
|
||||
@objc public func addTappableLinkAttribute(range: NSRange, actionMap: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
|
||||
@ -445,8 +447,8 @@ extension Label {
|
||||
|
||||
- Attention: This method expects text to be set first. Otherwise, it will do nothing. Do not use if actionText is not unique in the Label's text.
|
||||
- Parameters:
|
||||
- actionText: The actionable text contained witin the label's text.
|
||||
- actionBlock: The code triggered when tapping the range of text.
|
||||
- actionText: The actionable text contained witin the label's text.
|
||||
- actionBlock: The code triggered when tapping the range of text.
|
||||
*/
|
||||
@objc public func addTappableLinkAttribute(actionText: String, actionBlock: @escaping ActionBlock) {
|
||||
|
||||
@ -465,10 +467,10 @@ extension Label {
|
||||
|
||||
- Attention: This method expects text to be set first. Otherwise, it will do nothing. Do not use if actionText is not unique in the Label's text.
|
||||
- Parameters:
|
||||
- actionText: The actionable text contained witin the label's text.
|
||||
- actionMap:
|
||||
- delegate:
|
||||
- additionalData:
|
||||
- actionText: The actionable text contained witin the label's text.
|
||||
- actionMap:
|
||||
- delegate:
|
||||
- additionalData:
|
||||
*/
|
||||
@objc public func addTappableLinkAttribute(actionText: String, actionMap: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user