Skip to content

Commit 56dce53

Browse files
authored
Make ChatChannelInfoView subviews public for composing own info views (#892)
1 parent 497518a commit 56dce53

File tree

8 files changed

+29
-13
lines changed

8 files changed

+29
-13
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
77
- Add support for showing current poll comment on alert [#891](https://github.com/GetStream/stream-chat-swiftui/pull/891)
88

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

1116
# [4.82.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.82.0)
1217
_July 16, 2025_

Sources/StreamChatSwiftUI/ChatChannel/ChannelHeader/ChatChannelHeaderViewModifier.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,20 @@ public struct DefaultChannelHeaderModifier<Factory: ViewFactory>: ChatChannelHea
119119
}
120120
}
121121

122-
struct ChannelTitleView: View {
122+
public struct ChannelTitleView: View {
123123
@Injected(\.fonts) private var fonts
124124
@Injected(\.utils) private var utils
125125
@Injected(\.colors) private var colors
126126
@Injected(\.chatClient) private var chatClient
127127

128-
var channel: ChatChannel
129-
var shouldShowTypingIndicator: Bool
128+
let channel: ChatChannel
129+
let shouldShowTypingIndicator: Bool
130130

131+
public init(channel: ChatChannel, shouldShowTypingIndicator: Bool) {
132+
self.channel = channel
133+
self.shouldShowTypingIndicator = shouldShowTypingIndicator
134+
}
135+
131136
private var currentUserId: String {
132137
chatClient.currentUserId ?? ""
133138
}
@@ -136,7 +141,7 @@ struct ChannelTitleView: View {
136141
utils.channelNamer
137142
}
138143

139-
var body: some View {
144+
public var body: some View {
140145
VStack(spacing: 2) {
141146
Text(channelNamer(channel, currentUserId) ?? "")
142147
.font(fonts.bodyBold)

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoHelperViews.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ public struct ChatChannelInfoButton: View {
3838
}
3939
}
4040

41-
struct ChannelInfoDivider: View {
41+
public struct ChannelInfoDivider: View {
4242
@Injected(\.colors) private var colors
4343

44-
var body: some View {
44+
public init() {}
45+
46+
public var body: some View {
4547
Rectangle()
4648
.fill(Color(colors.innerBorder))
4749
.frame(height: 8)
@@ -240,19 +242,19 @@ public struct ChannelInfoItemView<TrailingView: View>: View {
240242
}
241243
}
242244

243-
struct ChatInfoDirectChannelView<Factory: ViewFactory>: View {
245+
public struct ChatInfoDirectChannelView<Factory: ViewFactory>: View {
244246
@Injected(\.fonts) private var fonts
245247
@Injected(\.colors) private var colors
246248

247249
let factory: Factory
248250
var participant: ParticipantInfo?
249251

250-
init(factory: Factory = DefaultViewFactory.shared, participant: ParticipantInfo?) {
252+
public init(factory: Factory = DefaultViewFactory.shared, participant: ParticipantInfo?) {
251253
self.factory = factory
252254
self.participant = participant
253255
}
254256

255-
var body: some View {
257+
public var body: some View {
256258
VStack {
257259
let displayInfo = UserDisplayInfo(
258260
id: participant?.chatUser.id ?? "",

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
5858

5959
if viewModel.showMoreUsersButton {
6060
ChatChannelInfoButton(
61-
title: L10n.ChatInfo.Users.loadMore(viewModel.notDisplayedParticipantsCount),
61+
title: viewModel.showMoreUsersButtonTitle,
6262
iconName: "chevron.down",
6363
foregroundColor: Color(colors.textLowEmphasis)
6464
) {

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoViewModel.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe
9999
return L10n.Alert.Actions.leaveGroupMessage
100100
}
101101
}
102+
103+
public var showMoreUsersButtonTitle: String {
104+
L10n.ChatInfo.Users.loadMore(notDisplayedParticipantsCount)
105+
}
102106

103107
public var notDisplayedParticipantsCount: Int {
104108
let total = channel.memberCount

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatInfoParticipantsView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import StreamChat
66
import SwiftUI
77

88
/// View for the chat info participants.
9-
struct ChatInfoParticipantsView<Factory: ViewFactory>: View {
9+
public struct ChatInfoParticipantsView<Factory: ViewFactory>: View {
1010
@Injected(\.fonts) private var fonts
1111
@Injected(\.colors) private var colors
1212

1313
let factory: Factory
1414
var participants: [ParticipantInfo]
1515
var onItemAppear: (ParticipantInfo) -> Void
1616

17-
init(
17+
public init(
1818
factory: Factory = DefaultViewFactory.shared,
1919
participants: [ParticipantInfo],
2020
onItemAppear: @escaping (ParticipantInfo) -> Void
@@ -24,7 +24,7 @@ struct ChatInfoParticipantsView<Factory: ViewFactory>: View {
2424
self.onItemAppear = onItemAppear
2525
}
2626

27-
var body: some View {
27+
public var body: some View {
2828
LazyVStack {
2929
ForEach(participants) { participant in
3030
HStack {

0 commit comments

Comments
 (0)