2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 02:05:29 +00:00

Refactor search

This commit is contained in:
Oliver Walters
2021-03-05 21:07:58 +11:00
parent fe2913529b
commit a6de7d619a
4 changed files with 77 additions and 117 deletions

View File

@ -5,22 +5,34 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class PaginatedSearch extends StatelessWidget {
class PaginatedSearchWidget extends StatelessWidget {
Function callback;
Function onChanged;
int results = 0;
PaginatedSearch({this.callback, this.results});
TextEditingController controller;
PaginatedSearchWidget(this.controller, this.onChanged, this.results);
@override
Widget build(BuildContext context) {
return ListTile(
leading: FaIcon(FontAwesomeIcons.search),
title: TextField(
leading: GestureDetector(
child: FaIcon(controller.text.isEmpty ? FontAwesomeIcons.search : FontAwesomeIcons.backspace),
onTap: () {
if (onChanged != null) {
controller.clear();
onChanged();
}
},
),
title: TextFormField(
controller: controller,
onChanged: (value) {
if (callback != null) {
callback(value);
if (onChanged != null) {
onChanged();
}
},
decoration: InputDecoration(