From a72f3cc3c1542a2d0fb2d2994b0f32d50d1309f9 Mon Sep 17 00:00:00 2001 From: Nandhini Rajendran Date: Fri, 9 Dec 2022 12:34:06 +0530 Subject: [PATCH] refactor to add resetAttributeStyle --- .../Atomic/Atoms/Views/Label/Label.swift | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 225d39c1..059c5637 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -241,18 +241,7 @@ public typealias ActionBlock = () -> () case left } - public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject? = nil, _ additionalData: [AnyHashable: Any]? = nil) { - - clauses = [] - text = nil - attributedText = nil - originalAttributedString = nil - shouldMaskWhileRecording = model.shouldMaskRecordedView ?? false - - guard let labelModel = model as? LabelModel else { return } - - text = labelModel.text - + @objc public func resetAttributeStyle() { /* * 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, @@ -274,6 +263,21 @@ public typealias ActionBlock = () -> () self.attributedText = attributedString } + } + + public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject? = nil, _ additionalData: [AnyHashable: Any]? = nil) { + + clauses = [] + text = nil + attributedText = nil + originalAttributedString = nil + shouldMaskWhileRecording = model.shouldMaskRecordedView ?? false + + guard let labelModel = model as? LabelModel else { return } + + text = labelModel.text + + resetAttributeStyle() hero = labelModel.hero Label.setLabel(self, withHTML: labelModel.html) @@ -786,10 +790,8 @@ public typealias ActionBlock = () -> () extension Label { public func reset() { - //Weird issue. when cell reuse. text style is not getting reset.Fix for:CXTDT-344190 - //We need to reset the attribute text first and then text. Its working fine - attributedText = nil text = nil + attributedText = nil hero = nil textAlignment = .left originalAttributedString = nil