@@ -54,10 +54,20 @@ public struct ChatChannelListItem<Factory: ViewFactory>: View {
5454
5555 VStack ( alignment: . leading, spacing: 4 ) {
5656 HStack {
57- ChatTitleView ( name: channelName)
57+ HStack ( spacing: 6 ) {
58+ ChatTitleView ( name: channelName)
59+ if channel. isMuted, mutedLayoutStyle == . afterChannelName {
60+ mutedIcon
61+ . frame ( maxHeight: 14 )
62+ . padding ( . bottom, - 2 )
63+ }
64+ }
5865
5966 Spacer ( )
6067
68+ if channel. isMuted, mutedLayoutStyle == . topRightCorner {
69+ mutedIcon
70+ }
6171 if injectedChannelInfo == nil && channel. unreadCount != . noUnread {
6272 UnreadIndicatorView (
6373 unreadCount: channel. unreadCount. messages
@@ -93,13 +103,14 @@ public struct ChatChannelListItem<Factory: ViewFactory>: View {
93103 . id ( " \( channel. id) -base " )
94104 }
95105
106+ private var mutedLayoutStyle : ChannelItemMutedLayoutStyle {
107+ utils. channelListConfig. channelItemMutedStyle
108+ }
109+
96110 private var subtitleView : some View {
97111 HStack ( spacing: 4 ) {
98- if let image = image {
99- Image ( uiImage: image)
100- . customizable ( )
101- . frame ( maxHeight: 12 )
102- . foregroundColor ( Color ( colors. subtitleText) )
112+ if channel. isMuted, mutedLayoutStyle == . default {
113+ mutedIcon
103114 } else {
104115 if channel. shouldShowTypingIndicator {
105116 TypingIndicatorView ( )
@@ -113,13 +124,40 @@ public struct ChatChannelListItem<Factory: ViewFactory>: View {
113124 SubtitleText ( text: draftText)
114125 }
115126 } else {
116- SubtitleText ( text: injectedChannelInfo ? . subtitle ?? channel . subtitleText)
127+ SubtitleText ( text: subtitleText)
117128 }
118129 Spacer ( )
119130 }
120131 . accessibilityIdentifier ( " subtitleView " )
121132 }
122133
134+ private var subtitleText : String {
135+ if let injectedSubtitle = injectedChannelInfo? . subtitle {
136+ return injectedSubtitle
137+ }
138+ if mutedLayoutStyle != . default {
139+ return channelSubtitleText
140+ }
141+ return channel. subtitleText
142+ }
143+
144+ private var channelSubtitleText : String {
145+ if channel. shouldShowTypingIndicator {
146+ return channel. typingIndicatorString ( currentUserId: chatClient. currentUserId)
147+ } else if let previewMessageText = channel. previewMessageText {
148+ return previewMessageText
149+ } else {
150+ return L10n . Channel. Item. emptyMessages
151+ }
152+ }
153+
154+ private var mutedIcon : some View {
155+ Image ( uiImage: images. muted)
156+ . customizable ( )
157+ . frame ( maxHeight: 12 )
158+ . foregroundColor ( Color ( colors. subtitleText) )
159+ }
160+
123161 private var shouldShowReadEvents : Bool {
124162 if let message = channel. latestMessages. first,
125163 message. isSentByCurrentUser,
@@ -345,3 +383,23 @@ extension ChatChannel {
345383 }
346384 }
347385}
386+
387+ /// The style for the muted icon in the channel list item.
388+ public struct ChannelItemMutedLayoutStyle : Hashable {
389+ let identifier : String
390+
391+ init ( _ identifier: String ) {
392+ self . identifier = identifier
393+ }
394+
395+ /// The default style shows the muted icon and the text "channel is muted" as the subtitle text.
396+ public static var `default` : ChannelItemMutedLayoutStyle = . init( " default " )
397+
398+ /// This style shows the muted icon at the top right corner of the channel item.
399+ /// The subtitle text shows the last message preview text.
400+ public static var topRightCorner : ChannelItemMutedLayoutStyle = . init( " topRightCorner " )
401+
402+ /// This style shows the muted icon after the channel name.
403+ /// The subtitle text shows the last message preview text.
404+ public static var afterChannelName : ChannelItemMutedLayoutStyle = . init( " afterChannelName " )
405+ }
0 commit comments