File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed
Sources/StreamChatSwiftUI Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ public struct ChannelList<Factory: ViewFactory>: View {
108108
109109/// LazyVStack displaying list of channels.
110110public struct ChannelsLazyVStack < Factory: ViewFactory > : View {
111+ @Injected ( \. colors) private var colors
111112
112113 private var factory : Factory
113114 var channels : LazyCachedMapCollection < ChatChannel >
@@ -170,6 +171,11 @@ public struct ChannelsLazyVStack<Factory: ViewFactory>: View {
170171 trailingSwipeLeftButtonTapped: trailingSwipeLeftButtonTapped,
171172 leadingSwipeButtonTapped: leadingSwipeButtonTapped
172173 )
174+ . background ( factory. makeChannelListItemBackground (
175+ colors: colors,
176+ channel: channel,
177+ isSelected: selectedChannel? . channel. id == channel. id
178+ ) )
173179 . onAppear {
174180 if let index = channels. firstIndex ( where: { chatChannel in
175181 chatChannel. id == channel. id
Original file line number Diff line number Diff line change @@ -99,7 +99,19 @@ extension ViewFactory {
9999 Color ( colors. background)
100100 . edgesIgnoringSafeArea ( . bottom)
101101 }
102-
102+
103+ public func makeChannelListItemBackground(
104+ colors: ColorPalette ,
105+ channel: ChatChannel ,
106+ isSelected: Bool
107+ ) -> some View {
108+ if isSelected && isIPad {
109+ return Color ( colors. background6)
110+ }
111+
112+ return Color ( colors. background)
113+ }
114+
103115 public func makeChannelListDividerItem( ) -> some View {
104116 Divider ( )
105117 }
Original file line number Diff line number Diff line change @@ -65,6 +65,18 @@ public protocol ViewFactory: AnyObject {
6565 /// - Returns: view shown as a background of the channel list.
6666 func makeChannelListBackground( colors: ColorPalette ) -> ChannelListBackground
6767
68+ associatedtype ChannelListItemBackground : View
69+ /// Creates the background for the channel list item.
70+ /// - Parameter colors: The colors palette used in the SDK.
71+ /// - Parameter channel: The channel which the item view belongs to.
72+ /// - Parameter isSelected: Whether the current item is selected or not.
73+ /// - Returns: The view shown as a background of the channel list item.
74+ func makeChannelListItemBackground(
75+ colors: ColorPalette ,
76+ channel: ChatChannel ,
77+ isSelected: Bool
78+ ) -> ChannelListItemBackground
79+
6880 associatedtype ChannelListDividerItem : View
6981 /// Creates the channel list divider item.
7082 func makeChannelListDividerItem( ) -> ChannelListDividerItem
You can’t perform that action at this time.
0 commit comments