Skip to content

Make message spacing in message list configurable #830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### ✅ Added
- Add extra data to user display info [#819](https://github.com/GetStream/stream-chat-swiftui/pull/819)
- Make message spacing in message list configurable [#830](https://github.com/GetStream/stream-chat-swiftui/pull/830)
### 🐞 Fixed
- Fix swipe to reply enabled when quoting a message is disabled [#824](https://github.com/GetStream/stream-chat-swiftui/pull/824)
- Fix mark unread action not removed when read events are disabled [#823](https://github.com/GetStream/stream-chat-swiftui/pull/823)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
@GestureState private var offset: CGSize = .zero

private let replyThreshold: CGFloat = 60
private let paddingValue: CGFloat = 8
private var paddingValue: CGFloat {
utils.messageListConfig.messagePaddings.singleBottom
}
private var groupMessageInterItemSpacing: CGFloat {
utils.messageListConfig.messagePaddings.groupBottom
}

var isSwipeToReplyPossible: Bool {
message.isInteractionEnabled && channel.canQuoteMessage
Expand Down Expand Up @@ -275,7 +280,7 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
topReactionsShown && !isMessagePinned ? messageListConfig.messageDisplayOptions.reactionsTopPadding(message) : 0
)
.padding(.horizontal, messageListConfig.messagePaddings.horizontal)
.padding(.bottom, showsAllInfo || isMessagePinned ? paddingValue : 2)
.padding(.bottom, showsAllInfo || isMessagePinned ? paddingValue : groupMessageInterItemSpacing)
.padding(.top, isLast ? paddingValue : 0)
.background(isMessagePinned ? Color(colors.pinnedBackground) : nil)
.padding(.bottom, isMessagePinned ? paddingValue / 2 : 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,19 @@ public struct MessagePaddings {
/// Horizontal padding for messages.
public let horizontal: CGFloat
public let quotedViewPadding: CGFloat
public let singleBottom: CGFloat
public let groupBottom: CGFloat

public init(
horizontal: CGFloat = 8,
quotedViewPadding: CGFloat = 8
quotedViewPadding: CGFloat = 8,
singleBottom: CGFloat = 8,
groupBottom: CGFloat = 2
) {
self.horizontal = horizontal
self.quotedViewPadding = quotedViewPadding
self.singleBottom = singleBottom
self.groupBottom = groupBottom
}
}

Expand Down
Loading