diff --git a/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift b/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift index a6a8837dc..6c13bb4a4 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift @@ -52,6 +52,7 @@ public struct ChatChannelInfoView: View, KeyboardReadable } else { ChatInfoParticipantsView( factory: factory, + channel: viewModel.channel, participants: viewModel.displayedParticipants, onItemAppear: viewModel.onParticipantAppear(_:), selectedParticipant: $viewModel.selectedParticipant diff --git a/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatInfoParticipantsView.swift b/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatInfoParticipantsView.swift index 2bf11a91e..be1584e7d 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatInfoParticipantsView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatInfoParticipantsView.swift @@ -14,16 +14,19 @@ public struct ChatInfoParticipantsView: View { @Binding var selectedParticipant: ParticipantInfo? let factory: Factory + let channel: ChatChannel var participants: [ParticipantInfo] var onItemAppear: (ParticipantInfo) -> Void public init( factory: Factory = DefaultViewFactory.shared, + channel: ChatChannel, participants: [ParticipantInfo], onItemAppear: @escaping (ParticipantInfo) -> Void, selectedParticipant: Binding = .constant(nil) ) { self.factory = factory + self.channel = channel self.participants = participants self.onItemAppear = onItemAppear _selectedParticipant = selectedParticipant @@ -41,14 +44,8 @@ public struct ChatInfoParticipantsView: View { ) factory.makeMessageAvatarView(for: displayInfo) - VStack(alignment: .leading, spacing: 4) { - Text(participant.displayName) - .lineLimit(1) - .font(fonts.bodyBold) - Text(participant.onlineInfoText) - .font(fonts.footnote) - .foregroundColor(Color(colors.textLowEmphasis)) - } + participantView(participant: participant) + Spacer() } .padding(.all, 8) @@ -67,6 +64,26 @@ public struct ChatInfoParticipantsView: View { } .background(Color(colors.background)) } + + private func participantView(participant:ParticipantInfo)-> some View { + HStack(alignment: .center) { + VStack(alignment: .leading, spacing: 4) { + Text(participant.displayName) + .lineLimit(1) + .font(fonts.bodyBold) + Text(participant.onlineInfoText) + .font(fonts.footnote) + .foregroundColor(Color(colors.textLowEmphasis)) + } + Spacer() + + if channel.createdBy?.id == participant.chatUser.id { + Text(L10n.chatGroupInfoOwner) + .font(fonts.footnote) + .foregroundColor(Color(colors.textLowEmphasis)) + } + } + } } public struct ParticipantInfo: Identifiable { diff --git a/Sources/StreamChatSwiftUI/Generated/L10n.swift b/Sources/StreamChatSwiftUI/Generated/L10n.swift index 9c4dcf11c..8f8754e75 100644 --- a/Sources/StreamChatSwiftUI/Generated/L10n.swift +++ b/Sources/StreamChatSwiftUI/Generated/L10n.swift @@ -6,6 +6,8 @@ import Foundation // MARK: - Strings internal enum L10n { + /// Owner + internal static var chatGroupInfoOwner: String { L10n.tr("Localizable", "chat_group_info_owner") } /// %d of %d internal static func currentSelection(_ p1: Int, _ p2: Int) -> String { return L10n.tr("Localizable", "current-selection", p1, p2) diff --git a/Sources/StreamChatSwiftUI/Resources/en.lproj/Localizable.strings b/Sources/StreamChatSwiftUI/Resources/en.lproj/Localizable.strings index 619e24b32..dbfb37f46 100644 --- a/Sources/StreamChatSwiftUI/Resources/en.lproj/Localizable.strings +++ b/Sources/StreamChatSwiftUI/Resources/en.lproj/Localizable.strings @@ -236,3 +236,5 @@ "thread.error.message" = "Error loading threads"; "thread.no-content.message" = "No threads here yet..."; "thread.item.replied-to" = "replied to: %@"; + +"chat_group_info_owner" = "Owner";