nothing more to do..?

i believe that the app is finished. ta-da!
This commit is contained in:
Felix 2019-07-16 12:14:47 +01:00
parent c288f257c5
commit 1353372743
No known key found for this signature in database
GPG key ID: 130EF6DC43E4DD07

View file

@ -75,42 +75,62 @@ class ReceiptPageState extends State<ReceiptPage> {
void submitReceipt(String amount, String time, Organisation organisation) async { void submitReceipt(String amount, String time, Organisation organisation) async {
SystemChannels.textInput.invokeMethod('TextInput.hide'); SystemChannels.textInput.invokeMethod('TextInput.hide');
if (demonstration) if (amount == "" || time == "" || organisation == null) {
{
await showDialog( await showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
// return object of type Dialog // return object of type Dialog
return AlertDialog( return AlertDialog(
title: new Text("Success"), title: new Text("Invalid data"),
content: new Text("Receipt successfully submitted."), content: new Text(
"We couldn't process your request because one or more required fields are missing."),
actions: <Widget>[ actions: <Widget>[
// usually buttons at the bottom of the dialog
new FlatButton( new FlatButton(
child: new Text("OK"), child: new Text("OK"),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed('/HomePage');
//TODO: Reset form after dialog exit
}, },
), ),
], ],
); );
}, },
).then((_) { );
});
} }
else { else {
Receipt receipt = new Receipt(); if (demonstration) {
await showDialog(
context: context,
builder: (BuildContext context) {
// return object of type Dialog
return AlertDialog(
title: new Text("Success"),
content: new Text("Receipt successfully submitted."),
actions: <Widget>[
// usually buttons at the bottom of the dialog
new FlatButton(
child: new Text("OK"),
onPressed: () {
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed('/HomePage');
},
),
],
);
},
).then((_) {});
}
// setting up 'receipt' else {
receipt.amount = amount; Receipt receipt = new Receipt();
receipt.time = formatDate(time);
// setting up 'receipt'
receipt.amount = amount;
receipt.time = formatDate(time);
// debugPrint(organisation.name + ", " + organisation.streetName + ", " + organisation.town + ", " + organisation.postcode); // debugPrint(organisation.name + ", " + organisation.streetName + ", " + organisation.town + ", " + organisation.postcode);
receipt.organisationName = organisation.name; receipt.organisationName = organisation.name;
receipt.street = organisation.streetName; receipt.street = organisation.streetName;
receipt.town = organisation.town; receipt.town = organisation.town;
receipt.postcode = organisation.postcode; receipt.postcode = organisation.postcode;
// receipt.essential = convertBoolToString(toConvert) // receipt.essential = convertBoolToString(toConvert)
@ -119,8 +139,9 @@ class ReceiptPageState extends State<ReceiptPage> {
// receipt.category = category; // receipt.category = category;
// receipt.etc = etc; // receipt.etc = etc;
submitReceiptAPI(context, receipt); submitReceiptAPI(context, receipt);
Navigator.of(context).pushReplacementNamed('/HomePage'); Navigator.of(context).pushReplacementNamed('/HomePage');
}
} }
} }