This commit is contained in:
parent
7371b387da
commit
619f7b804a
3 changed files with 6 additions and 68 deletions
|
@ -3,7 +3,7 @@ import 'package:cdb_ui/pages/flow/flows_page.dart';
|
|||
import 'package:cdb_ui/pages/items.dart';
|
||||
import 'package:cdb_ui/pages/locations.dart';
|
||||
import 'package:cdb_ui/pages/setup.dart';
|
||||
import 'package:cdb_ui/pages/stats.dart';
|
||||
import 'package:cdb_ui/pages/home.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
|
@ -68,7 +68,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
int pageIndex = 0;
|
||||
|
||||
List<Widget> pages = [
|
||||
const StatsPage(),
|
||||
const HomePage(),
|
||||
const ItemsPage(),
|
||||
const FlowsPage(),
|
||||
const LocationsPage()
|
||||
|
|
|
@ -3,8 +3,8 @@ import 'package:cdb_ui/pages/expandable_list.dart';
|
|||
import 'package:cdb_ui/pages/transaction.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class StatsPage extends StatelessWidget {
|
||||
const StatsPage({super.key});
|
||||
class HomePage extends StatelessWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
Future<(List<MinItem>, List<Transaction>, GlobalItemStat)>
|
||||
_fetchData() async {
|
||||
|
@ -93,54 +93,3 @@ class StatsPage extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemStatPage extends StatelessWidget {
|
||||
final Item item;
|
||||
|
||||
const ItemStatPage(this.item, {super.key});
|
||||
|
||||
// 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.averagePrice.toStringAsFixed(2)} €"),
|
||||
]);
|
||||
}).toList()
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
header: Text(item.variants[variant]!.name));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Statistics of ${item.name}"),
|
||||
),
|
||||
body: Column(children: [
|
||||
ExpandableList(item.variants.keys.map(buildVariantStat).toList())
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:cdb_ui/api.dart';
|
||||
import 'package:cdb_ui/pages/stats.dart';
|
||||
import 'package:cdb_ui/pages/home.dart';
|
||||
import 'package:cdb_ui/pages/transaction.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'supply.dart';
|
||||
|
@ -23,18 +23,7 @@ class _ItemViewState extends State<ItemView> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.item.name),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => ItemStatPage(widget.item),
|
||||
));
|
||||
},
|
||||
icon: const Icon(Icons.bar_chart))
|
||||
],
|
||||
),
|
||||
appBar: AppBar(title: Text(widget.item.name)),
|
||||
body: Column(children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 28),
|
||||
|
|
Loading…
Reference in a new issue