From 755893ee109d3d633388df6d2a67f36594ba7313 Mon Sep 17 00:00:00 2001 From: Felix Date: Mon, 5 Aug 2019 09:27:10 +0100 Subject: [PATCH] just gonna redo the whole receipt page this is because the code for it is now completely messy and impossible to follow (yeah, my fault) and I need to start remembering how to code properly again after two weeks --- ios/Podfile.lock | 2 +- lib/pages/receipt_page.dart | 45 ++++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index f5bffe1..a4e1203 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -25,4 +25,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: aff02bfeed411c636180d6812254b2daeea14d09 -COCOAPODS: 1.7.3 +COCOAPODS: 1.7.5 diff --git a/lib/pages/receipt_page.dart b/lib/pages/receipt_page.dart index b37601d..27bcad0 100644 --- a/lib/pages/receipt_page.dart +++ b/lib/pages/receipt_page.dart @@ -33,7 +33,8 @@ class ReceiptPageState extends State { TextEditingController _categoryController; // TODO: fix this!! final TextEditingController _orgController = TextEditingController(); final OrganizationController _organizationController = OrganizationController(); - DropdownButton _dropDownMenu = new DropdownButton(items: null, onChanged: null); + DropdownButton _categoriesDropDownButton = new DropdownButton(items: null /*onChanged: blahBlahBlah*/); + DropdownButton _recurringDropDownButton = new DropdownButton(items: null /*onChanged: blahBlahBlah*/); String _category; FocusNode focusNode; @@ -62,9 +63,9 @@ class ReceiptPageState extends State { // }); // loadDropDownMenu(); - getDropDownMenu().then((value) { + getCategoriesDropDownMenu("categories").then((value) { setState((){ - _dropDownMenu = value; + _categoriesDropDownButton = value; }); }); @@ -107,20 +108,20 @@ class ReceiptPageState extends State { // _category = categories[0]; // _dropDownMenu = new DropdownButton(/*value : _categoryController.text, */items: categories, onChanged: (newValue) => _categoryController.text = newValue); setState(() { - _dropDownMenu = new DropdownButton(items: categories, onChanged: (newValue) => _category = newValue, value: _category); + _categoriesDropDownButton = new DropdownButton(items: categories, onChanged: (newValue) => _category = newValue, value: _category); }); }); } + + Future getCategoriesDropDownMenu(String type) async { + List dropDownItems = await getDropDownItems(type); - Future getDropDownMenu() async { - List categories = await getDropDownItems("categories"); - - categories.forEach((thisOne) { - print("This value: " + thisOne.value); - }); +// dropDownItems.forEach((thisOne) { +// print("This value: " + thisOne.value); +// }); // _categoryController = new TextEditingController(text: null); return new DropdownButton( - items: categories, + items: dropDownItems, onChanged: (newValue) { _category = newValue; setState(() { @@ -267,16 +268,18 @@ class ReceiptPageState extends State { // } List getRecurringOptions() { - var options = new List(7); - options[0] = "None"; // this should not be hardcoded and should be fetched from API instead - options[1] = "Daily"; - options[2] = "Weekly"; - options[3] = "Fortnightly"; - options[4] = "Monthly"; - options[5] = "Quarterly"; - options[6] = "Yearly"; +// var options = new List(7); +// options[0] = "None"; // this should not be hardcoded and should be fetched from API instead +// options[1] = "Daily"; +// options[2] = "Weekly"; +// options[3] = "Fortnightly"; +// options[4] = "Monthly"; +// options[5] = "Quarterly"; +// options[6] = "Yearly"; +// +// return options; - return options; + var options = } String formatDate(String date) { @@ -612,7 +615,7 @@ class ReceiptPageState extends State { Container( padding: const EdgeInsets.fromLTRB(29, 0, 0, 0), - child: _dropDownMenu, + child: _categoriesDropDownButton, // child: DropdownButton( // items: _categoryDropDownItems, //