From 3da48add7edaf32767b8fad622f008431e2c8ccc Mon Sep 17 00:00:00 2001 From: JMARyA Date: Wed, 25 Sep 2024 10:49:21 +0200 Subject: [PATCH] update --- lib/api.dart | 1 + lib/pages/flow/end_flow_page.dart | 32 ++++--- lib/pages/flow/flows_page.dart | 2 +- lib/pages/itemview.dart | 2 +- lib/pages/supply.dart | 7 +- lib/pages/transaction.dart | 141 +++++++++++++++--------------- 6 files changed, 98 insertions(+), 87 deletions(-) diff --git a/lib/api.dart b/lib/api.dart index 0d3f926..b10e80e 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -3,6 +3,7 @@ import 'package:http/http.dart' as http; import 'package:shared_preferences/shared_preferences.dart'; // todo : api errors +// todo : api caching class API { late SharedPreferences pref; diff --git a/lib/pages/flow/end_flow_page.dart b/lib/pages/flow/end_flow_page.dart index af94e50..4525ea8 100644 --- a/lib/pages/flow/end_flow_page.dart +++ b/lib/pages/flow/end_flow_page.dart @@ -20,9 +20,11 @@ class _EndFlowWithProduceState extends State { List ret = []; for (var i in widget.info.produces!) { - ret.add(ElevatedButton(onPressed: () { - // todo : implement adding - }, child: Text("Produced $i"))); + ret.add(ElevatedButton( + onPressed: () { + // todo : implement adding + }, + child: Text("Produced $i"))); } return ret; @@ -38,14 +40,20 @@ class _EndFlowWithProduceState extends State { Widget build(BuildContext context) { // todo : show end screen with produce return Scaffold( - appBar: AppBar(title: Text("End ${widget.info.name} Flow"),), - body: Column(children: [ - ...addProduceButtons(), - const Divider(), - // todo : add produced list - const SizedBox(height: 10,), - ElevatedButton(onPressed: _endFlow, child: const Text("End Flow")) - ],), + appBar: AppBar( + title: Text("End ${widget.info.name} Flow"), + ), + body: Column( + children: [ + ...addProduceButtons(), + const Divider(), + // todo : add produced list + const SizedBox( + height: 10, + ), + ElevatedButton(onPressed: _endFlow, child: const Text("End Flow")) + ], + ), ); } -} \ No newline at end of file +} diff --git a/lib/pages/flow/flows_page.dart b/lib/pages/flow/flows_page.dart index 88cf174..5cf87d5 100644 --- a/lib/pages/flow/flows_page.dart +++ b/lib/pages/flow/flows_page.dart @@ -158,4 +158,4 @@ class _FlowsPageState extends State { _ => const Text("..."), })); } -} \ No newline at end of file +} diff --git a/lib/pages/itemview.dart b/lib/pages/itemview.dart index 2b1ebff..54d7110 100644 --- a/lib/pages/itemview.dart +++ b/lib/pages/itemview.dart @@ -40,7 +40,7 @@ class _ItemViewState extends State { fallbackWidth: 100, fallbackHeight: 100, ), - ), // todo + ), const SizedBox( width: 16.0, ), diff --git a/lib/pages/supply.dart b/lib/pages/supply.dart index 20c3d14..b83812b 100644 --- a/lib/pages/supply.dart +++ b/lib/pages/supply.dart @@ -178,10 +178,9 @@ class _SupplyPageState extends State { // Note TextFormField( - decoration: const InputDecoration(labelText: 'Note'), - controller: _noteController, - maxLines: 5 - ), + decoration: const InputDecoration(labelText: 'Note'), + controller: _noteController, + maxLines: 5), const SizedBox(height: 20), diff --git a/lib/pages/transaction.dart b/lib/pages/transaction.dart index 942d683..a368875 100644 --- a/lib/pages/transaction.dart +++ b/lib/pages/transaction.dart @@ -23,78 +23,81 @@ class _TransactionPageState extends State { title: Text(widget.transaction.item), actions: [ IconButton( - onPressed: () async { - final locations = await API().getLocations(); - List locationList = locations.keys.toList(); - String? selectedLocationID; + onPressed: () { + API().getLocations().then((locations) { + List locationList = locations.keys.toList(); + String? selectedLocationID; - await showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: const Text('Select Location'), - content: Row( - mainAxisSize: MainAxisSize.min, - children: [ - DropdownButton( - value: selectedLocationID, - onChanged: (value) { - selectedLocationID = value!; - API() - .moveTransaction(widget.transaction.uuid, - selectedLocationID!) - .then((x) { - Navigator.of(context).pop(); - }); - - setState(() {}); - }, - items: locationList - .map>((locationID) { - return DropdownMenuItem( - value: locationID, - child: Text(locations[locationID]!.name), - ); - }).toList(), - ), - IconButton( - onPressed: () { - API().getLocations().then((locations) { - QrBarCodeScannerDialog().getScannedQrBarCode( - context: context, - onCode: (code) { - // library is retarded - code = code!.replaceFirst( - "Code scanned = ", ""); - if (!locations.containsKey(code)) { - ScaffoldMessenger.of(context) - .showSnackBar( - SnackBar( - content: Text( - 'The location $code does not exist.')), - ); - return; - } - - API() - .moveTransaction( - widget.transaction.uuid, - selectedLocationID!) - .then( - (x) { - Navigator.of(context).pop(); - }, - ); - }); + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Move Transaction'), + content: Row( + mainAxisSize: MainAxisSize.min, + children: [ + DropdownButton( + value: selectedLocationID, + onChanged: (value) { + selectedLocationID = value!; + API() + .moveTransaction(widget.transaction.uuid, + selectedLocationID!) + .then((x) { + Navigator.of(context).pop(); }); + setState(() {}); }, - icon: const Icon(Icons.qr_code)) - ], - ), - ); - }, - ); + items: locationList + .map>((locationID) { + return DropdownMenuItem( + value: locationID, + child: Text(locations[locationID]!.name), + ); + }).toList(), + ), + IconButton( + onPressed: () { + API().getLocations().then((locations) { + QrBarCodeScannerDialog() + .getScannedQrBarCode( + context: context, + onCode: (code) { + // library is retarded + code = code!.replaceFirst( + "Code scanned = ", ""); + if (!locations + .containsKey(code)) { + ScaffoldMessenger.of(context) + .showSnackBar( + SnackBar( + content: Text( + 'The location $code does not exist.')), + ); + return; + } + + API() + .moveTransaction( + widget.transaction.uuid, + selectedLocationID!) + .then( + (x) { + Navigator.of(context).pop(); + }, + ); + }); + }); + setState(() {}); + }, + icon: const Icon(Icons.qr_code)) + ], + ), + ); + }, + ); + }); }, icon: const Icon(Icons.move_up)) ], @@ -327,4 +330,4 @@ class TransactionSelectPage extends StatelessWidget { .toList()), ); } -} \ No newline at end of file +}