From 5a14ea48c1e784b90e59d3bfc880b8e9df6827be Mon Sep 17 00:00:00 2001 From: nyne Date: Thu, 7 Nov 2024 09:02:03 +0800 Subject: [PATCH] fix changing search target in search result page --- lib/pages/search_result_page.dart | 39 +++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/pages/search_result_page.dart b/lib/pages/search_result_page.dart index 19d2105..1d67e5f 100644 --- a/lib/pages/search_result_page.dart +++ b/lib/pages/search_result_page.dart @@ -42,7 +42,7 @@ class _SearchResultPageState extends State { void search([String? text]) { if (text != null) { - if(suggestionsController.entry != null) { + if (suggestionsController.entry != null) { suggestionsController.remove(); } setState(() { @@ -135,20 +135,24 @@ class _SearchResultPageState extends State { onChanged: onChanged, action: buildAction(), ), - loadPage: source!.searchPageData!.loadPage == null ? null : (i) { - return source.searchPageData!.loadPage!( - text, - i, - options, - ); - }, - loadNext: source.searchPageData!.loadNext == null ? null : (i) { - return source.searchPageData!.loadNext!( - text, - i, - options, - ); - }, + loadPage: source!.searchPageData!.loadPage == null + ? null + : (i) { + return source.searchPageData!.loadPage!( + text, + i, + options, + ); + }, + loadNext: source.searchPageData!.loadNext == null + ? null + : (i) { + return source.searchPageData!.loadNext!( + text, + i, + options, + ); + }, ); } @@ -424,6 +428,11 @@ class _SearchSettingsDialogState extends State<_SearchSettingsDialog> { setState(() { searchTarget = e.key; options.clear(); + final searchOptions = ComicSource.find(searchTarget)! + .searchPageData! + .searchOptions ?? + []; + options = searchOptions.map((e) => e.defaultValue).toList(); onChanged(); }); },