mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-15 09:43:34 +01:00
Fixes crash when displaying new updates
This commit is contained in:
@@ -58,30 +58,33 @@ class CollapsingTextView: UITextView
|
|||||||
let buttonFont = UIFont.systemFont(ofSize: font.pointSize, weight: .medium)
|
let buttonFont = UIFont.systemFont(ofSize: font.pointSize, weight: .medium)
|
||||||
self.moreButton.titleLabel?.font = buttonFont
|
self.moreButton.titleLabel?.font = buttonFont
|
||||||
|
|
||||||
|
let buttonY = (font.lineHeight + self.lineSpacing) * CGFloat(self.maximumNumberOfLines - 1)
|
||||||
let size = self.moreButton.sizeThatFits(CGSize(width: 1000, height: 1000))
|
let size = self.moreButton.sizeThatFits(CGSize(width: 1000, height: 1000))
|
||||||
|
|
||||||
let moreButtonFrame = CGRect(x: self.bounds.width - self.moreButton.bounds.width,
|
let moreButtonFrame = CGRect(x: self.bounds.width - self.moreButton.bounds.width,
|
||||||
y: self.bounds.height - self.moreButton.bounds.height - self.lineSpacing,
|
y: buttonY,
|
||||||
width: size.width,
|
width: size.width,
|
||||||
height: font.lineHeight)
|
height: font.lineHeight)
|
||||||
self.moreButton.frame = moreButtonFrame
|
self.moreButton.frame = moreButtonFrame
|
||||||
|
|
||||||
if self.isCollapsed
|
if self.isCollapsed
|
||||||
{
|
{
|
||||||
var exclusionFrame = moreButtonFrame
|
|
||||||
exclusionFrame.origin.y += self.moreButton.bounds.midY
|
|
||||||
exclusionFrame.size.width = self.bounds.width // Extra wide to make sure it wraps to next line.
|
|
||||||
|
|
||||||
self.textContainer.maximumNumberOfLines = self.maximumNumberOfLines
|
self.textContainer.maximumNumberOfLines = self.maximumNumberOfLines
|
||||||
self.textContainer.exclusionPaths = [UIBezierPath(rect: exclusionFrame)]
|
|
||||||
|
|
||||||
let maximumCollapsedHeight = font.lineHeight * CGFloat(self.maximumNumberOfLines)
|
let maximumCollapsedHeight = font.lineHeight * CGFloat(self.maximumNumberOfLines)
|
||||||
if self.bounds.height > maximumCollapsedHeight
|
if self.intrinsicContentSize.height > maximumCollapsedHeight
|
||||||
{
|
{
|
||||||
|
var exclusionFrame = moreButtonFrame
|
||||||
|
exclusionFrame.origin.y += self.moreButton.bounds.midY
|
||||||
|
exclusionFrame.size.width = self.bounds.width // Extra wide to make sure it wraps to next line.
|
||||||
|
self.textContainer.exclusionPaths = [UIBezierPath(rect: exclusionFrame)]
|
||||||
|
|
||||||
self.moreButton.isHidden = false
|
self.moreButton.isHidden = false
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
self.textContainer.exclusionPaths = []
|
||||||
|
|
||||||
self.moreButton.isHidden = true
|
self.moreButton.isHidden = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,8 +333,11 @@ private extension MyAppsViewController
|
|||||||
UIApplication.shared.applicationIconBadgeNumber = 0
|
UIApplication.shared.applicationIconBadgeNumber = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
UIView.performWithoutAnimation {
|
if self.isViewLoaded
|
||||||
self.collectionView.reloadSections(IndexSet(integer: Section.updates.rawValue))
|
{
|
||||||
|
UIView.performWithoutAnimation {
|
||||||
|
self.collectionView.reloadSections(IndexSet(integer: Section.updates.rawValue))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user