Skip to content

Commit 85012cd

Browse files
committed
Add the description text too (when in the vertical layout)
1 parent e764d5a commit 85012cd

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public final class StatusCardControl: UIControl {
3131
private let dividerView = UIView()
3232
private let imageView = UIImageView()
3333
private let titleLabel = UILabel()
34+
private let descriptionLabel = UILabel()
3435
private let siteNameLabel = UILabel()
3536
private lazy var showEmbedButton: UIButton = {
3637
var configuration = UIButton.Configuration.gray()
@@ -85,7 +86,16 @@ public final class StatusCardControl: UIControl {
8586

8687
titleLabel.numberOfLines = 2
8788
titleLabel.textColor = Asset.Colors.Label.primary.color
88-
titleLabel.font = .preferredFont(forTextStyle: .body)
89+
let descriptor = UIFont.preferredFont(forTextStyle: .body)
90+
.fontDescriptor
91+
.addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: UIFont.Weight.medium]])
92+
titleLabel.font = UIFontMetrics(forTextStyle: .body)
93+
.scaledFont(for: UIFont(descriptor: descriptor, size: descriptor.pointSize))
94+
titleLabel.adjustsFontForContentSizeCategory = false
95+
96+
descriptionLabel.numberOfLines = 2
97+
descriptionLabel.textColor = Asset.Colors.Label.primary.color
98+
descriptionLabel.font = .preferredFont(forTextStyle: .caption1)
8999

90100
siteNameLabel.numberOfLines = 1
91101
siteNameLabel.textColor = Asset.Colors.Label.secondary.color
@@ -100,6 +110,7 @@ public final class StatusCardControl: UIControl {
100110
imageView.setContentCompressionResistancePriority(.zero, for: .vertical)
101111

102112
labelStackView.addArrangedSubview(titleLabel)
113+
labelStackView.addArrangedSubview(descriptionLabel)
103114
labelStackView.addArrangedSubview(siteNameLabel)
104115
labelStackView.layoutMargins = .init(top: 10, left: 10, bottom: 10, right: 10)
105116
labelStackView.isLayoutMarginsRelativeArrangement = true
@@ -146,6 +157,7 @@ public final class StatusCardControl: UIControl {
146157
}
147158

148159
titleLabel.text = title
160+
descriptionLabel.text = card.desc.trimmingCharacters(in: .whitespacesAndNewlines)
149161
siteNameLabel.text = card.websiteName
150162
imageView.contentMode = .center
151163

@@ -208,6 +220,7 @@ public final class StatusCardControl: UIControl {
208220
.constraint(lessThanOrEqualToConstant: 400),
209221
]
210222
dividerConstraint = dividerView.heightAnchor.constraint(equalToConstant: pixelSize).activate()
223+
descriptionLabel.isHidden = false
211224
case .compact:
212225
containerStackView.alignment = .center
213226
containerStackView.axis = .horizontal
@@ -219,6 +232,7 @@ public final class StatusCardControl: UIControl {
219232
dividerView.heightAnchor.constraint(equalTo: containerStackView.heightAnchor),
220233
]
221234
dividerConstraint = dividerView.widthAnchor.constraint(equalToConstant: pixelSize).activate()
235+
descriptionLabel.isHidden = true
222236
}
223237

224238
NSLayoutConstraint.activate(layoutConstraints)

0 commit comments

Comments
 (0)