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,31 +110,36 @@ class HomeScreen extends StatelessWidget {
BuildContext context, BuildContext context,
List<Channel> channels, List<Channel> channels,
) => ) =>
ListView.builder( LazyLoadScrollView(
itemCount: channels.length, onEndOfPage: () async {
itemBuilder: (BuildContext context, int index) { channelListController.paginateData();
final _item = channels[index];
return ListTile(
title: Text(_item.name),
subtitle: Text(_item.state.lastMessage.text),
onTap: () {
/// Display a list of messages when the user taps on an item.
/// We can use [StreamChannel] to wrap our [MessageScreen] screen
/// with the selected channel.
///
/// This allows us to use a built-in inherited widget for accessing
/// our `channel` later on.
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => StreamChannel(
channel: _item,
child: MessageScreen(),
),
),
);
},
);
}, },
child: ListView.builder(
itemCount: channels.length,
itemBuilder: (BuildContext context, int index) {
final _item = channels[index];
return ListTile(
title: Text(_item.name),
subtitle: Text(_item.state.lastMessage.text),
onTap: () {
/// Display a list of messages when the user taps on an item.
/// We can use [StreamChannel] to wrap our [MessageScreen] screen
/// with the selected channel.
///
/// This allows us to use a built-in inherited widget for accessing
/// our `channel` later on.
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => StreamChannel(
channel: _item,
child: MessageScreen(),
),
),
);
},
);
},
),
), ),
), ),
), ),
@@ -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),