From ea93aa144e22dad38dde692eb85415cb49c1d9ad Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 6 Dec 2025 19:47:36 +0800 Subject: [PATCH] :bug: Fix some bugs in post search UI --- lib/screens/posts/post_search.dart | 76 ++++++++++++++---------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/lib/screens/posts/post_search.dart b/lib/screens/posts/post_search.dart index 6ab96e20..af14dfe9 100644 --- a/lib/screens/posts/post_search.dart +++ b/lib/screens/posts/post_search.dart @@ -79,43 +79,21 @@ class PostSearchScreen extends HookConsumerWidget { return AppScaffold( isNoBackground: false, - appBar: isWideScreen(context) - ? null - : AppBar( - title: Row( - children: [ - Expanded( - child: TextField( - controller: searchController, - decoration: InputDecoration( - hintText: 'search'.tr(), - border: InputBorder.none, - hintStyle: TextStyle( - color: Theme.of(context).appBarTheme.foregroundColor, - ), - ), - style: TextStyle( - color: Theme.of(context).appBarTheme.foregroundColor, - ), - onChanged: onSearchChanged, - onSubmitted: (value) { - onSearchChanged(value, skipDebounce: true); - }, - autofocus: true, - ), - ), - IconButton( - icon: Icon( - showFilters.value - ? Icons.filter_alt - : Icons.filter_alt_outlined, - ), - onPressed: toggleFilterDisplay, - tooltip: 'toggleFilters'.tr(), - ), - ], + appBar: AppBar( + title: Text('searchPosts'.tr()), + actions: [ + if (!isWideScreen(context)) + IconButton( + icon: Icon( + showFilters.value + ? Icons.filter_alt + : Icons.filter_alt_outlined, ), + onPressed: toggleFilterDisplay, + tooltip: 'toggleFilters'.tr(), ), + ], + ), body: Consumer( builder: (context, ref, child) { final searchState = ref.watch( @@ -152,10 +130,7 @@ class PostSearchScreen extends HookConsumerWidget { ), ), ), - const SliverGap(16), - if (showFilters.value && !isWideScreen(context)) - SliverToBoxAdapter(child: buildFilterPanel()), - // Use PaginationList with isSliver=true + const SliverGap(12), PaginationList( provider: postListProvider( PostListQueryConfig(id: kSearchPostListId), @@ -246,6 +221,28 @@ class PostSearchScreen extends HookConsumerWidget { ) : CustomScrollView( slivers: [ + const SliverGap(4), + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), + child: SearchBar( + elevation: WidgetStateProperty.all(4), + controller: searchController, + hintText: 'search'.tr(), + leading: const Icon(Icons.search), + padding: WidgetStateProperty.all( + const EdgeInsets.symmetric(horizontal: 24), + ), + onChanged: onSearchChanged, + onSubmitted: (value) { + onSearchChanged(value, skipDebounce: true); + }, + ), + ), + ), if (showFilters.value) SliverToBoxAdapter( child: Center( @@ -255,7 +252,6 @@ class PostSearchScreen extends HookConsumerWidget { ), ), ), - // Use PaginationList with isSliver=true PaginationList( provider: postListProvider( PostListQueryConfig(id: kSearchPostListId),