Show (optional) published-date (IOS-284)
This commit is contained in:
parent
96798f941c
commit
a3b4528862
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,10 @@ extension Date {
|
|||
return formatter
|
||||
}()
|
||||
|
||||
public var abbreviatedDate: String {
|
||||
return Date.abbreviatedDateFormatter.string(from: self)
|
||||
}
|
||||
|
||||
public var localizedAbbreviatedSlowedTimeAgoSinceNow: String {
|
||||
return Date.relativeTimestampFormatter.localizedString(for: self, relativeTo: Date())
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue