From ba7325464594c5eb72b80a16b3ce352531f18536 Mon Sep 17 00:00:00 2001 From: shannon Date: Wed, 5 Mar 2025 18:08:55 -0500 Subject: [PATCH] Add ellipsis to end of avatar row if more than the pictured accounts are included in the notification group Contributes to #399 [BUG] Multiple interactions do not collapse into a single notification --- .../NotificationRowView.swift | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/Mastodon/In Progress New Layout and Datamodel/NotificationRowView.swift b/Mastodon/In Progress New Layout and Datamodel/NotificationRowView.swift index 812856f14..45e709bef 100644 --- a/Mastodon/In Progress New Layout and Datamodel/NotificationRowView.swift +++ b/Mastodon/In Progress New Layout and Datamodel/NotificationRowView.swift @@ -641,7 +641,11 @@ struct NotificationRowView: View { ) -> Int { let maxAvatarCount = Int( floor(fittingWidth / (smallAvatarSize + avatarSpacing))) - return maxAvatarCount + if maxAvatarCount < totalActorCount { + return maxAvatarCount - 1 + } else { + return maxAvatarCount + } } @ScaledMetric private var smallAvatarSize: CGFloat = 32 @@ -656,18 +660,29 @@ struct NotificationRowView: View { fittingWidth: geom.size.width, totalAvatarCount: accountInfo.avatarUrls.count, totalActorCount: accountInfo.totalActorCount) - HStack(alignment: .center) { - ForEach( - accountInfo.accounts.prefix(maxAvatarCount), id: \.self.id - ) { account in - AvatarView(author: account, goToProfile: viewModel.navigateToProfile(_:)) - .frame(width: smallAvatarSize, height: smallAvatarSize) - .onTapGesture { - Task { - try await viewModel.navigateToProfile(account) - } + HStack(spacing: 0) { + HStack(alignment: .center, spacing: avatarSpacing) { + ForEach( + accountInfo.accounts.prefix(maxAvatarCount), id: \.self.id + ) { account in + AvatarView(author: account, goToProfile: viewModel.navigateToProfile(_:)) + .frame(width: smallAvatarSize, height: smallAvatarSize) + .onTapGesture { + Task { + try await viewModel.navigateToProfile(account) + } + } } } + if maxAvatarCount < accountInfo.totalActorCount { + VStack { + Spacer().frame(maxHeight: .infinity) + Image(systemName: "ellipsis") + .foregroundStyle(.secondary) + .fontWeight(.light) + } + .frame(width: 0.75 * smallAvatarSize) + } Spacer().frame(minWidth: 0, maxWidth: .infinity) avatarRowTrailingElement( trailingElement, grouped: accountInfo.totalActorCount > 1)