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

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
This commit is contained in:
shannon 2025-03-05 18:08:55 -05:00
parent 41c0ae0b13
commit ba73254645

View File

@ -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)