From ed72022de2afa9a295dc3bf8b6347da858186969 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Sat, 29 Jun 2024 14:05:48 +0200 Subject: [PATCH] Add label for publisher (IOS-284) --- .../MastodonUI/View/Content/StatusCardControl.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift index 12ba3bcf6..ecc303c1d 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift @@ -31,6 +31,7 @@ public final class StatusCardControl: UIControl { private let highlightView = UIView() private let dividerView = UIView() private let imageView = UIImageView() + private let publisherDateLabel = UILabel() private let titleLabel = UILabel() private let descriptionLabel = UILabel() private lazy var showEmbedButton: UIButton = { @@ -90,6 +91,8 @@ public final class StatusCardControl: UIControl { authorLabel = UILabel() authorLabel.numberOfLines = 1 + publisherLabel.numberOfLines = 1 + var buttonConfiguration = UIButton.Configuration.filled() buttonConfiguration.background.cornerRadius = 10 buttonConfiguration.background.backgroundColor = Asset.Colors.Button.userFollowing.color @@ -133,6 +136,7 @@ public final class StatusCardControl: UIControl { imageView.setContentCompressionResistancePriority(.zero, for: .horizontal) imageView.setContentCompressionResistancePriority(.zero, for: .vertical) + labelStackView.addArrangedSubview(publisherLabel) labelStackView.addArrangedSubview(titleLabel) labelStackView.addArrangedSubview(descriptionLabel) labelStackView.layoutMargins = .init(top: 10, left: 10, bottom: 10, right: 10) @@ -184,6 +188,12 @@ public final class StatusCardControl: UIControl { accessibilityLabel = title } + if let providerName = card.providerName { + publisherLabel.text = providerName + publisherLabel.isHidden = false + } else { + publisherLabel.isHidden = true + } if let author = card.authors?.first { authorAccountButton.configuration?.title = author.name ?? author.account?.displayName