mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-31 05:15:42 +00:00 
			
		
		
		
	Fixed search bar issues
This commit is contained in:
		| @@ -4,7 +4,8 @@ | |||||||
| - Fixes crash bug on top-level part category | - Fixes crash bug on top-level part category | ||||||
| - Fixed crash bug on top-level stock location | - Fixed crash bug on top-level stock location | ||||||
| - Adds context overlay to barcode scanner view | - Adds context overlay to barcode scanner view | ||||||
| - Notifcations are less obtrusive (uses snack bar) | - Notifications are less obtrusive (uses snack bar) | ||||||
|  | - Fixed search views - keyboard search button now works properly | ||||||
|  |  | ||||||
| ## 0.1.0 - February 2021 | ## 0.1.0 - February 2021 | ||||||
| --- | --- | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								lib/l10n
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								lib/l10n
									
									
									
									
									
								
							 Submodule lib/l10n updated: bc85d5b16c...05207b7e5b
									
								
							| @@ -1,6 +1,7 @@ | |||||||
|  |  | ||||||
| import 'package:InvenTree/widget/part_detail.dart'; | import 'package:InvenTree/widget/part_detail.dart'; | ||||||
| import 'package:InvenTree/widget/progress.dart'; | import 'package:InvenTree/widget/progress.dart'; | ||||||
|  | import 'package:InvenTree/widget/snacks.dart'; | ||||||
| import 'package:InvenTree/widget/stock_detail.dart'; | import 'package:InvenTree/widget/stock_detail.dart'; | ||||||
| import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||||
| @@ -8,6 +9,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; | |||||||
| import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||||||
| import 'package:InvenTree/inventree/part.dart'; | import 'package:InvenTree/inventree/part.dart'; | ||||||
| import 'package:InvenTree/inventree/stock.dart'; | import 'package:InvenTree/inventree/stock.dart'; | ||||||
|  | import 'package:one_context/one_context.dart'; | ||||||
|  |  | ||||||
| import '../api.dart'; | import '../api.dart'; | ||||||
|  |  | ||||||
| @@ -19,6 +21,9 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart> { | |||||||
|  |  | ||||||
|   BuildContext context; |   BuildContext context; | ||||||
|  |  | ||||||
|  |   // What did we search for last time? | ||||||
|  |   String _cachedQuery; | ||||||
|  |  | ||||||
|   bool _searching = false; |   bool _searching = false; | ||||||
|  |  | ||||||
|   // Custom filters for the part search |   // Custom filters for the part search | ||||||
| @@ -45,6 +50,12 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart> { | |||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     if (query == _cachedQuery) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     _cachedQuery = query; | ||||||
|  |  | ||||||
|     _searching = true; |     _searching = true; | ||||||
|  |  | ||||||
|     print("Searching..."); |     print("Searching..."); | ||||||
| @@ -67,8 +78,11 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart> { | |||||||
|     print("Searching complete! Results: ${partResults.length}"); |     print("Searching complete! Results: ${partResults.length}"); | ||||||
|     _searching = false; |     _searching = false; | ||||||
|  |  | ||||||
|     // TODO: Show a snackbar detailing number of results... |     showSnackIcon( | ||||||
|     //showSnackIcon("Found ${partResults.length} parts", context: context); |         "${partResults.length} ${I18N.of(OneContext().context).results}", | ||||||
|  |         success: partResults.length > 0, | ||||||
|  |         icon: FontAwesomeIcons.pollH, | ||||||
|  |     ); | ||||||
|  |  | ||||||
|     // For some reason, need to toggle between suggestions and results here... |     // For some reason, need to toggle between suggestions and results here... | ||||||
|     showSuggestions(context); |     showSuggestions(context); | ||||||
| @@ -133,10 +147,14 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart> { | |||||||
|   @override |   @override | ||||||
|   Widget buildResults(BuildContext context) { |   Widget buildResults(BuildContext context) { | ||||||
|  |  | ||||||
|  |     print("build results"); | ||||||
|  |  | ||||||
|     if (_searching) { |     if (_searching) { | ||||||
|       return progressIndicator(); |       return progressIndicator(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     search(context); | ||||||
|  |  | ||||||
|     if (query.length == 0) { |     if (query.length == 0) { | ||||||
|       return ListTile( |       return ListTile( | ||||||
|         title: Text("Enter search query") |         title: Text("Enter search query") | ||||||
| @@ -152,8 +170,8 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart> { | |||||||
|  |  | ||||||
|     if (partResults.length == 0) { |     if (partResults.length == 0) { | ||||||
|       return ListTile( |       return ListTile( | ||||||
|         title: Text("No Results"), |         title: Text(I18N.of(context).noResults), | ||||||
|         subtitle: Text("No results matching query") |         subtitle: Text("No results for '${query}'") | ||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -189,6 +207,8 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem> { | |||||||
|  |  | ||||||
|   final BuildContext context; |   final BuildContext context; | ||||||
|  |  | ||||||
|  |   String _cachedQuery; | ||||||
|  |  | ||||||
|   bool _searching = false; |   bool _searching = false; | ||||||
|  |  | ||||||
|   // Custom filters for the stock item search |   // Custom filters for the stock item search | ||||||
| @@ -214,6 +234,12 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem> { | |||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     if (query == _cachedQuery) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     _cachedQuery = query; | ||||||
|  |  | ||||||
|     _searching = true; |     _searching = true; | ||||||
|  |  | ||||||
|     print("Searching..."); |     print("Searching..."); | ||||||
| @@ -236,7 +262,12 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem> { | |||||||
|  |  | ||||||
|     _searching = false; |     _searching = false; | ||||||
|  |  | ||||||
|     // TODO - Show a snackbar icon with number of results. |     showSnackIcon( | ||||||
|  |       "${itemResults.length} ${I18N.of(OneContext().context).results}", | ||||||
|  |       success: itemResults.length > 0, | ||||||
|  |       icon: FontAwesomeIcons.pollH, | ||||||
|  |     ); | ||||||
|  |  | ||||||
|     showSuggestions(context); |     showSuggestions(context); | ||||||
|     showResults(context); |     showResults(context); | ||||||
|   } |   } | ||||||
| @@ -299,10 +330,14 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem> { | |||||||
|   @override |   @override | ||||||
|   Widget buildResults(BuildContext context) { |   Widget buildResults(BuildContext context) { | ||||||
|  |  | ||||||
|  |     search(context); | ||||||
|  |  | ||||||
|     if (_searching) { |     if (_searching) { | ||||||
|       return progressIndicator(); |       return progressIndicator(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     search(context); | ||||||
|  |  | ||||||
|     if (query.length == 0) { |     if (query.length == 0) { | ||||||
|       return ListTile( |       return ListTile( | ||||||
|           title: Text("Enter search query") |           title: Text("Enter search query") | ||||||
| @@ -318,8 +353,8 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem> { | |||||||
|  |  | ||||||
|     if (itemResults.length == 0) { |     if (itemResults.length == 0) { | ||||||
|       return ListTile( |       return ListTile( | ||||||
|           title: Text("No Results"), |           title: Text(I18N.of(context).noResults), | ||||||
|           subtitle: Text("No results matching query") |           subtitle: Text("No results for '${query}'") | ||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user