add barcode quick add
This commit is contained in:
parent
fcecb5aad5
commit
0e2ccb9e54
8 changed files with 58 additions and 23 deletions
|
@ -82,7 +82,7 @@ class _ActiveFlowPageState extends State<ActiveFlowPage> {
|
|||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 18.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
|
|
|
@ -94,7 +94,7 @@ class _CreateFlowPageState extends State<CreateFlowPage> {
|
|||
child: Text(API.API().getFlowInfo(widget.previousFlow!.kind).name),
|
||||
),
|
||||
),
|
||||
Card(child: Icon(Icons.arrow_right)),
|
||||
const Card(child: Icon(Icons.arrow_right)),
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
|
|
|
@ -7,11 +7,40 @@ import 'package:flutter/material.dart';
|
|||
class ItemsPage extends StatelessWidget {
|
||||
const ItemsPage({super.key});
|
||||
|
||||
_scanBarcodeSupply(BuildContext context) async {
|
||||
var code =
|
||||
int.parse(await scanQRCode(context, title: "Scan Barcode") ?? "0");
|
||||
|
||||
var items = API().getItems();
|
||||
for (var item in items) {
|
||||
for (var variant in item.variants.keys) {
|
||||
for (var barcode in item.variants[variant]!.barcodes ?? []) {
|
||||
if (code == barcode) {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => SupplyPage(
|
||||
item,
|
||||
() {},
|
||||
onlyVariants: [variant],
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Items"),
|
||||
// todo : add barcode scan
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
_scanBarcodeSupply(context);
|
||||
},
|
||||
child: const Icon(Icons.add_box))
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
children: API().getItems().map((x) {
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'package:cdb_ui/api.dart';
|
|||
import 'package:cdb_ui/pages/stats.dart';
|
||||
import 'package:cdb_ui/pages/transaction.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'supply.dart';
|
||||
|
||||
// todo : show est. time remaining until inventory gets empty (based on demand)
|
||||
|
@ -33,7 +32,7 @@ class _ItemViewState extends State<ItemView> {
|
|||
builder: (context) => ItemStatPage(widget.item),
|
||||
));
|
||||
},
|
||||
icon: Icon(Icons.bar_chart))
|
||||
icon: const Icon(Icons.bar_chart))
|
||||
],
|
||||
),
|
||||
body: Column(children: [
|
||||
|
|
|
@ -107,7 +107,7 @@ class _LocationViewState extends State<LocationView> {
|
|||
title: Text(widget.location.name),
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Card(
|
||||
|
|
|
@ -24,7 +24,9 @@ class StatsPage extends StatelessWidget {
|
|||
// global origin / destinations
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text("Home"),),
|
||||
appBar: AppBar(
|
||||
title: const Text("Home"),
|
||||
),
|
||||
body: FutureBuilder(
|
||||
future: _fetchData(),
|
||||
builder: (context, snapshot) {
|
||||
|
@ -47,11 +49,11 @@ class StatsPage extends StatelessWidget {
|
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
IconText(Icons.data_object,
|
||||
"Items: ${globalStat.item_count}"),
|
||||
"Items: ${globalStat.itemCount}"),
|
||||
IconText(Icons.list_alt,
|
||||
"Inventory: ${globalStat.total_transactions}"),
|
||||
"Inventory: ${globalStat.totalTransactions}"),
|
||||
IconText(Icons.money,
|
||||
"Price: ${globalStat.total_price.toStringAsFixed(2)} €")
|
||||
"Price: ${globalStat.totalPrice.toStringAsFixed(2)} €")
|
||||
],
|
||||
),
|
||||
)),
|
||||
|
@ -110,7 +112,7 @@ class ItemStatPage extends StatelessWidget {
|
|||
return Column(children: [
|
||||
Text("Inventory: ${originStat.inventory}"),
|
||||
Text(
|
||||
"Average Price: ${originStat.average_price.toStringAsFixed(2)} €"),
|
||||
"Average Price: ${originStat.averagePrice.toStringAsFixed(2)} €"),
|
||||
]);
|
||||
}).toList()
|
||||
],
|
||||
|
|
|
@ -132,12 +132,15 @@ class _TransactionPageState extends State<TransactionPage> {
|
|||
children: [
|
||||
// todo : human names
|
||||
Text(
|
||||
"${API().getItem(transaction.item).name}",
|
||||
API().getItem(transaction.item).name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold, fontSize: 28),
|
||||
),
|
||||
Text(
|
||||
"${API().getItem(transaction.item).variants[transaction.variant]!.name}",
|
||||
API()
|
||||
.getItem(transaction.item)
|
||||
.variants[transaction.variant]!
|
||||
.name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
|
@ -355,7 +358,7 @@ class TransactionSelectPage extends StatelessWidget {
|
|||
body: ListView(
|
||||
children: selectionList.isEmpty
|
||||
? [
|
||||
ListTile(
|
||||
const ListTile(
|
||||
title: Center(child: Text("No Transactions available")),
|
||||
)
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue