organisations dialog improved

This commit is contained in:
Felix 2019-08-09 14:32:47 +01:00
parent 3dba00b0b6
commit 0996a1e252
2 changed files with 33 additions and 16 deletions

View file

@ -19,19 +19,22 @@ class FindOrganisations {
// eg items: organisations.getFavourites().orderBy(name),
Future<Organisation> dialog(context) {
bool _searchEnabled = false;
TextEditingController searchBarText = new TextEditingController();
var organisations = new Organisations();
var listTitle = "All Organisations";
var organisationsList = organisations.getTestData();
void _submitSearch(String search) {
void _submitSearch(String search) async {
_searchEnabled = false;
listTitle = "Results for \'" + search + "\'";
var futureOrgs = organisations.findOrganisations(search);
futureOrgs.then((val) {
debugPrint("There are " + val.length.toString() +
futureOrgs.then((value) {
debugPrint("There are " + value.length.toString() +
" payees matching the query \'" + search + "\'.");
organisationsList = val;
organisationsList = value;
_searchEnabled = true;
});
}
@ -49,31 +52,45 @@ class FindOrganisations {
child: Row(
children: [
Container(
width: 200,
width: 140,
height: 50,
child: TextField(
controller: searchBarText,
decoration: InputDecoration(
hintText: "Payee Name",
),
onSubmitted: (_) {
_submitSearch(searchBarText.text);
onChanged: (value) {
if (value.length > 0) {
_searchEnabled = true;
} else {
_searchEnabled = false;
}
setState(() => {});
},
onSubmitted: (value) {
if (_searchEnabled) {
_submitSearch(searchBarText.text);
setState(() => {});
}
},
),
),
Container(
width: 80,
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
child: RaisedButton(
onPressed: () {
_submitSearch(searchBarText.text);
setState(() => {});
},
child: Icon(Icons.search, color: Colors.white),
color: Colors.blue,
// make inactive when search in progress as activity indicator
child: IgnorePointer(
ignoring: _searchEnabled,
child: RaisedButton(
onPressed: () {
_submitSearch(searchBarText.text);
setState(() => {});
},
child: Icon(Icons.search, color: Colors.white),
color: _searchEnabled ? Colors.blue : Colors.blue[200],
// make inactive when search in progress as activity indicator
),
),
),
],

View file

@ -149,8 +149,8 @@ class ReceiptPage2State extends State<ReceiptPage2> {
// var dialog = popupListView.dialog(context, optionsList, "Choose Organization");
var organisations = new FindOrganisations();
var orgDialog = organisations.dialog(context);
orgDialog.then((organisation) {
setState(() => {});
debugPrint(organisation.name);
});
},