2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00

Widget cleanup

This commit is contained in:
Oliver Walters 2022-07-06 21:13:07 +10:00
parent a450154bac
commit c3e6d3f902
2 changed files with 20 additions and 4 deletions

View File

@ -294,6 +294,9 @@
"feedbackSuccess": "Feedback submitted", "feedbackSuccess": "Feedback submitted",
"@feedbackSuccess": {}, "@feedbackSuccess": {},
"filteringOptions": "Filtering Options",
"@filteringOptions": {},
"formatException": "Format Exception", "formatException": "Format Exception",
"@formatException": {}, "@formatException": {},

View File

@ -4,6 +4,7 @@ import "package:font_awesome_flutter/font_awesome_flutter.dart";
import "package:infinite_scroll_pagination/infinite_scroll_pagination.dart"; import "package:infinite_scroll_pagination/infinite_scroll_pagination.dart";
import "package:inventree/api_form.dart"; import "package:inventree/api_form.dart";
import 'package:inventree/app_colors.dart';
import "package:inventree/l10.dart"; import "package:inventree/l10.dart";
import "package:inventree/inventree/model.dart"; import "package:inventree/inventree/model.dart";
@ -118,7 +119,7 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> with BaseW
launchApiForm( launchApiForm(
context, context,
"...filtering...", L10().filteringOptions,
"", "",
fields, fields,
icon: FontAwesomeIcons.checkCircle, icon: FontAwesomeIcons.checkCircle,
@ -143,6 +144,15 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> with BaseW
int resultCount = 0; int resultCount = 0;
String resultsString() {
if (resultCount <= 0) {
return noResultsText;
} else {
return "${resultCount} ${L10().results}";
}
}
// Text controller // Text controller
final TextEditingController searchController = TextEditingController(); final TextEditingController searchController = TextEditingController();
@ -274,13 +284,16 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> with BaseW
Widget buildSearchInput(BuildContext context) { Widget buildSearchInput(BuildContext context) {
return ListTile( return ListTile(
leading: orderingOptions.isEmpty ? null : GestureDetector( leading: orderingOptions.isEmpty ? null : GestureDetector(
child: FaIcon(FontAwesomeIcons.sort), child: FaIcon(FontAwesomeIcons.sort, color: COLOR_CLICK),
onTap: () async { onTap: () async {
_saveOrderingOptions(context); _saveOrderingOptions(context);
}, },
), ),
trailing: GestureDetector( trailing: GestureDetector(
child: FaIcon(searchController.text.isEmpty ? FontAwesomeIcons.search : FontAwesomeIcons.backspace), child: FaIcon(
searchController.text.isEmpty ? FontAwesomeIcons.search : FontAwesomeIcons.backspace,
color: searchController.text.isNotEmpty ? COLOR_DANGER : COLOR_CLICK,
),
onTap: () { onTap: () {
searchController.clear(); searchController.clear();
updateSearchTerm(); updateSearchTerm();
@ -293,7 +306,7 @@ class PaginatedSearchState<T extends StatefulWidget> extends State<T> with BaseW
}, },
decoration: InputDecoration( decoration: InputDecoration(
hintText: L10().search, hintText: L10().search,
helperText: resultCount.toString(), helperText: resultsString(),
), ),
) )
); );