Skip to content

Commit 6e43654

Browse files
Implemented adding custom background for channel and message list
1 parent aed2b83 commit 6e43654

File tree

117 files changed

+126
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+126
-5
lines changed

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ public struct MessageListView<Factory: ViewFactory>: View, KeyboardReadable {
118118
.id(listId)
119119
}
120120
}
121-
.background(Color(colors.background))
121+
.background(
122+
factory.makeMessageListBackground(
123+
colors: colors,
124+
isInThread: isMessageThread
125+
)
126+
)
122127
.coordinateSpace(name: scrollAreaId)
123128
.onPreferenceChange(WidthPreferenceKey.self) { value in
124129
if let value = value, value != width {

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelList.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public struct ChannelList<Factory: ViewFactory>: View {
6868
channelsVStack
6969
}
7070
}
71-
.background(Color(colors.background))
7271
}
7372

7473
private var channelsVStack: some View {

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ public struct ChatChannelListView<Factory: ViewFactory>: View {
9797
)
9898
}
9999
}
100-
.background(Color(colors.background))
101100
}
102101
}
103102
}
103+
.background(
104+
viewFactory.makeChannelListBackground(colors: colors)
105+
)
104106
.alert(isPresented: $viewModel.alertShown) {
105107
switch viewModel.channelAlertType {
106108
case let .deleteChannel(channel):

Sources/StreamChatSwiftUI/CommonViews/LoadingView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public struct LoadingView: View {
1212
ProgressView()
1313
Spacer()
1414
}
15+
.frame(maxWidth: .infinity)
1516
}
1617
}

Sources/StreamChatSwiftUI/DefaultViewFactory.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ extension ViewFactory {
9494
)
9595
}
9696

97+
public func makeChannelListBackground(colors: ColorPalette) -> some View {
98+
Color(colors.background)
99+
.edgesIgnoringSafeArea(.bottom)
100+
}
101+
97102
public func makeChannelListDividerItem() -> some View {
98103
Divider()
99104
}
@@ -197,6 +202,13 @@ extension ViewFactory {
197202
DefaultMessageThreadHeaderModifier()
198203
}
199204

205+
public func makeMessageListBackground(
206+
colors: ColorPalette,
207+
isInThread: Bool
208+
) -> some View {
209+
Color(colors.background)
210+
}
211+
200212
public func makeMessageContainerView(
201213
channel: ChatChannel,
202214
message: ChatMessage,

Sources/StreamChatSwiftUI/ViewFactory.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ public protocol ViewFactory: AnyObject {
5959
leadingSwipeButtonTapped: @escaping (ChatChannel) -> Void
6060
) -> ChannelListItemType
6161

62+
associatedtype ChannelListBackground: View
63+
/// Creates the background for the channel list.
64+
/// - Parameter colors: the colors used in the SDK.
65+
/// - Returns: view shown as a background of the channel list.
66+
func makeChannelListBackground(colors: ColorPalette) -> ChannelListBackground
67+
6268
associatedtype ChannelListDividerItem: View
6369
/// Creates the channel list divider item.
6470
func makeChannelListDividerItem() -> ChannelListDividerItem
@@ -176,6 +182,17 @@ public protocol ViewFactory: AnyObject {
176182
/// Creates the message thread header view modifier.
177183
func makeMessageThreadHeaderViewModifier() -> ThreadHeaderViewModifier
178184

185+
associatedtype MessageListBackground: View
186+
/// Creates the background for the message list.
187+
/// - Parameters:
188+
/// - colors: the color palette used in the SDK.
189+
/// - isInThread: whether the message list is part of a message thread.
190+
/// - Returns: view shown as a background for the message list.
191+
func makeMessageListBackground(
192+
colors: ColorPalette,
193+
isInThread: Bool
194+
) -> MessageListBackground
195+
179196
associatedtype MessageContainerViewType: View
180197
/// Creates the message container view.
181198
/// - Parameters:
-592 Bytes
-751 Bytes
-15.2 KB
-18.7 KB

0 commit comments

Comments
 (0)