requested changes.

This commit is contained in:
Christiano, Kevin 2019-05-07 09:36:10 -04:00
parent d83cc8f8ae
commit dadfc83744

View File

@ -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,7 +268,7 @@ public typealias ActionBlock = () -> Void
let subStringRange = Range(NSRange(location: actionLocation, length: actionLength), in: text)
else { continue }
label.clauses.append(ActionableClause(location: actionLocation,
actionLabel.clauses.append(ActionableClause(location: actionLocation,
length: actionLength,
actionText: String(text[subStringRange]),
actionBlock: { [weak delegate] in
@ -274,7 +276,7 @@ public typealias ActionBlock = () -> Void
if let buttonDelegate = (delegate as? MVMCoreUIDelegateObject)?.buttonDelegate,
buttonDelegate.responds(to: #selector(ButtonObjectDelegate.button(_:shouldPerformActionWithMap:additionalData:))) {
willPerform = buttonDelegate.button?(label, shouldPerformActionWithMap: json, additionalData: additionalData) ?? false
willPerform = buttonDelegate.button?(actionLabel, shouldPerformActionWithMap: json, additionalData: additionalData) ?? false
}
if willPerform {