[UI-Kit -> ChannelListCore] Replace ChannelListController function signature with AsyncCallback for better refreshIndicator support.
Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
@@ -180,15 +180,13 @@ class _ChannelListViewState extends State<ChannelListView> {
|
|||||||
|
|
||||||
if (widget.pullToRefresh) {
|
if (widget.pullToRefresh) {
|
||||||
child = RefreshIndicator(
|
child = RefreshIndicator(
|
||||||
onRefresh: () async => _channelListController.loadData(),
|
onRefresh: () => _channelListController.loadData(),
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return LazyLoadScrollView(
|
return LazyLoadScrollView(
|
||||||
onEndOfPage: () async {
|
onEndOfPage: () => _channelListController.paginateData(),
|
||||||
_channelListController.paginateData();
|
|
||||||
},
|
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -451,9 +449,7 @@ class _ChannelListViewState extends State<ChannelListView> {
|
|||||||
style: Theme.of(context).textTheme.headline6,
|
style: Theme.of(context).textTheme.headline6,
|
||||||
),
|
),
|
||||||
FlatButton(
|
FlatButton(
|
||||||
onPressed: () {
|
onPressed: () => _channelListController.loadData(),
|
||||||
_channelListController.loadData();
|
|
||||||
},
|
|
||||||
child: Text('Retry'),
|
child: Text('Retry'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -159,10 +159,9 @@ class _ChannelListCoreState extends State<ChannelListCore> {
|
|||||||
return widget.errorBuilder(context, snapshot.error);
|
return widget.errorBuilder(context, snapshot.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadData() {
|
Future<void> loadData() {
|
||||||
final channelsBloc = ChannelsBloc.of(context);
|
final channelsBloc = ChannelsBloc.of(context);
|
||||||
|
return channelsBloc.queryChannels(
|
||||||
channelsBloc.queryChannels(
|
|
||||||
filter: widget.filter,
|
filter: widget.filter,
|
||||||
sortOptions: widget.sort,
|
sortOptions: widget.sort,
|
||||||
paginationParams: widget.pagination,
|
paginationParams: widget.pagination,
|
||||||
@@ -170,10 +169,9 @@ class _ChannelListCoreState extends State<ChannelListCore> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void paginateData() {
|
Future<void> paginateData() {
|
||||||
final channelsBloc = ChannelsBloc.of(context);
|
final channelsBloc = ChannelsBloc.of(context);
|
||||||
|
return channelsBloc.queryChannels(
|
||||||
channelsBloc.queryChannels(
|
|
||||||
filter: widget.filter,
|
filter: widget.filter,
|
||||||
sortOptions: widget.sort,
|
sortOptions: widget.sort,
|
||||||
paginationParams: widget.pagination.copyWith(
|
paginationParams: widget.pagination.copyWith(
|
||||||
@@ -229,10 +227,10 @@ class _ChannelListCoreState extends State<ChannelListCore> {
|
|||||||
class ChannelListController {
|
class ChannelListController {
|
||||||
/// This function calls Stream's servers to load a list of channels. If there is existing data,
|
/// This function calls Stream's servers to load a list of channels. If there is existing data,
|
||||||
/// calling this function causes a reload.
|
/// calling this function causes a reload.
|
||||||
VoidCallback loadData;
|
AsyncCallback loadData;
|
||||||
|
|
||||||
/// This function is used to load another page of data. Note, [loadData] should be
|
/// This function is used to load another page of data. Note, [loadData] should be
|
||||||
/// used to populate the initial page of data. Calling [paginateData] performs a query
|
/// used to populate the initial page of data. Calling [paginateData] performs a query
|
||||||
/// to load subsequent pages.
|
/// to load subsequent pages.
|
||||||
VoidCallback paginateData;
|
AsyncCallback paginateData;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user