Card author (4.3.0)

This commit is contained in:
lumaa-dev 2024-11-11 13:07:35 +01:00
parent c0b9eb4082
commit 06fea1da02
3 changed files with 52 additions and 3 deletions

View File

@ -7,11 +7,12 @@ struct PostCardView: View {
var card: Card
var inQuote: Bool = false
var imaging: Bool = false
var body: some View {
VStack(alignment: .center, spacing: 10) {
if card.image != nil {
OnlineImage(url: card.image, size: inQuote ? 260 : 300, useNuke: false)
OnlineImage(url: card.image, size: inQuote ? 260 : 300, useNuke: imaging)
.frame(width: inQuote ? 250 : 300)
}
@ -37,7 +38,28 @@ struct PostCardView: View {
.multilineTextAlignment(.leading)
.lineLimit(3)
}
.padding(card.authors.first?.account == nil ? [.horizontal, .bottom] : [.horizontal], 10)
if let acc = card.authors.first?.account {
Divider()
.frame(maxWidth: .infinity)
HStack(alignment: .center) {
Label {
Text("status.card.author-\(acc.acct)")
.font(.caption)
.lineLimit(1)
} icon: {
ProfilePicture(url: acc.avatar, size: 30.0)
}
.minimumScaleFactor(0.7)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding([.horizontal, .bottom], 10)
.onTapGesture {
Navigator.shared.navigate(to: .account(acc: acc))
}
}
}
.frame(width: inQuote ? 200 : 250)
.padding(.horizontal, 10)

View File

@ -328,8 +328,19 @@ public struct Card: Codable, Identifiable, Equatable, Hashable {
public let url: String
public let title: String?
public let description: String?
public let authors: [Self.Author]
public let type: String
public let image: URL?
public struct Author: Codable, Identifiable, Equatable, Sendable, Hashable {
public var id: String {
url
}
let name: String
let url: String
let account: Account?
}
}
extension Card: Sendable {}

View File

@ -3679,6 +3679,22 @@
}
}
},
"status.card.author-%@" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Article by @%@"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Article par @%@"
}
}
}
},
"status.content-filter.censor" : {
"localizations" : {
"en" : {