improve explore page loading

This commit is contained in:
2024-12-10 14:45:48 +08:00
parent 659b211038
commit 07f8cd2455
2 changed files with 56 additions and 9 deletions

View File

@@ -832,6 +832,7 @@ class ComicList extends StatefulWidget {
this.errorLeading,
this.menuBuilder,
this.controller,
this.refreshHandlerCallback,
});
final Future<Res<List<Comic>>> Function(int page)? loadPage;
@@ -848,6 +849,8 @@ class ComicList extends StatefulWidget {
final ScrollController? controller;
final void Function(VoidCallback c)? refreshHandlerCallback;
@override
State<ComicList> createState() => ComicListState();
}
@@ -892,10 +895,22 @@ class ComicListState extends State<ComicList> {
PageStorage.of(context).writeState(context, state);
}
void refresh() {
_data.clear();
_page = 1;
_maxPage = null;
_error = null;
_nextUrl = null;
_loading.clear();
storeState();
setState(() {});
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
restoreState(PageStorage.of(context).readState(context));
widget.refreshHandlerCallback?.call(refresh);
}
void remove(Comic c) {