- Fix: CollapsingMarkdownView was not reloading properly during layoutSubviews phase

This commit is contained in:
mahee96
2025-02-28 02:28:34 +05:30
parent cfaf79f878
commit 2197161d55
3 changed files with 12 additions and 19 deletions

View File

@@ -64,14 +64,12 @@ final class CollapsingMarkdownView: UIView {
var text: String = "" {
didSet {
self.updateMarkdownContent()
self.shouldResetLayout = true
self.setNeedsLayout()
}
}
var lineSpacing: Double = 2 {
didSet {
self.shouldResetLayout = true
self.setNeedsLayout()
}
}
@@ -81,7 +79,6 @@ final class CollapsingMarkdownView: UIView {
private let textView = UITextView()
private let markdownParser = MarkdownManager().markdownParser
private var shouldResetLayout: Bool = false
private var previousSize: CGSize?
// MARK: - Initialization
@@ -212,9 +209,8 @@ final class CollapsingMarkdownView: UIView {
textView.frame = bounds
// Check if content needs collapsing when layout changes
if shouldResetLayout || previousSize?.width != bounds.width {
if previousSize?.width != bounds.width {
checkIfNeedsCollapsing()
shouldResetLayout = false
previousSize = bounds.size
}