Skip to content

Commit

Permalink
Update to set a value for the gap between message groups (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
seunghyeoks authored Aug 12, 2024
1 parent ad165ec commit 9744437
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/src/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ List<Object> calculateChatMessages(
bool dateIsUtc = false,
String? dateLocale,
required int groupMessagesThreshold,
double messagesSpacerHeight = 12,
String? lastReadMessageId,
required bool showUserNames,
DateFormat? timeFormat,
Expand Down Expand Up @@ -217,7 +218,7 @@ List<Object> calculateChatMessages(
chatMessages.insert(
0,
MessageSpacer(
height: 12,
height: messagesSpacerHeight,
id: message.id,
),
);
Expand Down
6 changes: 6 additions & 0 deletions lib/src/widgets/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Chat extends StatefulWidget {
this.emptyState,
this.fileMessageBuilder,
this.groupMessagesThreshold = 60000,
this.messagesSpacerHeight = 12,
this.hideBackgroundOnEmojiMessages = true,
this.imageGalleryOptions = const ImageGalleryOptions(
maxScale: PhotoViewComputedScale.covered,
Expand Down Expand Up @@ -176,6 +177,10 @@ class Chat extends StatefulWidget {
/// is lower than this threshold, they will be visually grouped.
final int groupMessagesThreshold;

/// Height value of spacers added to separate message groups.
/// Default value is 12. If 0, no gap between groups.
final double messagesSpacerHeight;

/// See [Message.hideBackgroundOnEmojiMessages].
final bool hideBackgroundOnEmojiMessages;

Expand Down Expand Up @@ -594,6 +599,7 @@ class ChatState extends State<Chat> {
lastReadMessageId: widget.scrollToUnreadOptions.lastReadMessageId,
showUserNames: widget.showUserNames,
timeFormat: widget.timeFormat,
messagesSpacerHeight: widget.messagesSpacerHeight,
);

_chatMessages = result[0] as List<Object>;
Expand Down

0 comments on commit 9744437

Please sign in to comment.