Skip to content

Commit 0970711

Browse files
Customization of the channel loading view (#474)
1 parent 2c38783 commit 0970711

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

44
# Upcoming
55

6-
### 🔄 Changed
6+
### ✅ Added
7+
- Customization of the channel loading view
78

89
# [4.52.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.52.0)
910
_April 09, 2024_

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public struct ChatChannelView<Factory: ViewFactory>: View, KeyboardReadable {
152152
: nil
153153
)
154154
} else {
155-
LoadingView()
155+
factory.makeChannelLoadingView()
156156
}
157157
}
158158
.navigationBarTitleDisplayMode(factory.navigationBarDisplayMode())

Sources/StreamChatSwiftUI/DefaultViewFactory.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ extension ViewFactory {
271271
DefaultChannelHeaderModifier(channel: channel)
272272
}
273273

274+
public func makeChannelLoadingView() -> some View {
275+
LoadingView()
276+
}
277+
274278
public func makeMessageThreadHeaderViewModifier() -> some MessageThreadHeaderViewModifier {
275279
DefaultMessageThreadHeaderModifier()
276280
}

Sources/StreamChatSwiftUI/ViewFactory.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ public protocol ViewFactory: AnyObject {
252252
/// Creates the channel header view modifier.
253253
/// - Parameter channel: the displayed channel.
254254
func makeChannelHeaderViewModifier(for channel: ChatChannel) -> ChatHeaderViewModifier
255+
256+
associatedtype ChannelLoadingViewType: View
257+
/// Creates a loading view for the channel.
258+
func makeChannelLoadingView() -> ChannelLoadingViewType
255259

256260
associatedtype ThreadHeaderViewModifier: MessageThreadHeaderViewModifier
257261
/// Creates the message thread header view modifier.

StreamChatSwiftUITests/Tests/Utils/ViewFactory_Tests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,17 @@ class ViewFactory_Tests: StreamChatTestCase {
901901
// Then
902902
XCTAssert(view is LockedView)
903903
}
904+
905+
func test_viewFactory_makeChannelLoadingView() {
906+
// Given
907+
let viewFactory = DefaultViewFactory.shared
908+
909+
// When
910+
let view = viewFactory.makeChannelLoadingView()
911+
912+
// Then
913+
XCTAssert(view is LoadingView)
914+
}
904915
}
905916

906917
extension ChannelAction: Equatable {

0 commit comments

Comments
 (0)