Skip to content

Commit 8f0ac18

Browse files
authored
Make message spacing in message list configurable (#830)
1 parent b10a9f4 commit 8f0ac18

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

66
### ✅ Added
77
- Add extra data to user display info [#819](https://github.com/GetStream/stream-chat-swiftui/pull/819)
8+
- Make message spacing in message list configurable [#830](https://github.com/GetStream/stream-chat-swiftui/pull/830)
89
### 🐞 Fixed
910
- Fix swipe to reply enabled when quoting a message is disabled [#824](https://github.com/GetStream/stream-chat-swiftui/pull/824)
1011
- Fix mark unread action not removed when read events are disabled [#823](https://github.com/GetStream/stream-chat-swiftui/pull/823)

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageContainerView.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
3333
@GestureState private var offset: CGSize = .zero
3434

3535
private let replyThreshold: CGFloat = 60
36-
private let paddingValue: CGFloat = 8
36+
private var paddingValue: CGFloat {
37+
utils.messageListConfig.messagePaddings.singleBottom
38+
}
39+
private var groupMessageInterItemSpacing: CGFloat {
40+
utils.messageListConfig.messagePaddings.groupBottom
41+
}
3742

3843
var isSwipeToReplyPossible: Bool {
3944
message.isInteractionEnabled && channel.canQuoteMessage
@@ -275,7 +280,7 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
275280
topReactionsShown && !isMessagePinned ? messageListConfig.messageDisplayOptions.reactionsTopPadding(message) : 0
276281
)
277282
.padding(.horizontal, messageListConfig.messagePaddings.horizontal)
278-
.padding(.bottom, showsAllInfo || isMessagePinned ? paddingValue : 2)
283+
.padding(.bottom, showsAllInfo || isMessagePinned ? paddingValue : groupMessageInterItemSpacing)
279284
.padding(.top, isLast ? paddingValue : 0)
280285
.background(isMessagePinned ? Color(colors.pinnedBackground) : nil)
281286
.padding(.bottom, isMessagePinned ? paddingValue / 2 : 0)

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,19 @@ public struct MessagePaddings {
110110
/// Horizontal padding for messages.
111111
public let horizontal: CGFloat
112112
public let quotedViewPadding: CGFloat
113+
public let singleBottom: CGFloat
114+
public let groupBottom: CGFloat
113115

114116
public init(
115117
horizontal: CGFloat = 8,
116-
quotedViewPadding: CGFloat = 8
118+
quotedViewPadding: CGFloat = 8,
119+
singleBottom: CGFloat = 8,
120+
groupBottom: CGFloat = 2
117121
) {
118122
self.horizontal = horizontal
119123
self.quotedViewPadding = quotedViewPadding
124+
self.singleBottom = singleBottom
125+
self.groupBottom = groupBottom
120126
}
121127
}
122128

0 commit comments

Comments
 (0)