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
This commit is contained in:
Felix 2019-08-05 09:27:10 +01:00
parent 525a092f40
commit 755893ee10
2 changed files with 25 additions and 22 deletions

View file

@ -25,4 +25,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: aff02bfeed411c636180d6812254b2daeea14d09 PODFILE CHECKSUM: aff02bfeed411c636180d6812254b2daeea14d09
COCOAPODS: 1.7.3 COCOAPODS: 1.7.5

View file

@ -33,7 +33,8 @@ class ReceiptPageState extends State<ReceiptPage> {
TextEditingController _categoryController; // TODO: fix this!! TextEditingController _categoryController; // TODO: fix this!!
final TextEditingController _orgController = TextEditingController(); final TextEditingController _orgController = TextEditingController();
final OrganizationController _organizationController = OrganizationController(); 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; String _category;
FocusNode focusNode; FocusNode focusNode;
@ -62,9 +63,9 @@ class ReceiptPageState extends State<ReceiptPage> {
// }); // });
// loadDropDownMenu(); // loadDropDownMenu();
getDropDownMenu().then((value) { getCategoriesDropDownMenu("categories").then((value) {
setState((){ setState((){
_dropDownMenu = value; _categoriesDropDownButton = value;
}); });
}); });
@ -107,20 +108,20 @@ class ReceiptPageState extends State<ReceiptPage> {
// _category = categories[0]; // _category = categories[0];
// _dropDownMenu = new DropdownButton<String>(/*value : _categoryController.text, */items: categories, onChanged: (newValue) => _categoryController.text = newValue); // _dropDownMenu = new DropdownButton<String>(/*value : _categoryController.text, */items: categories, onChanged: (newValue) => _categoryController.text = newValue);
setState(() { setState(() {
_dropDownMenu = new DropdownButton(items: categories, onChanged: (newValue) => _category = newValue, value: _category); _categoriesDropDownButton = new DropdownButton(items: categories, onChanged: (newValue) => _category = newValue, value: _category);
}); });
}); });
} }
Future<DropdownButton> getDropDownMenu() async { Future<DropdownButton> getCategoriesDropDownMenu(String type) async {
List<DropdownMenuItem> categories = await getDropDownItems("categories"); List<DropdownMenuItem> dropDownItems = await getDropDownItems(type);
categories.forEach((thisOne) { // dropDownItems.forEach((thisOne) {
print("This value: " + thisOne.value); // print("This value: " + thisOne.value);
}); // });
// _categoryController = new TextEditingController(text: null); // _categoryController = new TextEditingController(text: null);
return new DropdownButton( return new DropdownButton(
items: categories, items: dropDownItems,
onChanged: (newValue) { onChanged: (newValue) {
_category = newValue; _category = newValue;
setState(() { setState(() {
@ -267,16 +268,18 @@ class ReceiptPageState extends State<ReceiptPage> {
// } // }
List<String> getRecurringOptions() { List<String> getRecurringOptions() {
var options = new List<String>(7); // var options = new List<String>(7);
options[0] = "None"; // this should not be hardcoded and should be fetched from API instead // options[0] = "None"; // this should not be hardcoded and should be fetched from API instead
options[1] = "Daily"; // options[1] = "Daily";
options[2] = "Weekly"; // options[2] = "Weekly";
options[3] = "Fortnightly"; // options[3] = "Fortnightly";
options[4] = "Monthly"; // options[4] = "Monthly";
options[5] = "Quarterly"; // options[5] = "Quarterly";
options[6] = "Yearly"; // options[6] = "Yearly";
//
// return options;
return options; var options =
} }
String formatDate(String date) { String formatDate(String date) {
@ -612,7 +615,7 @@ class ReceiptPageState extends State<ReceiptPage> {
Container( Container(
padding: const EdgeInsets.fromLTRB(29, 0, 0, 0), padding: const EdgeInsets.fromLTRB(29, 0, 0, 0),
child: _dropDownMenu, child: _categoriesDropDownButton,
// child: DropdownButton( // child: DropdownButton(
// items: _categoryDropDownItems, // items: _categoryDropDownItems,
// //