Skip to content

Make ChatChannelInfoView subviews public for composing own info views #892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add support for showing current poll comment on alert [#891](https://github.com/GetStream/stream-chat-swiftui/pull/891)

### 🔄 Changed
- Make `ChatChannelInfoView` subviews public for creating custom info views through composition [#892](https://github.com/GetStream/stream-chat-swiftui/pull/892)
- `ChannelTitleView`
- `ChannelInfoDivider`
- `ChatInfoDirectChannelView`
- `ChatInfoParticipantsView`

# [4.82.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.82.0)
_July 16, 2025_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,20 @@ public struct DefaultChannelHeaderModifier<Factory: ViewFactory>: ChatChannelHea
}
}

struct ChannelTitleView: View {
public struct ChannelTitleView: View {
@Injected(\.fonts) private var fonts
@Injected(\.utils) private var utils
@Injected(\.colors) private var colors
@Injected(\.chatClient) private var chatClient

var channel: ChatChannel
var shouldShowTypingIndicator: Bool
let channel: ChatChannel
let shouldShowTypingIndicator: Bool

public init(channel: ChatChannel, shouldShowTypingIndicator: Bool) {
self.channel = channel
self.shouldShowTypingIndicator = shouldShowTypingIndicator
}

private var currentUserId: String {
chatClient.currentUserId ?? ""
}
Expand All @@ -136,7 +141,7 @@ struct ChannelTitleView: View {
utils.channelNamer
}

var body: some View {
public var body: some View {
VStack(spacing: 2) {
Text(channelNamer(channel, currentUserId) ?? "")
.font(fonts.bodyBold)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ public struct ChatChannelInfoButton: View {
}
}

struct ChannelInfoDivider: View {
public struct ChannelInfoDivider: View {
@Injected(\.colors) private var colors

var body: some View {
public init() {}

public var body: some View {
Rectangle()
.fill(Color(colors.innerBorder))
.frame(height: 8)
Expand Down Expand Up @@ -240,19 +242,19 @@ public struct ChannelInfoItemView<TrailingView: View>: View {
}
}

struct ChatInfoDirectChannelView<Factory: ViewFactory>: View {
public struct ChatInfoDirectChannelView<Factory: ViewFactory>: View {
@Injected(\.fonts) private var fonts
@Injected(\.colors) private var colors

let factory: Factory
var participant: ParticipantInfo?

init(factory: Factory = DefaultViewFactory.shared, participant: ParticipantInfo?) {
public init(factory: Factory = DefaultViewFactory.shared, participant: ParticipantInfo?) {
self.factory = factory
self.participant = participant
}

var body: some View {
public var body: some View {
VStack {
let displayInfo = UserDisplayInfo(
id: participant?.chatUser.id ?? "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable

if viewModel.showMoreUsersButton {
ChatChannelInfoButton(
title: L10n.ChatInfo.Users.loadMore(viewModel.notDisplayedParticipantsCount),
title: viewModel.showMoreUsersButtonTitle,
iconName: "chevron.down",
foregroundColor: Color(colors.textLowEmphasis)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe
return L10n.Alert.Actions.leaveGroupMessage
}
}

public var showMoreUsersButtonTitle: String {
L10n.ChatInfo.Users.loadMore(notDisplayedParticipantsCount)
}

public var notDisplayedParticipantsCount: Int {
let total = channel.memberCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import StreamChat
import SwiftUI

/// View for the chat info participants.
struct ChatInfoParticipantsView<Factory: ViewFactory>: View {
public struct ChatInfoParticipantsView<Factory: ViewFactory>: View {
@Injected(\.fonts) private var fonts
@Injected(\.colors) private var colors

let factory: Factory
var participants: [ParticipantInfo]
var onItemAppear: (ParticipantInfo) -> Void

init(
public init(
factory: Factory = DefaultViewFactory.shared,
participants: [ParticipantInfo],
onItemAppear: @escaping (ParticipantInfo) -> Void
Expand All @@ -24,7 +24,7 @@ struct ChatInfoParticipantsView<Factory: ViewFactory>: View {
self.onItemAppear = onItemAppear
}

var body: some View {
public var body: some View {
LazyVStack {
ForEach(participants) { participant in
HStack {
Expand Down
Loading