From 619f7b804aea58df942081741d243e7717ab0ead Mon Sep 17 00:00:00 2001 From: JMARyA Date: Sun, 15 Dec 2024 03:59:32 +0100 Subject: [PATCH] remove stats --- lib/main.dart | 4 +-- lib/pages/{stats.dart => home.dart} | 55 ++--------------------------- lib/pages/itemview.dart | 15 ++------ 3 files changed, 6 insertions(+), 68 deletions(-) rename lib/pages/{stats.dart => home.dart} (64%) diff --git a/lib/main.dart b/lib/main.dart index 815427e..2d6afb7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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 main() async { @@ -68,7 +68,7 @@ class _MyHomePageState extends State { int pageIndex = 0; List pages = [ - const StatsPage(), + const HomePage(), const ItemsPage(), const FlowsPage(), const LocationsPage() diff --git a/lib/pages/stats.dart b/lib/pages/home.dart similarity index 64% rename from lib/pages/stats.dart rename to lib/pages/home.dart index 80ecceb..e3081bd 100644 --- a/lib/pages/stats.dart +++ b/lib/pages/home.dart @@ -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, List, 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()) - ]), - ); - } -} diff --git a/lib/pages/itemview.dart b/lib/pages/itemview.dart index 8ea7415..6d8d367 100644 --- a/lib/pages/itemview.dart +++ b/lib/pages/itemview.dart @@ -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 { @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),