organisations dialog improved
This commit is contained in:
parent
3dba00b0b6
commit
0996a1e252
2 changed files with 33 additions and 16 deletions
|
@ -19,19 +19,22 @@ class FindOrganisations {
|
||||||
// eg items: organisations.getFavourites().orderBy(name),
|
// eg items: organisations.getFavourites().orderBy(name),
|
||||||
|
|
||||||
Future<Organisation> dialog(context) {
|
Future<Organisation> dialog(context) {
|
||||||
|
bool _searchEnabled = false;
|
||||||
TextEditingController searchBarText = new TextEditingController();
|
TextEditingController searchBarText = new TextEditingController();
|
||||||
var organisations = new Organisations();
|
var organisations = new Organisations();
|
||||||
var listTitle = "All Organisations";
|
var listTitle = "All Organisations";
|
||||||
var organisationsList = organisations.getTestData();
|
var organisationsList = organisations.getTestData();
|
||||||
|
|
||||||
void _submitSearch(String search) {
|
void _submitSearch(String search) async {
|
||||||
|
_searchEnabled = false;
|
||||||
listTitle = "Results for \'" + search + "\'";
|
listTitle = "Results for \'" + search + "\'";
|
||||||
|
|
||||||
var futureOrgs = organisations.findOrganisations(search);
|
var futureOrgs = organisations.findOrganisations(search);
|
||||||
futureOrgs.then((val) {
|
futureOrgs.then((value) {
|
||||||
debugPrint("There are " + val.length.toString() +
|
debugPrint("There are " + value.length.toString() +
|
||||||
" payees matching the query \'" + search + "\'.");
|
" payees matching the query \'" + search + "\'.");
|
||||||
organisationsList = val;
|
organisationsList = value;
|
||||||
|
_searchEnabled = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,31 +52,45 @@ class FindOrganisations {
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
width: 200,
|
width: 140,
|
||||||
height: 50,
|
height: 50,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: searchBarText,
|
controller: searchBarText,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: "Payee Name",
|
hintText: "Payee Name",
|
||||||
),
|
),
|
||||||
onSubmitted: (_) {
|
onChanged: (value) {
|
||||||
_submitSearch(searchBarText.text);
|
if (value.length > 0) {
|
||||||
|
_searchEnabled = true;
|
||||||
|
} else {
|
||||||
|
_searchEnabled = false;
|
||||||
|
}
|
||||||
setState(() => {});
|
setState(() => {});
|
||||||
},
|
},
|
||||||
|
onSubmitted: (value) {
|
||||||
|
if (_searchEnabled) {
|
||||||
|
_submitSearch(searchBarText.text);
|
||||||
|
setState(() => {});
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
Container(
|
Container(
|
||||||
width: 80,
|
width: 80,
|
||||||
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
|
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
|
||||||
child: RaisedButton(
|
child: IgnorePointer(
|
||||||
onPressed: () {
|
ignoring: _searchEnabled,
|
||||||
_submitSearch(searchBarText.text);
|
child: RaisedButton(
|
||||||
setState(() => {});
|
onPressed: () {
|
||||||
},
|
_submitSearch(searchBarText.text);
|
||||||
child: Icon(Icons.search, color: Colors.white),
|
setState(() => {});
|
||||||
color: Colors.blue,
|
},
|
||||||
// make inactive when search in progress as activity indicator
|
|
||||||
|
child: Icon(Icons.search, color: Colors.white),
|
||||||
|
color: _searchEnabled ? Colors.blue : Colors.blue[200],
|
||||||
|
// make inactive when search in progress as activity indicator
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -149,8 +149,8 @@ class ReceiptPage2State extends State<ReceiptPage2> {
|
||||||
// var dialog = popupListView.dialog(context, optionsList, "Choose Organization");
|
// var dialog = popupListView.dialog(context, optionsList, "Choose Organization");
|
||||||
var organisations = new FindOrganisations();
|
var organisations = new FindOrganisations();
|
||||||
var orgDialog = organisations.dialog(context);
|
var orgDialog = organisations.dialog(context);
|
||||||
|
|
||||||
orgDialog.then((organisation) {
|
orgDialog.then((organisation) {
|
||||||
|
setState(() => {});
|
||||||
debugPrint(organisation.name);
|
debugPrint(organisation.name);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Reference in a new issue