Skip to content

Commit 637f42d

Browse files
Fixes to the channel list item
1 parent b27aa70 commit 637f42d

File tree

6 files changed

+40
-42
lines changed

6 files changed

+40
-42
lines changed

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelList.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public struct ChannelList<Factory: ViewFactory>: View {
5454

5555
public var body: some View {
5656
ScrollView {
57-
LazyVStack {
57+
LazyVStack(spacing: 0) {
5858
ForEach(channels) { channel in
5959
factory.makeChannelListItem(
6060
channel: channel,
@@ -70,7 +70,6 @@ public struct ChannelList<Factory: ViewFactory>: View {
7070
trailingSwipeLeftButtonTapped: trailingSwipeLeftButtonTapped,
7171
leadingSwipeButtonTapped: leadingSwipeButtonTapped
7272
)
73-
.frame(height: 48)
7473
.onAppear {
7574
if let index = channels.firstIndex(where: { chatChannel in
7675
chatChannel.id == channel.id

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListItem.swift

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,54 +22,52 @@ public struct ChatChannelListItem: View {
2222
var onItemTap: (ChatChannel) -> Void
2323

2424
public var body: some View {
25-
ZStack {
26-
Button {
27-
onItemTap(channel)
28-
} label: {
29-
HStack {
30-
ChannelAvatarView(
31-
avatar: avatar,
32-
showOnlineIndicator: onlineIndicatorShown
33-
)
34-
35-
VStack(alignment: .leading, spacing: 4) {
36-
HStack {
37-
titleView
38-
39-
Spacer()
40-
41-
if channel.unreadCount != .noUnread {
42-
UnreadIndicatorView(
43-
unreadCount: channel.unreadCount.messages
44-
)
45-
}
25+
Button {
26+
onItemTap(channel)
27+
} label: {
28+
HStack {
29+
ChannelAvatarView(
30+
avatar: avatar,
31+
showOnlineIndicator: onlineIndicatorShown
32+
)
33+
34+
VStack(alignment: .leading, spacing: 4) {
35+
HStack {
36+
titleView
37+
38+
Spacer()
39+
40+
if channel.unreadCount != .noUnread {
41+
UnreadIndicatorView(
42+
unreadCount: channel.unreadCount.messages
43+
)
4644
}
45+
}
46+
47+
HStack {
48+
subtitleView
4749

48-
HStack {
49-
subtitleView
50-
51-
Spacer()
52-
53-
HStack(spacing: 4) {
54-
if shouldShowReadEvents {
55-
MessageReadIndicatorView(
56-
readUsers: channel.readUsers(
57-
currentUserId: chatClient.currentUserId,
58-
message: channel.latestMessages.first
59-
),
60-
showReadCount: false
61-
)
62-
}
63-
SubtitleText(text: timestampText)
50+
Spacer()
51+
52+
HStack(spacing: 4) {
53+
if shouldShowReadEvents {
54+
MessageReadIndicatorView(
55+
readUsers: channel.readUsers(
56+
currentUserId: chatClient.currentUserId,
57+
message: channel.latestMessages.first
58+
),
59+
showReadCount: false
60+
)
6461
}
62+
SubtitleText(text: timestampText)
6563
}
6664
}
6765
}
68-
.padding(.all, 8)
6966
}
70-
.foregroundColor(.black)
71-
.disabled(disabled)
67+
.padding(.all, 8)
7268
}
69+
.foregroundColor(.black)
70+
.disabled(disabled)
7371
.id("\(channel.id)-base")
7472
}
7573

StreamChatSwiftUITests/Tests/ChatChannelList/NoChannelsView_Tests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class NoChannelsView_Tests: XCTestCase {
2525
func test_noChannelsView_snapshot() {
2626
// Given
2727
let view = NoChannelsView()
28+
.frame(width: defaultScreenSize.width, height: defaultScreenSize.height)
2829

2930
// Then
3031
assertSnapshot(matching: view, as: .image)
Loading
Loading
56.3 KB
Loading

0 commit comments

Comments
 (0)