latest state

This commit is contained in:
Kevin G Christiano 2020-10-01 12:15:45 -04:00
parent 592e0a9591
commit 0ba5da2add

View File

@ -252,6 +252,8 @@ public typealias ActionBlock = () -> ()
originalAttributedString = nil
text = labelModel.text
print("SET before:\n \(attributedText)")
/*
* This is to address a reuse issue with iOS 13 and up.
* Even if you set text & attributedText to nil, the moment you set text with a value,
@ -261,13 +263,23 @@ public typealias ActionBlock = () -> ()
*/
if #available(iOS 13, *) {
// Case where no attributes are set in the model but attributedText has a value.
if attributedText != nil, let text = text {
if let attributedText = attributedText, let text = text {
let attributedString = NSMutableAttributedString(string: text)
attributedString.addAttribute(.underlineStyle, value: 0, range: NSRange(location: 0, length: text.count))
attributedText = attributedString
for attributes in attributedText.attributes(at: 0, effectiveRange: nil) {
if attributes.key == .underlineStyle {
attributedString.addAttribute(.underlineStyle, value: 0, range: NSRange(location: 0, length: text.count))
}
if attributes.key == .strikethroughStyle {
attributedString.addAttribute(.strikethroughStyle, value: 0, range: NSRange(location: 0, length: text.count))
}
}
self.attributedText = attributedString
}
}
print("SET after:\n \(attributedText)")
hero = labelModel.hero
Label.setLabel(self, withHTML: labelModel.html)
isAccessibilityElement = hasText
@ -382,7 +394,9 @@ public typealias ActionBlock = () -> ()
attributedText = attributedString
originalAttributedString = attributedText
print("SET new attribute:\n \(attributedText)")
}
print("SET DONE FUNC:\n \(attributedText)")
}
@objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {
@ -773,6 +787,7 @@ extension Label {
public func reset() {
text = nil
attributedText = nil
print("reset:\n \(attributedText)")
hero = nil
textAlignment = .left
originalAttributedString = nil