Merge remote-tracking branch 'origin/feat/pin-message' into feat/pin-message

This commit is contained in:
Sahil Kumar
2021-02-19 18:17:09 +05:30
2 changed files with 44 additions and 25 deletions
@@ -67,6 +67,8 @@ class StreamExample extends StatelessWidget {
/// [ChannelListCore] is a `builder` with callbacks for constructing UIs based /// [ChannelListCore] is a `builder` with callbacks for constructing UIs based
/// on different scenarios. /// on different scenarios.
class HomeScreen extends StatelessWidget { class HomeScreen extends StatelessWidget {
final channelListController = ChannelListController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@@ -75,6 +77,15 @@ class HomeScreen extends StatelessWidget {
), ),
body: ChannelsBloc( body: ChannelsBloc(
child: ChannelListCore( child: ChannelListCore(
channelListController: channelListController,
filter: {
'type': 'messaging',
'members': {
r'$in': [
StreamChatCore.of(context).user.id,
]
}
},
emptyBuilder: (BuildContext context) { emptyBuilder: (BuildContext context) {
return Center( return Center(
child: Text('Looks like you are not in any channels'), child: Text('Looks like you are not in any channels'),
@@ -99,7 +110,11 @@ class HomeScreen extends StatelessWidget {
BuildContext context, BuildContext context,
List<Channel> channels, List<Channel> channels,
) => ) =>
ListView.builder( LazyLoadScrollView(
onEndOfPage: () async {
channelListController.paginateData();
},
child: ListView.builder(
itemCount: channels.length, itemCount: channels.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
final _item = channels[index]; final _item = channels[index];
@@ -127,6 +142,7 @@ class HomeScreen extends StatelessWidget {
), ),
), ),
), ),
),
); );
} }
} }
@@ -64,7 +64,10 @@ class ChannelListCore extends StatefulWidget {
this.filter, this.filter,
this.options, this.options,
this.sort, this.sort,
this.pagination, this.pagination = const PaginationParams(
offset: 0,
limit: 25,
),
this.channelListController, this.channelListController,
}) : assert(errorBuilder != null), }) : assert(errorBuilder != null),
assert(emptyBuilder != null), assert(emptyBuilder != null),