mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +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.versionDescriptionTextView.toggleButton.addTarget(self, action: #selector(MyAppsViewController.toggleUpdateCellMode(_:)), for: .primaryActionTriggered)
|
||||||
|
|
||||||
cell.setNeedsLayout()
|
cell.setNeedsLayout()
|
||||||
|
|
||||||
// Below lines are necessary to avoid "more" button layout issues.
|
|
||||||
cell.versionDescriptionTextView.setNeedsLayout()
|
|
||||||
cell.layoutIfNeeded()
|
cell.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
dataSource.prefetchHandler = { (installedApp, indexPath, completionHandler) in
|
dataSource.prefetchHandler = { (installedApp, indexPath, completionHandler) in
|
||||||
|
|||||||
@@ -92,16 +92,16 @@ extension UpdateCollectionViewCell
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize
|
// override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize
|
||||||
{
|
// {
|
||||||
// Ensure cell is laid out so it will report correct size.
|
// // Ensure cell is laid out so it will report correct size.
|
||||||
self.versionDescriptionTextView.setNeedsLayout()
|
// self.versionDescriptionTextView.setNeedsLayout()
|
||||||
self.versionDescriptionTextView.layoutIfNeeded()
|
// self.versionDescriptionTextView.layoutIfNeeded()
|
||||||
|
//
|
||||||
let size = super.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: horizontalFittingPriority, verticalFittingPriority: verticalFittingPriority)
|
// let size = super.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: horizontalFittingPriority, verticalFittingPriority: verticalFittingPriority)
|
||||||
|
//
|
||||||
return size
|
// return size
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension UpdateCollectionViewCell
|
private extension UpdateCollectionViewCell
|
||||||
|
|||||||
@@ -64,14 +64,12 @@ final class CollapsingMarkdownView: UIView {
|
|||||||
var text: String = "" {
|
var text: String = "" {
|
||||||
didSet {
|
didSet {
|
||||||
self.updateMarkdownContent()
|
self.updateMarkdownContent()
|
||||||
self.shouldResetLayout = true
|
|
||||||
self.setNeedsLayout()
|
self.setNeedsLayout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var lineSpacing: Double = 2 {
|
var lineSpacing: Double = 2 {
|
||||||
didSet {
|
didSet {
|
||||||
self.shouldResetLayout = true
|
|
||||||
self.setNeedsLayout()
|
self.setNeedsLayout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +79,6 @@ final class CollapsingMarkdownView: UIView {
|
|||||||
private let textView = UITextView()
|
private let textView = UITextView()
|
||||||
private let markdownParser = MarkdownManager().markdownParser
|
private let markdownParser = MarkdownManager().markdownParser
|
||||||
|
|
||||||
private var shouldResetLayout: Bool = false
|
|
||||||
private var previousSize: CGSize?
|
private var previousSize: CGSize?
|
||||||
|
|
||||||
// MARK: - Initialization
|
// MARK: - Initialization
|
||||||
@@ -212,9 +209,8 @@ final class CollapsingMarkdownView: UIView {
|
|||||||
textView.frame = bounds
|
textView.frame = bounds
|
||||||
|
|
||||||
// Check if content needs collapsing when layout changes
|
// Check if content needs collapsing when layout changes
|
||||||
if shouldResetLayout || previousSize?.width != bounds.width {
|
if previousSize?.width != bounds.width {
|
||||||
checkIfNeedsCollapsing()
|
checkIfNeedsCollapsing()
|
||||||
shouldResetLayout = false
|
|
||||||
previousSize = bounds.size
|
previousSize = bounds.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user