diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Card.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Card.swift index a8f1e511d..d80d63991 100644 --- a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Card.swift +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Card.swift @@ -36,6 +36,7 @@ extension Mastodon.Entity { public let embedURL: String? public let blurhash: String? public let authors: [Mastodon.Entity.Card.Author]? + public let publishedAt: Date? enum CodingKeys: String, CodingKey { case url @@ -53,6 +54,7 @@ extension Mastodon.Entity { case embedURL = "embed_url" case blurhash case authors + case publishedAt = "published_at" } } } diff --git a/MastodonSDK/Sources/MastodonUI/Extension/Date.swift b/MastodonSDK/Sources/MastodonUI/Extension/Date.swift index 8b4c0c3e0..59fb808dd 100644 --- a/MastodonSDK/Sources/MastodonUI/Extension/Date.swift +++ b/MastodonSDK/Sources/MastodonUI/Extension/Date.swift @@ -27,7 +27,11 @@ extension Date { formatter.timeStyle = .none // none return formatter }() - + + public var abbreviatedDate: String { + return Date.abbreviatedDateFormatter.string(from: self) + } + public var localizedAbbreviatedSlowedTimeAgoSinceNow: String { return Date.relativeTimestampFormatter.localizedString(for: self, relativeTo: Date()) } diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift index 3e3abe5e4..36b434d72 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift @@ -97,6 +97,8 @@ public final class StatusCardControl: UIControl { authorLabel.numberOfLines = 1 publisherLabel.numberOfLines = 1 + publisherLabel.font = UIFontMetrics(forTextStyle: .footnote).scaledFont(for: .systemFont(ofSize: 13, weight: .regular)) + publisherLabel.textColor = .secondaryLabel var buttonConfiguration = UIButton.Configuration.filled() buttonConfiguration.background.cornerRadius = 10 @@ -201,7 +203,14 @@ public final class StatusCardControl: UIControl { } if let providerName = card.providerName { - publisherLabel.text = providerName + let publisherDateText: String + if let formattedPublishedDate = card.publishedAt?.abbreviatedDate { + publisherDateText = "\(providerName) ยท \(formattedPublishedDate)" + } else { + publisherDateText = providerName + } + + publisherLabel.text = publisherDateText publisherLabel.isHidden = false } else { publisherLabel.isHidden = true