diff --git a/lib/api/client.dart b/lib/api/client.dart index 85a29d6..13885d2 100644 --- a/lib/api/client.dart +++ b/lib/api/client.dart @@ -150,6 +150,8 @@ abstract class _EHApi { @Query("offset") int? offset, @Query("limit") int? limit, @Query("sort_by_gid") bool? sortByGid, + @Query("uploader") String? uploader, + @Query("tag") String? tag, @CancelRequest() CancelToken? cancel}); @GET('/tag/{id}') diff --git a/lib/api/client.g.dart b/lib/api/client.g.dart index da14bb8..2e516d3 100644 --- a/lib/api/client.g.dart +++ b/lib/api/client.g.dart @@ -531,6 +531,8 @@ class __EHApi implements _EHApi { int? offset, int? limit, bool? sortByGid, + String? uploader, + String? tag, CancelToken? cancel, }) async { const _extra = {}; @@ -539,6 +541,8 @@ class __EHApi implements _EHApi { r'offset': offset, r'limit': limit, r'sort_by_gid': sortByGid, + r'uploader': uploader, + r'tag': tag, }; queryParameters.removeWhere((k, v) => v == null); final _headers = {}; diff --git a/lib/components/tag_tooltip.dart b/lib/components/tag_tooltip.dart index 286608f..2897d85 100644 --- a/lib/components/tag_tooltip.dart +++ b/lib/components/tag_tooltip.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import '../api/gallery.dart'; @@ -16,7 +17,13 @@ class TagTooltip extends StatelessWidget { @override Widget build(BuildContext context) { final name = _getTag(tag); - final t = SelectableText(name); + final t = InkWell( + onTap: () { + context.pushNamed("/galleries", queryParameters: { + "tag": [tag.tag] + }); + }, + child: Text(name)); return tag.intro != null && tag.intro!.isNotEmpty ? Tooltip( message: tag.intro!, diff --git a/lib/components/tags.dart b/lib/components/tags.dart index 2e07a8a..245b4c1 100644 --- a/lib/components/tags.dart +++ b/lib/components/tags.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:go_router/go_router.dart'; import '../api/gallery.dart'; import '../globals.dart'; import '../main.dart'; @@ -73,7 +74,13 @@ class _TagsPanel extends State { ), child: stt ? TagTooltip(ta[index - 1]!) - : SelectableText(ta[index - 1]!.tag)); + : InkWell( + onTap: () { + context.pushNamed("/galleries", queryParameters: { + "tag": [ta[index - 1]!.tag] + }); + }, + child: Text(ta[index - 1]!.tag))); } })); }); diff --git a/lib/galleries.dart b/lib/galleries.dart index f845b13..f9c008f 100644 --- a/lib/galleries.dart +++ b/lib/galleries.dart @@ -10,8 +10,11 @@ import 'globals.dart'; final _log = Logger("GalleriesPage"); class GalleriesPage extends StatefulWidget { - const GalleriesPage({Key? key, this.sortByGid}) : super(key: key); + const GalleriesPage({Key? key, this.sortByGid, this.uploader, this.tag}) + : super(key: key); final SortByGid? sortByGid; + final String? uploader; + final String? tag; static const String routeName = '/galleries'; @@ -30,7 +33,11 @@ class _GalleriesPage extends State with ThemeModeWidget { Future _fetchPage(int pageKey) async { try { final list = (await api.listGalleries( - offset: pageKey, limit: _pageSize, sortByGid: _sortByGid)) + offset: pageKey, + limit: _pageSize, + sortByGid: _sortByGid, + uploader: widget.uploader, + tag: widget.tag)) .unwrap(); final isLastPage = list.length < _pageSize; if (isLastPage) { @@ -73,9 +80,14 @@ class _GalleriesPage extends State with ThemeModeWidget { }).catchError((error) { _log.warning("Failed to save sortByGid to prefs:", error); }); - context.pushReplacementNamed("/galleries", queryParameters: { + var queryParameters = { "sortByGid": [v!.index.toString()], - }); + "tag": [widget.tag ?? ""], + "uploader": [widget.uploader ?? ""], + }; + queryParameters.removeWhere((k, v) => v[0].isEmpty); + context.pushReplacementNamed("/galleries", + queryParameters: queryParameters); } }, label: Text(AppLocalizations.of(context)!.sortByGid, diff --git a/lib/main.dart b/lib/main.dart index 75a0387..a135b3d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -55,7 +55,10 @@ final _router = GoRouter( } catch (e) { _routerLog.warning("Failed to load sortByGid from prefs:", e); } - return GalleriesPage(sortByGid: sortByGid); + final tag = state.uri.queryParameters["tag"]; + final uploader = state.uri.queryParameters["uploader"]; + return GalleriesPage( + sortByGid: sortByGid, tag: tag, uploader: uploader); }), GoRoute( path: GalleryPage.routeName,