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';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ConsumePage extends StatefulWidget {
|
class ConsumePage extends StatefulWidget {
|
||||||
final String item;
|
final Transaction transaction;
|
||||||
final String variant;
|
|
||||||
final String transaction;
|
|
||||||
final Function refresh;
|
final Function refresh;
|
||||||
|
|
||||||
const ConsumePage(this.transaction, this.item, this.variant, this.refresh,
|
const ConsumePage(this.transaction, this.refresh, {super.key});
|
||||||
{super.key});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ConsumePage> createState() => _ConsumePageState();
|
State<ConsumePage> createState() => _ConsumePageState();
|
||||||
|
@ -30,7 +27,8 @@ class _ConsumePageState extends State<ConsumePage> {
|
||||||
_formKey.currentState!.save();
|
_formKey.currentState!.save();
|
||||||
|
|
||||||
API()
|
API()
|
||||||
.consumeItem(widget.transaction, _selectedDestination, "$_price €")
|
.consumeItem(
|
||||||
|
widget.transaction.uuid, _selectedDestination, "$_price €")
|
||||||
.then((_) {
|
.then((_) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('Item consumed successfully!')),
|
const SnackBar(content: Text('Item consumed successfully!')),
|
||||||
|
@ -48,8 +46,8 @@ class _ConsumePageState extends State<ConsumePage> {
|
||||||
title: const Text('Consume Item'),
|
title: const Text('Consume Item'),
|
||||||
),
|
),
|
||||||
body: FutureBuilder(
|
body: FutureBuilder(
|
||||||
future:
|
future: API().getUniqueField(
|
||||||
API().getUniqueField(widget.item, widget.variant, "destination"),
|
widget.transaction.item, widget.transaction.variant, "destination"),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
|
|
@ -6,8 +6,9 @@ import 'package:qr_bar_code/qr/qr.dart';
|
||||||
|
|
||||||
class TransactionPage extends StatelessWidget {
|
class TransactionPage extends StatelessWidget {
|
||||||
final Transaction transaction;
|
final Transaction transaction;
|
||||||
|
final Function? refresh;
|
||||||
|
|
||||||
const TransactionPage(this.transaction, {super.key});
|
const TransactionPage(this.transaction, {this.refresh, super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -48,6 +49,15 @@ class TransactionPage extends StatelessWidget {
|
||||||
// todo : chart with price history
|
// 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: () {
|
onTap: () {
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return ConsumePage(t.uuid, t.item, t.variant, refresh);
|
return ConsumePage(t, refresh);
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue