diff --git a/apple/InlineMac/Features/Chat/Participants/ParticipantAvatarStack.swift b/apple/InlineMac/Features/Chat/Participants/ParticipantAvatarStack.swift index e419240f..01d33bbe 100644 --- a/apple/InlineMac/Features/Chat/Participants/ParticipantAvatarStack.swift +++ b/apple/InlineMac/Features/Chat/Participants/ParticipantAvatarStack.swift @@ -11,6 +11,10 @@ public struct ParticipantAvatarStack: View { self.participants = participants } + private var visibleParticipants: [UserInfo] { + Array(participants.prefix(3)) + } + private var overflowCount: Int { // This will be used if we need to show +N indicator in the future max(0, participants.count - 3) @@ -18,7 +22,7 @@ public struct ParticipantAvatarStack: View { public var body: some View { HStack(spacing: -overlap) { - ForEach(Array(participants.enumerated()), id: \.element.id) { index, participant in + ForEach(Array(visibleParticipants.enumerated()), id: \.element.id) { index, participant in UserAvatar( user: participant.user, size: avatarSize @@ -29,9 +33,22 @@ public struct ParticipantAvatarStack: View { .strokeBorder(Color.white.opacity(0.3), lineWidth: 1) ) .shadow(color: .black.opacity(0.1), radius: 1, x: 0, y: 0.5) - .zIndex(Double(participants.count - index)) + .zIndex(Double(index)) + } + + if self.overflowCount > 0 { + Text("+\(self.overflowCount, format: .number.notation(.compactName))") + .font(.system(size: 6, design: .rounded).weight(.semibold).width(.compressed)) + .foregroundStyle(.white) + .frame(width: self.avatarSize, height: self.avatarSize) + .background(.accent.gradient, in: .circle) + .overlay( + Circle() + .strokeBorder(Color.white.opacity(0.3), lineWidth: 1) + ) + .shadow(color: .black.opacity(0.1), radius: 1, x: 0, y: 0.5) + .zIndex(Double(4)) } } - .padding(.horizontal, 8) } -} \ No newline at end of file +} diff --git a/apple/InlineMac/Features/Chat/Toolbar/ChatToolbarParticipantsCoordinator.swift b/apple/InlineMac/Features/Chat/Toolbar/ChatToolbarParticipantsCoordinator.swift index 4033ee3e..f03cd358 100644 --- a/apple/InlineMac/Features/Chat/Toolbar/ChatToolbarParticipantsCoordinator.swift +++ b/apple/InlineMac/Features/Chat/Toolbar/ChatToolbarParticipantsCoordinator.swift @@ -404,8 +404,8 @@ private struct ParticipantsButton: View { } private var buttonWidth: CGFloat { - let count = visibleParticipants.count - let width = CGFloat(count) * 24 - CGFloat(max(0, count - 1)) * 6 + 8 + let count = self.visibleParticipants.count == 3 ? 4 : self.visibleParticipants.count + let width = CGFloat(count) * 24 - CGFloat(max(0, count - 1)) * 6 return max(32, width) } @@ -415,7 +415,7 @@ private struct ParticipantsButton: View { .frame(width: buttonWidth) .opacity(0) .overlay { - ParticipantAvatarStack(participants: visibleParticipants) + ParticipantAvatarStack(participants: self.participants) } } }