Hide card description label when it doesn't fit

Closes #336
This commit is contained in:
Shadowfacts 2023-02-25 15:23:13 -05:00
parent 6f51f321f6
commit 3d9477f0c9
1 changed files with 9 additions and 1 deletions

View File

@ -26,6 +26,7 @@ class StatusCardView: UIView {
private var isGrayscale = false
private var hStack: UIStackView!
private var vStack: UIStackView!
private var titleLabel: UILabel!
private var descriptionLabel: UILabel!
private var domainLabel: UILabel!
@ -70,7 +71,7 @@ class StatusCardView: UIView {
domainLabel.numberOfLines = 1
domainLabel.textColor = .tintColor
let vStack = UIStackView(arrangedSubviews: [
vStack = UIStackView(arrangedSubviews: [
titleLabel,
descriptionLabel,
domainLabel,
@ -188,6 +189,13 @@ class StatusCardView: UIView {
} else {
domainLabel.isHidden = true
}
let titleHeight = titleLabel.isHidden ? 0 : titleLabel.sizeThatFits(CGSize(width: titleLabel.bounds.width, height: UIView.layoutFittingCompressedSize.height)).height
let descriptionHeight = descriptionLabel.isHidden ? 0 : descriptionLabel.sizeThatFits(CGSize(width: descriptionLabel.bounds.width, height: UIView.layoutFittingCompressedSize.height)).height
let domainLabel = domainLabel.isHidden ? 0 : domainLabel.sizeThatFits(CGSize(width: domainLabel.bounds.width, height: UIView.layoutFittingCompressedSize.height)).height
if titleHeight + descriptionHeight + domainLabel > vStack.bounds.height {
descriptionLabel.isHidden = true
}
}
private func loadBlurHash() {