new organisation picker -actually- works now

This commit is contained in:
Felix 2019-08-12 10:48:50 +01:00
parent 9cba3e037c
commit ee682eef82
2 changed files with 11 additions and 5 deletions

View file

@ -32,8 +32,8 @@ class FindOrganisations {
var futureOrgs = await organisations.findOrganisations(search); var futureOrgs = await organisations.findOrganisations(search);
// futureOrgs.then((value) { // futureOrgs.then((value) {
debugPrint("There are " + futureOrgs.length.toString() + // debugPrint("There are " + futureOrgs.length.toString() +
" payees matching the query \'" + search + "\'."); // " payees matching the query \'" + search + "\'.");
organisationsList = futureOrgs; organisationsList = futureOrgs;
_searchEnabled = true; _searchEnabled = true;
return futureOrgs.length; return futureOrgs.length;
@ -41,7 +41,7 @@ class FindOrganisations {
} }
_chosenOrg(Organisation chosen) { _chosenOrg(Organisation chosen) {
debugPrint(chosen.name + " tapped"); // debugPrint(chosen.name + " tapped");
} }
return showDialog<Organisation>( return showDialog<Organisation>(
@ -139,6 +139,7 @@ class FindOrganisations {
// trailing: Icon(Icons.arrow_forward_ios), // trailing: Icon(Icons.arrow_forward_ios),
// onTap: _chosenOrg(organisationsList[index]), // onTap: _chosenOrg(organisationsList[index]),
onTap: (){ onTap: (){
Navigator.of(context).pop(organisationsList[index]);
_chosenOrg(organisationsList[index]); _chosenOrg(organisationsList[index]);
}, },
onLongPress: (){ onLongPress: (){

View file

@ -151,7 +151,10 @@ class ReceiptPage2State extends State<ReceiptPage2> {
var orgDialog = organisations.dialog(context); var orgDialog = organisations.dialog(context);
orgDialog.then((organisation) { orgDialog.then((organisation) {
try { try {
debugPrint(organisation.name); organisation.name.length;
transaction.organisation = organisation;
// debugPrint(organisation.name);
setState(() {});
} catch(_) { } catch(_) {
debugPrint("No organisation chosen."); debugPrint("No organisation chosen.");
} }
@ -160,6 +163,8 @@ class ReceiptPage2State extends State<ReceiptPage2> {
child: Text( child: Text(
transaction.organisation.name == null transaction.organisation.name == null
? 'Find' ? 'Find'
: transaction.organisation.name.length > 14
? transaction.organisation.name.substring(0,12) + "..."
: transaction.organisation.name, : transaction.organisation.name,
style: style:
TextStyle(color: Colors.white, fontSize: 18.0), TextStyle(color: Colors.white, fontSize: 18.0),