From 06fea1da0280fc7a54dfa429287500c44cd0ad35 Mon Sep 17 00:00:00 2001 From: lumaa-dev Date: Mon, 11 Nov 2024 13:07:35 +0100 Subject: [PATCH] Card author (4.3.0) --- Bubble/Components/Post/PostCardView.swift | 28 ++++++++++++++++++++--- Bubble/Data/Content/Status.swift | 11 +++++++++ Bubble/Localizable.xcstrings | 16 +++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/Bubble/Components/Post/PostCardView.swift b/Bubble/Components/Post/PostCardView.swift index a996a2c..fe52129 100644 --- a/Bubble/Components/Post/PostCardView.swift +++ b/Bubble/Components/Post/PostCardView.swift @@ -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([.horizontal, .bottom], 10) + .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) diff --git a/Bubble/Data/Content/Status.swift b/Bubble/Data/Content/Status.swift index 5849851..f8a70f5 100644 --- a/Bubble/Data/Content/Status.swift +++ b/Bubble/Data/Content/Status.swift @@ -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 {} diff --git a/Bubble/Localizable.xcstrings b/Bubble/Localizable.xcstrings index 8125cff..93e70ea 100644 --- a/Bubble/Localizable.xcstrings +++ b/Bubble/Localizable.xcstrings @@ -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" : {