From 2e1b74a222e7f3fe8e5aef9ca6f739835cc8f239 Mon Sep 17 00:00:00 2001 From: Felix Date: Mon, 19 Aug 2019 11:19:41 +0100 Subject: [PATCH] dialog looks slightly better --- lib/common/widgets/organisations_dialog.dart | 100 +++++++++---------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/lib/common/widgets/organisations_dialog.dart b/lib/common/widgets/organisations_dialog.dart index 1465aed..5c69e48 100644 --- a/lib/common/widgets/organisations_dialog.dart +++ b/lib/common/widgets/organisations_dialog.dart @@ -86,7 +86,6 @@ class FindOrganisations { TextEditingController searchBarText = new TextEditingController(); var organisations = new Organisations(); var listTitle = "All Organisations"; -// var organisationsList = organisations.getTestData(); var organisationsList = List(); Future _submitSearch(String search) async { @@ -94,13 +93,9 @@ class FindOrganisations { listTitle = "Results for \'" + search + "\'"; var futureOrgs = await organisations.findOrganisations(search); -// futureOrgs.then((value) { -// debugPrint("There are " + futureOrgs.length.toString() + -// " payees matching the query \'" + search + "\'."); organisationsList = futureOrgs; _searchEnabled = true; return futureOrgs.length; -// }); } return showDialog( @@ -166,54 +161,57 @@ class FindOrganisations { ), ), - Container( - padding: EdgeInsets.fromLTRB(20, 20, 20, 0), - child: Text( - listTitle, - style: new TextStyle( - fontSize: 23, fontWeight: FontWeight.bold), - ), - ), - - Container( - padding: EdgeInsets.fromLTRB(10, 10, 10, 0), - width: MediaQuery - .of(context) - .size - .width, - height: MediaQuery - .of(context) - .size - .height * 0.67, - - child: Material( - shadowColor: Colors.transparent, - color: Colors.transparent, - child: ListView.builder( - itemCount: organisationsList.length, - itemBuilder: (context, index) { - return Card( - child: ListTile( - leading: Icon(Icons.person), - title: Text(organisationsList[index].name, style: new TextStyle(fontSize: 18)), - subtitle: Text(organisationsList[index].postcode.toUpperCase()), -// trailing: Icon(Icons.arrow_forward_ios), -// onTap: _chosenOrg(organisationsList[index]), - onTap: (){ - Navigator.of(context).pop(organisationsList[index]); - }, - onLongPress: (){ - // show more details about the organisation in a new dialog - var moreInfo = _moreInfoDialog(context, organisationsList[index]); - moreInfo.whenComplete(null); - }, - ), - ); - }, + Column( + children: organisationsList.length > 0 ? [ + Container( + padding: EdgeInsets.fromLTRB(20, 20, 20, 0), + child: Text( + listTitle, + style: new TextStyle( + fontSize: 23, fontWeight: FontWeight.bold), + ), ), - ), - ), + Container( + padding: EdgeInsets.fromLTRB(10, 10, 10, 0), + width: MediaQuery + .of(context) + .size + .width, + height: MediaQuery + .of(context) + .size + .height * 0.67, + + child: Material( + shadowColor: Colors.transparent, + color: Colors.transparent, + child: ListView.builder( + itemCount: organisationsList.length, + itemBuilder: (context, index) { + return Card( + child: ListTile( + leading: Icon(Icons.person), + title: Text(organisationsList[index].name, style: new TextStyle(fontSize: 18)), + subtitle: Text(organisationsList[index].postcode.toUpperCase()), + // trailing: Icon(Icons.arrow_forward_ios), + // onTap: _chosenOrg(organisationsList[index]), + onTap: (){ + Navigator.of(context).pop(organisationsList[index]); + }, + onLongPress: (){ + // show more details about the organisation in a new dialog + var moreInfo = _moreInfoDialog(context, organisationsList[index]); + moreInfo.whenComplete(null); + }, + ), + ); + }, + ), + ), + ), + ] : [ Container(), ], + ), // help button for if org not listed // cancel and ok buttons