update stat
This commit is contained in:
parent
167a4620fe
commit
d21554cddc
1 changed files with 35 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'package:cdb_ui/api.dart';
|
import 'package:cdb_ui/api.dart';
|
||||||
|
import 'package:cdb_ui/pages/expandable_list.dart';
|
||||||
import 'package:cdb_ui/pages/transaction.dart';
|
import 'package:cdb_ui/pages/transaction.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
@ -85,16 +86,48 @@ class ItemStatPage extends StatelessWidget {
|
||||||
|
|
||||||
const ItemStatPage(this.item, {super.key});
|
const ItemStatPage(this.item, {super.key});
|
||||||
|
|
||||||
// todo : expiry ratio
|
|
||||||
// todo : avg time of transaction active
|
// todo : avg time of transaction active
|
||||||
|
|
||||||
|
ExpandableListItem buildVariantStat(String variant) {
|
||||||
|
return ExpandableListItem(
|
||||||
|
body: FutureBuilder(
|
||||||
|
future: API().getStat(item.id, variant, full: true),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (!snapshot.hasData) {
|
||||||
|
return const CircularProgressIndicator();
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = snapshot.data! as FullItemVariantStat;
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Text("Amount: ${data.amount}"),
|
||||||
|
Text("Total Cost: ${data.totalPrice}"),
|
||||||
|
Text("Expiry Rate: ${data.expiryRate}"),
|
||||||
|
...data.origins.keys.map((key) {
|
||||||
|
var originStat = data.origins[key]!;
|
||||||
|
return Column(children: [
|
||||||
|
Text("Inventory: ${originStat.inventory}"),
|
||||||
|
Text(
|
||||||
|
"Average Price: ${originStat.average_price.toStringAsFixed(2)} €"),
|
||||||
|
]);
|
||||||
|
}).toList()
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
header: Text(item.variants[variant]!.name));
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("Statistics of ${item.name}"),
|
title: Text("Statistics of ${item.name}"),
|
||||||
),
|
),
|
||||||
body: null,
|
body: Column(children: [
|
||||||
|
ExpandableList(item.variants.keys.map(buildVariantStat).toList())
|
||||||
|
]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue