Skip to content

Commit 200eaae

Browse files
UI Fixes to the channel list item (#1384)
1 parent a6a40d3 commit 200eaae

31 files changed

Lines changed: 29 additions & 30 deletions

File tree

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListItem.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public struct ChatChannelListItem<Factory: ViewFactory>: View {
216216
if let iconImage = previewAttachmentIconImage {
217217
Image(uiImage: iconImage)
218218
.customizable()
219-
.frame(maxHeight: 14)
219+
.frame(height: 14)
220220
.accessibilityHidden(true)
221221
}
222222
}
@@ -246,8 +246,8 @@ public struct ChatChannelListItem<Factory: ViewFactory>: View {
246246
private var mutedIcon: some View {
247247
Image(uiImage: images.muted)
248248
.customizable()
249-
.frame(maxHeight: 12)
250-
.foregroundColor(Color(colors.textSecondary))
249+
.frame(height: tokens.iconSizeMd)
250+
.foregroundColor(Color(colors.textTertiary))
251251
}
252252

253253
private var lastMessageFailedToSend: Bool {

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public struct ChatChannelListView<Factory: ViewFactory>: View {
7979
containerView
8080
.sheet(isPresented: $viewModel.channelPopupShown, content: {
8181
channelPopup()
82-
.modifier(PresentationDetentsModifier(sheetSizes: [.custom(280), .medium]))
8382
})
8483
.if(isIphone || !utils.messageListConfig.iPadSplitViewEnabled, transform: { view in
8584
view.navigationViewStyle(.stack)

Sources/StreamChatSwiftUI/ChatChannelList/DefaultChannelActions.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ extension ChannelAction {
3434
actions.append(muteAction(for: channel, chatClient: chatClient, onDismiss: onDismiss, onError: onError))
3535
}
3636

37-
actions.append(archiveAction(for: channel, chatClient: chatClient, onDismiss: onDismiss, onError: onError))
38-
3937
if let otherMember = channel.lastActiveMembers.first(where: { $0.id != chatClient.currentUserId }) {
4038
let blockedIds = chatClient.currentUserController().dataStore.currentUser()?.blockedUserIds ?? []
4139
actions.append(
@@ -69,8 +67,6 @@ extension ChannelAction {
6967
actions.append(muteAction(for: channel, chatClient: chatClient, onDismiss: onDismiss, onError: onError))
7068
}
7169

72-
actions.append(archiveAction(for: channel, chatClient: chatClient, onDismiss: onDismiss, onError: onError))
73-
7470
if channel.ownCapabilities.contains(.deleteChannel) {
7571
actions.append(deleteAction(for: channel, chatClient: chatClient, onDismiss: onDismiss, onError: onError))
7672
} else if channel.ownCapabilities.contains(.leaveChannel), let userId = chatClient.currentUserId {

Sources/StreamChatSwiftUI/ChatChannelList/MoreChannelActionsView.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ public struct MoreChannelActionsView<Factory: ViewFactory>: View {
5050
}
5151

5252
public var body: some View {
53-
VStack(alignment: .leading, spacing: 0) {
54-
channelHeader
55-
actionsListView
56-
Spacer()
53+
ScrollView {
54+
VStack(alignment: .leading, spacing: 0) {
55+
channelHeader
56+
actionsListView
57+
Spacer()
58+
}
5759
}
58-
.background(colors.backgroundCoreApp.toColor.edgesIgnoringSafeArea(.all))
60+
.background(colors.backgroundCoreElevation1.toColor.edgesIgnoringSafeArea(.all))
5961
.alert(isPresented: $viewModel.alertShown) {
6062
let title = viewModel.alertAction?.confirmationPopup?.title ?? ""
6163
let message = viewModel.alertAction?.confirmationPopup?.message ?? ""

Sources/StreamChatSwiftUI/ViewFactory/DefaultViewFactory.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,23 @@ extension ViewFactory {
3131
public func makeMoreChannelActionsView(
3232
options: MoreChannelActionsViewOptions
3333
) -> some View {
34-
MoreChannelActionsView(
34+
let actions = InjectedValues[\.utils].channelListConfig.supportedMoreChannelActions(
35+
SupportedMoreChannelActionsOptions(
36+
channel: options.channel,
37+
onDismiss: options.onDismiss,
38+
onError: options.onError
39+
)
40+
)
41+
return MoreChannelActionsView(
3542
factory: self,
3643
channel: options.channel,
37-
channelActions: InjectedValues[\.utils].channelListConfig.supportedMoreChannelActions(
38-
SupportedMoreChannelActionsOptions(
39-
channel: options.channel,
40-
onDismiss: options.onDismiss,
41-
onError: options.onError
42-
)
43-
),
44+
channelActions: actions,
4445
swipedChannelId: options.swipedChannelId,
4546
onDismiss: options.onDismiss
4647
)
48+
.modifier(PresentationDetentsModifier(
49+
sheetSizes: [.custom(actions.count > 3 ? 250 : 200), .medium])
50+
)
4751
}
4852

4953
public func makeChannelListItem(
Loading

StreamChatSwiftUITests/Tests/ChatChannelList/MoreChannelActionsViewModel_Tests.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ import XCTest
5050
// When
5151
let actions = makeActions(for: channel)
5252

53-
// Then - viewInfo, muteUser (mutesEnabled=true by default), archiveConversation
54-
XCTAssertEqual(actions.count, 3)
53+
// Then - viewInfo, muteUser (mutesEnabled=true by default)
54+
XCTAssertEqual(actions.count, 2)
5555
XCTAssertEqual(actions[0].title, L10n.Alert.Actions.viewInfoTitle)
5656
XCTAssertEqual(actions[1].title, L10n.Alert.Actions.muteUser)
57-
XCTAssertEqual(actions[2].title, L10n.Alert.Actions.archiveConversation)
5857
}
5958

6059
func test_defaultActions_dmChannel_withDeleteCapability_hasDeleteAction() {
@@ -108,8 +107,8 @@ import XCTest
108107
// When
109108
let actions = makeActions(for: channel)
110109

111-
// Then
112-
XCTAssertTrue(actions.contains(where: { $0.title == L10n.Alert.Actions.unarchiveConversation }))
110+
// Then - archive action removed; neither archive nor unarchive should appear
111+
XCTAssertFalse(actions.contains(where: { $0.title == L10n.Alert.Actions.unarchiveConversation }))
113112
XCTAssertFalse(actions.contains(where: { $0.title == L10n.Alert.Actions.archiveConversation }))
114113
}
115114

@@ -122,11 +121,10 @@ import XCTest
122121
// When
123122
let actions = makeActions(for: channel)
124123

125-
// Then - viewInfo, muteChannel (mutesEnabled=true by default), archiveChannel
126-
XCTAssertEqual(actions.count, 3)
124+
// Then - viewInfo, muteChannel (mutesEnabled=true by default)
125+
XCTAssertEqual(actions.count, 2)
127126
XCTAssertEqual(actions[0].title, L10n.Alert.Actions.viewInfoTitle)
128127
XCTAssertEqual(actions[1].title, L10n.Alert.Actions.muteChannel)
129-
XCTAssertEqual(actions[2].title, L10n.Alert.Actions.archiveChannel)
130128
}
131129

132130
func test_defaultActions_groupChannel_withDeleteCapability_hasDeleteAction() {
Loading
Loading
Loading

0 commit comments

Comments
 (0)