Skip to content

Commit 0870150

Browse files
Added possibility to customize message transition
1 parent 2fc6954 commit 0870150

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageContainerView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ struct MessageContainerView<Factory: ViewFactory>: View {
181181
.padding(.top, isLast ? paddingValue : 0)
182182
.background(isMessagePinned ? Color(colors.pinnedBackground) : nil)
183183
.padding(.bottom, isMessagePinned ? paddingValue / 2 : 0)
184+
.transition(
185+
message.isSentByCurrentUser ?
186+
messageListConfig.messageDisplayOptions.currentUserMessageTransition :
187+
messageListConfig.messageDisplayOptions.otherUserMessageTransition
188+
)
184189
}
185190

186191
private var isMessagePinned: Bool {

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import CoreGraphics
66
import StreamChat
7+
import SwiftUI
78

89
/// Configuration for the message list.
910
public struct MessageListConfig {
@@ -67,15 +68,21 @@ public struct MessageDisplayOptions {
6768
let showAvatars: Bool
6869
let showMessageDate: Bool
6970
let animateChanges: Bool
71+
let currentUserMessageTransition: AnyTransition
72+
let otherUserMessageTransition: AnyTransition
7073

7174
public init(
7275
showAvatars: Bool = true,
7376
showMessageDate: Bool = true,
74-
animateChanges: Bool = true
77+
animateChanges: Bool = true,
78+
currentUserMessageTransition: AnyTransition = .identity,
79+
otherUserMessageTransition: AnyTransition = .identity
7580
) {
7681
self.showAvatars = showAvatars
7782
self.showMessageDate = showMessageDate
7883
self.animateChanges = animateChanges
84+
self.currentUserMessageTransition = currentUserMessageTransition
85+
self.otherUserMessageTransition = otherUserMessageTransition
7986
}
8087
}
8188

0 commit comments

Comments
 (0)