update
This commit is contained in:
parent
3669b00fd6
commit
aa816f8893
2 changed files with 18 additions and 10 deletions
|
@ -3,13 +3,10 @@ import 'package:cdb_ui/pages/supply.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ConsumePage extends StatefulWidget {
|
||||
final String item;
|
||||
final String variant;
|
||||
final String transaction;
|
||||
final Transaction transaction;
|
||||
final Function refresh;
|
||||
|
||||
const ConsumePage(this.transaction, this.item, this.variant, this.refresh,
|
||||
{super.key});
|
||||
const ConsumePage(this.transaction, this.refresh, {super.key});
|
||||
|
||||
@override
|
||||
State<ConsumePage> createState() => _ConsumePageState();
|
||||
|
@ -30,7 +27,8 @@ class _ConsumePageState extends State<ConsumePage> {
|
|||
_formKey.currentState!.save();
|
||||
|
||||
API()
|
||||
.consumeItem(widget.transaction, _selectedDestination, "$_price €")
|
||||
.consumeItem(
|
||||
widget.transaction.uuid, _selectedDestination, "$_price €")
|
||||
.then((_) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Item consumed successfully!')),
|
||||
|
@ -48,8 +46,8 @@ class _ConsumePageState extends State<ConsumePage> {
|
|||
title: const Text('Consume Item'),
|
||||
),
|
||||
body: FutureBuilder(
|
||||
future:
|
||||
API().getUniqueField(widget.item, widget.variant, "destination"),
|
||||
future: API().getUniqueField(
|
||||
widget.transaction.item, widget.transaction.variant, "destination"),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
|
|
|
@ -6,8 +6,9 @@ import 'package:qr_bar_code/qr/qr.dart';
|
|||
|
||||
class TransactionPage extends StatelessWidget {
|
||||
final Transaction transaction;
|
||||
final Function? refresh;
|
||||
|
||||
const TransactionPage(this.transaction, {super.key});
|
||||
const TransactionPage(this.transaction, {this.refresh, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -48,6 +49,15 @@ class TransactionPage extends StatelessWidget {
|
|||
// todo : chart with price history
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ConsumePage(transaction, refresh ?? () {});
|
||||
},
|
||||
));
|
||||
},
|
||||
child: const Icon(Icons.receipt_long)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +74,7 @@ class TransactionCard extends StatelessWidget {
|
|||
onTap: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ConsumePage(t.uuid, t.item, t.variant, refresh);
|
||||
return ConsumePage(t, refresh);
|
||||
},
|
||||
));
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue