This commit is contained in:
JMARyA 2024-09-25 10:49:21 +02:00
parent 20bc5a9ae6
commit 3da48add7e
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
6 changed files with 98 additions and 87 deletions

View file

@ -3,6 +3,7 @@ import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
// todo : api errors // todo : api errors
// todo : api caching
class API { class API {
late SharedPreferences pref; late SharedPreferences pref;

View file

@ -20,9 +20,11 @@ class _EndFlowWithProduceState extends State<EndFlowWithProduce> {
List<Widget> ret = []; List<Widget> ret = [];
for (var i in widget.info.produces!) { for (var i in widget.info.produces!) {
ret.add(ElevatedButton(onPressed: () { ret.add(ElevatedButton(
// todo : implement adding onPressed: () {
}, child: Text("Produced $i"))); // todo : implement adding
},
child: Text("Produced $i")));
} }
return ret; return ret;
@ -38,14 +40,20 @@ class _EndFlowWithProduceState extends State<EndFlowWithProduce> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
// todo : show end screen with produce // todo : show end screen with produce
return Scaffold( return Scaffold(
appBar: AppBar(title: Text("End ${widget.info.name} Flow"),), appBar: AppBar(
body: Column(children: [ title: Text("End ${widget.info.name} Flow"),
...addProduceButtons(), ),
const Divider(), body: Column(
// todo : add produced list children: [
const SizedBox(height: 10,), ...addProduceButtons(),
ElevatedButton(onPressed: _endFlow, child: const Text("End Flow")) const Divider(),
],), // todo : add produced list
const SizedBox(
height: 10,
),
ElevatedButton(onPressed: _endFlow, child: const Text("End Flow"))
],
),
); );
} }
} }

View file

@ -40,7 +40,7 @@ class _ItemViewState extends State<ItemView> {
fallbackWidth: 100, fallbackWidth: 100,
fallbackHeight: 100, fallbackHeight: 100,
), ),
), // todo ),
const SizedBox( const SizedBox(
width: 16.0, width: 16.0,
), ),

View file

@ -178,10 +178,9 @@ class _SupplyPageState extends State<SupplyPage> {
// Note // Note
TextFormField( TextFormField(
decoration: const InputDecoration(labelText: 'Note'), decoration: const InputDecoration(labelText: 'Note'),
controller: _noteController, controller: _noteController,
maxLines: 5 maxLines: 5),
),
const SizedBox(height: 20), const SizedBox(height: 20),

View file

@ -23,78 +23,81 @@ class _TransactionPageState extends State<TransactionPage> {
title: Text(widget.transaction.item), title: Text(widget.transaction.item),
actions: [ actions: [
IconButton( IconButton(
onPressed: () async { onPressed: () {
final locations = await API().getLocations(); API().getLocations().then((locations) {
List<String> locationList = locations.keys.toList(); List<String> locationList = locations.keys.toList();
String? selectedLocationID; String? selectedLocationID;
await showDialog<int>( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
title: const Text('Select Location'), title: const Text('Move Transaction'),
content: Row( content: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
DropdownButton<String>( DropdownButton<String>(
value: selectedLocationID, value: selectedLocationID,
onChanged: (value) { onChanged: (value) {
selectedLocationID = value!; selectedLocationID = value!;
API() API()
.moveTransaction(widget.transaction.uuid, .moveTransaction(widget.transaction.uuid,
selectedLocationID!) selectedLocationID!)
.then((x) { .then((x) {
Navigator.of(context).pop(); Navigator.of(context).pop();
});
setState(() {});
},
items: locationList
.map<DropdownMenuItem<String>>((locationID) {
return DropdownMenuItem<String>(
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(() {}); setState(() {});
}, },
icon: const Icon(Icons.qr_code)) items: locationList
], .map<DropdownMenuItem<String>>((locationID) {
), return DropdownMenuItem<String>(
); 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)) icon: const Icon(Icons.move_up))
], ],