feat(ui): add paginationLoadingIndicatorBuilder in MessageListView.
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
- Added `MessageInput.customOverlays` property to add custom overlays to the message input.
|
- Added `MessageInput.customOverlays` property to add custom overlays to the message input.
|
||||||
- Added `MessageInput.mentionAllAppUsers` property to mention all app users in the message input.
|
- Added `MessageInput.mentionAllAppUsers` property to mention all app users in the message input.
|
||||||
- The `MessageInput` now supports local search for channels with less than 100 members.
|
- The `MessageInput` now supports local search for channels with less than 100 members.
|
||||||
|
- Added `MessageListView.paginationLoadingIndicatorBuilder` to override the default loading indicator shown while paginating the message list.
|
||||||
|
|
||||||
⚠️ Deprecated
|
⚠️ Deprecated
|
||||||
|
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ class MessageListView extends StatefulWidget {
|
|||||||
this.messageListController,
|
this.messageListController,
|
||||||
this.reverse = true,
|
this.reverse = true,
|
||||||
this.paginationLimit = 20,
|
this.paginationLimit = 20,
|
||||||
|
this.paginationLoadingIndicatorBuilder,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// Function used to build a custom message widget
|
/// Function used to build a custom message widget
|
||||||
@@ -284,6 +285,9 @@ class MessageListView extends StatefulWidget {
|
|||||||
/// Use [ChannelListController.paginateData] pagination.
|
/// Use [ChannelListController.paginateData] pagination.
|
||||||
final MessageListController? messageListController;
|
final MessageListController? messageListController;
|
||||||
|
|
||||||
|
/// Builder used to build the loading indicator shown while paginating.
|
||||||
|
final WidgetBuilder? paginationLoadingIndicatorBuilder;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_MessageListViewState createState() => _MessageListViewState();
|
_MessageListViewState createState() => _MessageListViewState();
|
||||||
}
|
}
|
||||||
@@ -572,17 +576,22 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final indicatorBuilder =
|
||||||
|
widget.paginationLoadingIndicatorBuilder;
|
||||||
|
|
||||||
if (i == itemCount - 3) {
|
if (i == itemCount - 3) {
|
||||||
return _buildLoadingIndicator(
|
return _loadingIndicator(
|
||||||
streamChannel!,
|
streamChannel!,
|
||||||
QueryDirection.top,
|
QueryDirection.top,
|
||||||
|
indicatorBuilder: indicatorBuilder,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
return _buildLoadingIndicator(
|
return _loadingIndicator(
|
||||||
streamChannel!,
|
streamChannel!,
|
||||||
QueryDirection.bottom,
|
QueryDirection.bottom,
|
||||||
|
indicatorBuilder: indicatorBuilder,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -816,15 +825,17 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildLoadingIndicator(
|
Widget _loadingIndicator(
|
||||||
StreamChannelState streamChannel,
|
StreamChannelState streamChannel,
|
||||||
QueryDirection direction,
|
QueryDirection direction, {
|
||||||
) =>
|
WidgetBuilder? indicatorBuilder,
|
||||||
|
}) =>
|
||||||
_LoadingIndicator(
|
_LoadingIndicator(
|
||||||
direction: direction,
|
direction: direction,
|
||||||
streamTheme: _streamTheme,
|
streamTheme: _streamTheme,
|
||||||
streamChannel: streamChannel,
|
streamChannel: streamChannel,
|
||||||
isThreadConversation: _isThreadConversation,
|
isThreadConversation: _isThreadConversation,
|
||||||
|
indicatorBuilder: indicatorBuilder,
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildBottomMessage(
|
Widget _buildBottomMessage(
|
||||||
@@ -1290,12 +1301,14 @@ class _LoadingIndicator extends StatelessWidget {
|
|||||||
required this.isThreadConversation,
|
required this.isThreadConversation,
|
||||||
required this.direction,
|
required this.direction,
|
||||||
required this.streamChannel,
|
required this.streamChannel,
|
||||||
|
this.indicatorBuilder,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final StreamChatThemeData streamTheme;
|
final StreamChatThemeData streamTheme;
|
||||||
final bool isThreadConversation;
|
final bool isThreadConversation;
|
||||||
final QueryDirection direction;
|
final QueryDirection direction;
|
||||||
final StreamChannelState streamChannel;
|
final StreamChannelState streamChannel;
|
||||||
|
final WidgetBuilder? indicatorBuilder;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -1314,12 +1327,13 @@ class _LoadingIndicator extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
builder: (context, data) {
|
builder: (context, data) {
|
||||||
if (!data) return const Offstage();
|
if (!data) return const Offstage();
|
||||||
return const Center(
|
return indicatorBuilder?.call(context) ??
|
||||||
child: Padding(
|
const Center(
|
||||||
padding: EdgeInsets.all(8),
|
child: Padding(
|
||||||
child: CircularProgressIndicator(),
|
padding: EdgeInsets.all(8),
|
||||||
),
|
child: CircularProgressIndicator(),
|
||||||
);
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user