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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
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.messageListItemSpacing
}
private var groupMessageInterItemSpacing: CGFloat {
utils.messageListConfig.messageGroupItemSpacing
}

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 @@ -35,7 +35,9 @@ public struct MessageListConfig {
userBlockingEnabled: Bool = false,
bouncedMessagesAlertActionsEnabled: Bool = true,
skipEditedMessageLabel: @escaping (ChatMessage) -> Bool = { _ in false },
draftMessagesEnabled: Bool = false
draftMessagesEnabled: Bool = false,
messageListItemSpacing: CGFloat = 8,
messageGroupItemSpacing: CGFloat = 2
) {
self.messageListType = messageListType
self.typingIndicatorPlacement = typingIndicatorPlacement
Expand Down Expand Up @@ -64,6 +66,8 @@ public struct MessageListConfig {
self.bouncedMessagesAlertActionsEnabled = bouncedMessagesAlertActionsEnabled
self.skipEditedMessageLabel = skipEditedMessageLabel
self.draftMessagesEnabled = draftMessagesEnabled
self.messageListItemSpacing = messageListItemSpacing
self.messageGroupItemSpacing = messageGroupItemSpacing
}

public let messageListType: MessageListType
Expand Down Expand Up @@ -102,6 +106,9 @@ public struct MessageListConfig {
///
/// If enabled, the SDK will save the message content as a draft when the user navigates away from the composer.
public let draftMessagesEnabled: Bool

public let messageListItemSpacing: CGFloat
public let messageGroupItemSpacing: CGFloat
}

/// Contains information about the message paddings.
Expand Down
Loading