File tree Expand file tree Collapse file tree 4 files changed +23
-2
lines changed
Sources/StreamChatSwiftUI/Utils
StreamChatSwiftUITests/Tests/ChatChannel
__Snapshots__/MessageListView_Tests Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6
6
### ✅ Added
7
7
- Configuration for stack based navigation for iPads
8
8
- Customization of the reactions background
9
+ - Possibility to add custom snapshot generation logic
9
10
10
11
# [ 4.21.0] ( https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.21.0 )
11
12
_ September 02, 2022_
Original file line number Diff line number Diff line change @@ -21,10 +21,14 @@ public class DefaultSnapshotCreator: SnapshotCreator {
21
21
public init ( ) { /* Public init. */ }
22
22
23
23
public func makeSnapshot( for view: AnyView ) -> UIImage {
24
- let currentSnapshot : UIImage ?
25
- guard let view: UIView = topVC ( ) ? . view else {
24
+ guard let uiView: UIView = topVC ( ) ? . view else {
26
25
return images. snapshot
27
26
}
27
+ return makeSnapshot ( from: uiView)
28
+ }
29
+
30
+ func makeSnapshot( from view: UIView ) -> UIImage {
31
+ let currentSnapshot : UIImage ?
28
32
UIGraphicsBeginImageContext ( view. frame. size)
29
33
if let currentGraphicsContext = UIGraphicsGetCurrentContext ( ) {
30
34
view. layer. render ( in: currentGraphicsContext)
Original file line number Diff line number Diff line change @@ -60,6 +60,22 @@ class MessageListView_Tests: StreamChatTestCase {
60
60
assertSnapshot ( matching: messageListView, as: . image)
61
61
}
62
62
63
+ func test_messageListView_snapshot( ) {
64
+ // Given
65
+ let channelConfig = ChannelConfig ( reactionsEnabled: true )
66
+ let messageListView = makeMessageListView ( channelConfig: channelConfig)
67
+ . applyDefaultSize ( )
68
+
69
+ // When
70
+ let snapshotCreator = DefaultSnapshotCreator ( )
71
+ let viewController = UIHostingController ( rootView: messageListView)
72
+ let snapshot = snapshotCreator. makeSnapshot ( from: viewController. view)
73
+ let view = Image ( uiImage: snapshot)
74
+
75
+ // Then
76
+ assertSnapshot ( matching: view, as: . image)
77
+ }
78
+
63
79
func test_messageListView_snapshotFallback( ) {
64
80
// Given
65
81
let channelConfig = ChannelConfig ( reactionsEnabled: true )
You can’t perform that action at this time.
0 commit comments