Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions packages/stream_chat_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Upcoming

✅ Added

- Added floatingDateDividerBuilder to StreamMessageListView and FloatingDateDivider.
Comment thread
xsahil03x marked this conversation as resolved.
Outdated

🐞 Fixed

- Fixed `StreamMessageListView` not marking thread messages as read when scrolled to the bottom of the list.
Expand Down
Comment thread
xsahil03x marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FloatingDateDivider extends StatelessWidget {
required this.itemCount,
@Deprecated('No longer used, Will be removed in future versions.')
this.isThreadConversation = false,
this.dateDividerBuilder,
this.floatingDateDividerBuilder,
});

/// true if this is a thread conversation
Expand All @@ -43,7 +43,7 @@ class FloatingDateDivider extends StatelessWidget {
///
/// If provided, this function will be called with the date of the message
/// to create the date divider widget.
final Widget Function(DateTime)? dateDividerBuilder;
final Widget Function(DateTime)? floatingDateDividerBuilder;

@override
Widget build(BuildContext context) {
Expand All @@ -67,7 +67,7 @@ class FloatingDateDivider extends StatelessWidget {
final message = messages.elementAtOrNull(index - 2);
if (message == null) return const Empty();

if (dateDividerBuilder case final builder?) {
if (floatingDateDividerBuilder case final builder?) {
return builder.call(message.createdAt.toLocal());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class StreamMessageListView extends StatefulWidget {
this.threadBuilder,
this.onThreadTap,
this.dateDividerBuilder,
this.floatingDateDividerBuilder,
// we need to use ClampingScrollPhysics to avoid the list view to bounce
// when we are at the either end of the list view and try to use 'animateTo'
// to animate in the same direction.
Expand Down Expand Up @@ -241,6 +242,10 @@ class StreamMessageListView extends StatefulWidget {
/// Builder used to render date dividers
final Widget Function(DateTime)? dateDividerBuilder;

/// Builder used to render floating date divider separately from
/// the date dividers in the list
final Widget Function(DateTime)? floatingDateDividerBuilder;

/// Index of an item to initially align within the viewport.
final int? initialScrollIndex;

Expand Down Expand Up @@ -852,7 +857,7 @@ class _StreamMessageListViewState extends State<StreamMessageListView> {
reverse: widget.reverse,
itemPositionListener: _itemPositionListener.itemPositions,
messages: messages,
dateDividerBuilder: widget.dateDividerBuilder,
floatingDateDividerBuilder: widget.floatingDateDividerBuilder,
Comment thread
xsahil03x marked this conversation as resolved.
Outdated
Comment thread
xsahil03x marked this conversation as resolved.
Outdated
),
),
if (widget.showScrollToBottom)
Expand Down
Comment thread
xsahil03x marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void main() {
);

testWidgets(
'renders custom dateDividerBuilder when provided',
'renders custom floatingDateDividerBuilder when provided',
(tester) async {
itemPositionListener.value = [
const ItemPosition(
Expand All @@ -160,7 +160,7 @@ void main() {
reverse: false,
messages: messages,
itemCount: itemCount,
dateDividerBuilder: (date) {
floatingDateDividerBuilder: (date) {
receivedDate = date;
return Container(
key: customKey,
Expand Down
Loading