From df9a854cb0ef2c2f680d91ff0c24cf9add66d94b Mon Sep 17 00:00:00 2001 From: nyne Date: Thu, 3 Oct 2024 17:39:16 +0800 Subject: [PATCH] category options --- lib/components/comic.dart | 22 ++++++++++++++++++---- lib/pages/category_comics_page.dart | 22 +++++++++------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/lib/components/comic.dart b/lib/components/comic.dart index b75f9ba..9fdd82c 100644 --- a/lib/components/comic.dart +++ b/lib/components/comic.dart @@ -499,12 +499,22 @@ String? isBlocked(Comic item) { } class ComicList extends StatefulWidget { - const ComicList({super.key, this.loadPage, this.loadNext}); + const ComicList({ + super.key, + this.loadPage, + this.loadNext, + this.leadingSliver, + this.trailingSliver, + }); final Future>> Function(int page)? loadPage; final Future>> Function(String? next)? loadNext; + final Widget? leadingSliver; + + final Widget? trailingSliver; + @override State createState() => _ComicListState(); } @@ -567,16 +577,18 @@ class _ComicListState extends State { onPressed: () { Navigator.of(context).pop(); var page = int.tryParse(value); - if(page == null) { + if (page == null) { context.showMessage(message: "Invalid page".tl); } else { - if(page > 0 && (maxPage == null || page <= maxPage!)) { + if (page > 0 && + (maxPage == null || page <= maxPage!)) { setState(() { error = null; this.page = page; }); } else { - context.showMessage(message: "Invalid page".tl); + context.showMessage( + message: "Invalid page".tl); } } }, @@ -702,9 +714,11 @@ class _ComicListState extends State { } return SmoothCustomScrollView( slivers: [ + if (widget.leadingSliver != null) widget.leadingSliver!, buildSliverPageSelector(), SliverGridComics(comics: data[page] ?? const []), buildSliverPageSelector(), + if (widget.trailingSliver != null) widget.trailingSliver!, ], ); } diff --git a/lib/pages/category_comics_page.dart b/lib/pages/category_comics_page.dart index 0b69a7e..fb0317e 100644 --- a/lib/pages/category_comics_page.dart +++ b/lib/pages/category_comics_page.dart @@ -58,19 +58,15 @@ class _CategoryComicsPageState extends State { appBar: Appbar( title: Text(widget.category), ), - body: Column( - children: [ - Expanded( - child: ComicList( - loadPage: (i) => data.load( - widget.category, - widget.param, - optionsValue, - i, - ), - ), - ), - ], + body: ComicList( + key: Key(widget.category + optionsValue.toString()), + leadingSliver: buildOptions(), + loadPage: (i) => data.load( + widget.category, + widget.param, + optionsValue, + i, + ), ), ); }