Skip to content

Commit 8f9e99b

Browse files
Config to change the scrolling anchor (top/bottom) on messages
1 parent f771173 commit 8f9e99b

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
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+
- Config to change the scrolling anchor (top/bottom) on messages
78

89
# [4.25.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.25.0)
910
_December 16, 2022_

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public struct MessageListConfig {
2222
updateChannelsFromMessageList: Bool = false,
2323
maxTimeIntervalBetweenMessagesInGroup: TimeInterval = 60,
2424
cacheSizeOnChatDismiss: Int = 1024 * 1024 * 100,
25-
iPadSplitViewEnabled: Bool = true
25+
iPadSplitViewEnabled: Bool = true,
26+
scrollingAnchor: UnitPoint = .bottom
2627
) {
2728
self.messageListType = messageListType
2829
self.typingIndicatorPlacement = typingIndicatorPlacement
@@ -38,6 +39,7 @@ public struct MessageListConfig {
3839
self.maxTimeIntervalBetweenMessagesInGroup = maxTimeIntervalBetweenMessagesInGroup
3940
self.cacheSizeOnChatDismiss = cacheSizeOnChatDismiss
4041
self.iPadSplitViewEnabled = iPadSplitViewEnabled
42+
self.scrollingAnchor = scrollingAnchor
4143
}
4244

4345
public let messageListType: MessageListType
@@ -54,6 +56,7 @@ public struct MessageListConfig {
5456
public let maxTimeIntervalBetweenMessagesInGroup: TimeInterval
5557
public let cacheSizeOnChatDismiss: Int
5658
public let iPadSplitViewEnabled: Bool
59+
public let scrollingAnchor: UnitPoint
5760
}
5861

5962
/// Contains information about the message paddings.

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public struct MessageListView<Factory: ViewFactory>: View, KeyboardReadable {
203203
}
204204
}
205205
withAnimation {
206-
scrollView.scrollTo(scrolledId, anchor: .bottom)
206+
scrollView.scrollTo(scrolledId, anchor: messageListConfig.scrollingAnchor)
207207
}
208208
}
209209
}

0 commit comments

Comments
 (0)