From c99774e42b65c356408b7ef52e8281899b4320fd Mon Sep 17 00:00:00 2001 From: gitea Date: Wed, 19 Nov 2025 15:47:50 +0100 Subject: [PATCH] better search design --- lib/ui/recipes/recipes_screen.dart | 68 +++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/lib/ui/recipes/recipes_screen.dart b/lib/ui/recipes/recipes_screen.dart index fd71b1b..b10fed6 100644 --- a/lib/ui/recipes/recipes_screen.dart +++ b/lib/ui/recipes/recipes_screen.dart @@ -461,19 +461,55 @@ class _RecipesScreenState extends State with WidgetsBindingObserv Widget build(BuildContext context) { return Scaffold( appBar: AppBar( + toolbarHeight: (_isSearching && _selectedTags.isNotEmpty) ? 80 : null, title: _isSearching - ? TextField( - controller: _searchController, - autofocus: true, - decoration: const InputDecoration( - hintText: 'Search recipes...', - border: InputBorder.none, - hintStyle: TextStyle(color: Colors.white70), - ), - style: const TextStyle(color: Colors.white), - onChanged: (_) => _filterRecipes(), + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 4), + child: TextField( + controller: _searchController, + autofocus: true, + decoration: const InputDecoration( + hintText: 'Search recipes...', + border: InputBorder.none, + hintStyle: TextStyle(color: Colors.white70), + contentPadding: EdgeInsets.symmetric(vertical: 8, horizontal: 8), + ), + style: const TextStyle(color: Colors.white), + onChanged: (_) => _filterRecipes(), + ), + ), + if (_selectedTags.isNotEmpty) + Padding( + padding: const EdgeInsets.only(top: 2, bottom: 4, left: 4, right: 4), + child: RichText( + maxLines: 1, + overflow: TextOverflow.ellipsis, + text: TextSpan( + style: const TextStyle( + fontSize: 11, + fontWeight: FontWeight.w400, + ), + children: [ + const TextSpan( + text: 'Tag: ', + style: TextStyle(color: Colors.grey), + ), + TextSpan( + text: _selectedTags.join(', '), + style: const TextStyle(color: Colors.green), + ), + ], + ), + ), + ), + ], ) : const Text('All Recipes'), + titleSpacing: _isSearching ? 0 : null, elevation: 0, bottom: _buildTagFilterBar(), actions: [ @@ -667,18 +703,18 @@ class _RecipesScreenState extends State with WidgetsBindingObserv ), const SizedBox(height: 16), Text( - _searchController.text.isEmpty - ? 'No recipes yet' - : 'No recipes found', + (_searchController.text.isNotEmpty || _selectedTags.isNotEmpty) + ? 'No recipes found' + : 'No recipes yet', style: Theme.of(context).textTheme.titleLarge?.copyWith( color: Colors.grey[600], ), ), const SizedBox(height: 8), Text( - _searchController.text.isEmpty - ? 'Tap the + button to create your first recipe' - : 'Try a different search term', + (_searchController.text.isNotEmpty || _selectedTags.isNotEmpty) + ? 'Try a different search term' + : 'Tap the + button to create your first recipe', style: Theme.of(context).textTheme.bodyMedium?.copyWith( color: Colors.grey[500], ),