2
2
mirror of https://github.com/mastodon/mastodon-ios synced 2025-04-11 22:58:02 +02:00

Show more lines of the post preview and omit the attribution header when the author avatar is taking the place of the icon

Contributes to #399 [BUG] Multiple interactions do not collapse into a single notification
This commit is contained in:
shannon 2025-02-18 12:49:34 -05:00
parent a9ff00102c
commit 4847c461a0
2 changed files with 15 additions and 5 deletions

View File

@ -11,6 +11,7 @@ import SwiftUI
struct InlinePostPreview: View {
let viewModel: Mastodon.Entity.Status.ViewModel
let showAttributionHeader: Bool // TODO: remove this option when full post layout is available
@Environment(\.colorScheme) private var colorScheme
@ -20,7 +21,7 @@ struct InlinePostPreview: View {
if let content = viewModel.content {
Text(String(content.characters[...]))
.font(.subheadline)
.lineLimit(3)
.lineLimit(showAttributionHeader ? 3 : 9)
.fixedSize(horizontal: false, vertical: true)
}
if let attachmentInfo = viewModel.attachmentInfo {
@ -50,7 +51,7 @@ struct InlinePostPreview: View {
@ViewBuilder func header() -> some View {
HStack(spacing: 4) {
if viewModel.needsUserAttribution {
if showAttributionHeader && viewModel.needsUserAttribution {
if let url = viewModel.accountAvatarUrl {
AsyncImage(
url: url,

View File

@ -178,6 +178,15 @@ extension GroupedNotificationType {
return .gray
}
}
var wantsFullStatusLayout: Bool {
switch self {
case .status, .mention:
return true
default:
return false
}
}
func actionSummaryLabel(_ sourceAccounts: NotificationSourceAccounts)
-> AttributedString?
@ -673,10 +682,10 @@ struct NotificationRowView: View {
.frame(maxWidth: .infinity, alignment: .leading)
case .weightedText(let string, let weight):
textComponent(string, fontWeight: weight)
case .status(let viewModel):
InlinePostPreview(viewModel: viewModel)
case .status(let statusViewModel):
InlinePostPreview(viewModel: statusViewModel, showAttributionHeader: !viewModel.type.wantsFullStatusLayout)
.onTapGesture {
viewModel.navigateToStatus()
statusViewModel.navigateToStatus()
}
case .hyperlinkButton(let label, let url):
Button(label) {