mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-21 04:33:30 +01:00
Fixes AppViewController scrolling performance for apps with several privacy permissions
This commit is contained in:
@@ -12,18 +12,23 @@ final class CollapsingTextView: UITextView
|
||||
{
|
||||
var isCollapsed = true {
|
||||
didSet {
|
||||
guard self.isCollapsed != oldValue else { return }
|
||||
self.shouldResetLayout = true
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
}
|
||||
|
||||
var maximumNumberOfLines = 2 {
|
||||
didSet {
|
||||
self.shouldResetLayout = true
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
}
|
||||
|
||||
var lineSpacing: Double = 2 {
|
||||
didSet {
|
||||
self.shouldResetLayout = true
|
||||
|
||||
if #available(iOS 16, *)
|
||||
{
|
||||
self.updateText()
|
||||
@@ -37,6 +42,8 @@ final class CollapsingTextView: UITextView
|
||||
|
||||
override var text: String! {
|
||||
didSet {
|
||||
self.shouldResetLayout = true
|
||||
|
||||
guard #available(iOS 16, *) else { return }
|
||||
self.updateText()
|
||||
}
|
||||
@@ -44,6 +51,9 @@ final class CollapsingTextView: UITextView
|
||||
|
||||
let moreButton = UIButton(type: .system)
|
||||
|
||||
private var shouldResetLayout: Bool = false
|
||||
private var previousSize: CGSize?
|
||||
|
||||
override init(frame: CGRect, textContainer: NSTextContainer?)
|
||||
{
|
||||
super.init(frame: frame, textContainer: textContainer)
|
||||
@@ -105,6 +115,8 @@ final class CollapsingTextView: UITextView
|
||||
height: font.lineHeight)
|
||||
self.moreButton.frame = moreButtonFrame
|
||||
|
||||
if self.shouldResetLayout || self.previousSize != self.bounds.size
|
||||
{
|
||||
if self.isCollapsed
|
||||
{
|
||||
self.textContainer.maximumNumberOfLines = self.maximumNumberOfLines
|
||||
@@ -138,6 +150,10 @@ final class CollapsingTextView: UITextView
|
||||
|
||||
self.invalidateIntrinsicContentSize()
|
||||
}
|
||||
|
||||
self.shouldResetLayout = false
|
||||
self.previousSize = self.bounds.size
|
||||
}
|
||||
}
|
||||
|
||||
private extension CollapsingTextView
|
||||
|
||||
Reference in New Issue
Block a user