mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-08 22:33:26 +01:00
- Fix: CollapsingMarkdownView was not reloading properly during layoutSubviews phase
This commit is contained in:
@@ -282,11 +282,8 @@ private extension MyAppsViewController
|
||||
}
|
||||
|
||||
cell.versionDescriptionTextView.toggleButton.addTarget(self, action: #selector(MyAppsViewController.toggleUpdateCellMode(_:)), for: .primaryActionTriggered)
|
||||
|
||||
|
||||
cell.setNeedsLayout()
|
||||
|
||||
// Below lines are necessary to avoid "more" button layout issues.
|
||||
cell.versionDescriptionTextView.setNeedsLayout()
|
||||
cell.layoutIfNeeded()
|
||||
}
|
||||
dataSource.prefetchHandler = { (installedApp, indexPath, completionHandler) in
|
||||
|
||||
@@ -92,16 +92,16 @@ extension UpdateCollectionViewCell
|
||||
}
|
||||
}
|
||||
|
||||
override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize
|
||||
{
|
||||
// Ensure cell is laid out so it will report correct size.
|
||||
self.versionDescriptionTextView.setNeedsLayout()
|
||||
self.versionDescriptionTextView.layoutIfNeeded()
|
||||
|
||||
let size = super.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: horizontalFittingPriority, verticalFittingPriority: verticalFittingPriority)
|
||||
|
||||
return size
|
||||
}
|
||||
// override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize
|
||||
// {
|
||||
// // Ensure cell is laid out so it will report correct size.
|
||||
// self.versionDescriptionTextView.setNeedsLayout()
|
||||
// self.versionDescriptionTextView.layoutIfNeeded()
|
||||
//
|
||||
// let size = super.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: horizontalFittingPriority, verticalFittingPriority: verticalFittingPriority)
|
||||
//
|
||||
// return size
|
||||
// }
|
||||
}
|
||||
|
||||
private extension UpdateCollectionViewCell
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user