Skip to content

Commit c89e519

Browse files
Add avatar customization in add users popup (#787)
1 parent 467c934 commit c89e519

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

44
# Upcoming
55

6-
### 🔄 Changed
6+
### ✅ Added
7+
- Add avatar customization in add users popup [#787](https://github.com/GetStream/stream-chat-swiftui/pull/787)
78

89
# [4.74.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.74.0)
910
_March 14, 2025_

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/AddUsersView.swift

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,47 @@ import StreamChat
66
import SwiftUI
77

88
/// View for the add users popup.
9-
struct AddUsersView: View {
9+
struct AddUsersView<Factory: ViewFactory>: View {
1010

1111
@Injected(\.fonts) private var fonts
1212
@Injected(\.colors) private var colors
1313

14-
private static let columnCount = 4
15-
private static let itemSize: CGFloat = 64
16-
1714
private let columns = Array(
1815
repeating:
1916
GridItem(
20-
.adaptive(minimum: itemSize),
17+
.adaptive(minimum: 64),
2118
alignment: .top
2219
),
23-
count: columnCount
20+
count: 4
2421
)
22+
23+
private let factory: Factory
2524

2625
@StateObject private var viewModel: AddUsersViewModel
2726
var onUserTap: (ChatUser) -> Void
2827

2928
init(
29+
factory: Factory = DefaultViewFactory.shared,
3030
loadedUserIds: [String],
3131
onUserTap: @escaping (ChatUser) -> Void
3232
) {
3333
_viewModel = StateObject(
3434
wrappedValue: AddUsersViewModel(loadedUserIds: loadedUserIds)
3535
)
3636
self.onUserTap = onUserTap
37+
self.factory = factory
3738
}
3839

3940
init(
41+
factory: Factory = DefaultViewFactory.shared,
4042
viewModel: AddUsersViewModel,
4143
onUserTap: @escaping (ChatUser) -> Void
4244
) {
4345
_viewModel = StateObject(
4446
wrappedValue: viewModel
4547
)
4648
self.onUserTap = onUserTap
49+
self.factory = factory
4750
}
4851

4952
var body: some View {
@@ -57,17 +60,20 @@ struct AddUsersView: View {
5760
onUserTap(user)
5861
} label: {
5962
VStack {
60-
MessageAvatarView(
61-
avatarURL: user.imageURL,
62-
size: CGSize(width: Self.itemSize, height: Self.itemSize),
63-
showOnlineIndicator: false
63+
let itemSize: CGFloat = 64
64+
let userDisplayInfo = UserDisplayInfo(
65+
id: user.id,
66+
name: user.name ?? "",
67+
imageURL: user.imageURL,
68+
size: CGSize(width: itemSize, height: itemSize)
6469
)
70+
factory.makeMessageAvatarView(for: userDisplayInfo)
6571

6672
Text(user.name ?? user.id)
6773
.multilineTextAlignment(.center)
6874
.lineLimit(2)
6975
.font(fonts.footnoteBold)
70-
.frame(width: Self.itemSize)
76+
.frame(width: itemSize)
7177
.foregroundColor(Color(colors.text))
7278
}
7379
.padding(.all, 8)

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
126126
viewModel.addUsersShown = false
127127
}
128128
AddUsersView(
129+
factory: factory,
129130
loadedUserIds: viewModel.participants.map(\.id),
130131
onUserTap: viewModel.addUserTapped(_:)
131132
)

0 commit comments

Comments
 (0)