From b6b4d48ced9ec7b4c523b01abe0f7a79217f6f82 Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 12 Jan 2025 13:14:57 +0100 Subject: [PATCH] wip --- lib/pages/graphs_page.dart | 102 +++++++++++++++++++ lib/perdate/perdate_pageview_controller.dart | 7 ++ pubspec.lock | 16 +++ pubspec.yaml | 1 + 4 files changed, 126 insertions(+) create mode 100644 lib/pages/graphs_page.dart diff --git a/lib/pages/graphs_page.dart b/lib/pages/graphs_page.dart new file mode 100644 index 0000000..47a1aba --- /dev/null +++ b/lib/pages/graphs_page.dart @@ -0,0 +1,102 @@ +import 'package:calorimeter/utils/settings_bloc.dart'; +import 'package:fl_chart/fl_chart.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class GraphsPageWidget extends StatefulWidget { + const GraphsPageWidget({super.key}); + + @override + State createState() => _GraphsPageWidgetState(); +} + +class _GraphsPageWidgetState extends State { + late double data1; + + @override + void initState() { + super.initState(); + data1 = 40; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: BlocBuilder( + builder: (context, state) { + return BarChart( + duration: Duration(seconds: 1), + BarChartData( + extraLinesData: ExtraLinesData( + horizontalLines: [ + HorizontalLine( + y: state.kcalLimit, + color: Colors.red, + ), + ], + ), + titlesData: FlTitlesData( + topTitles: AxisTitles(), + rightTitles: AxisTitles(), + bottomTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + ), + ), + ), + gridData: FlGridData( + horizontalInterval: state.kcalLimit / 10, + drawVerticalLine: false, + ), + maxY: state.kcalLimit + 500, + barGroups: [ + BarChartGroupData( + x: 0, + barRods: [BarChartRodData(toY: state.kcalLimit)], + ), + BarChartGroupData( + x: 1, + barRods: [BarChartRodData(toY: state.kcalLimit - 500)], + ), + BarChartGroupData( + x: 2, + barRods: [BarChartRodData(toY: state.kcalLimit + 200)], + ), + BarChartGroupData( + x: 3, + barRods: [BarChartRodData(toY: state.kcalLimit + data1)], + ), + BarChartGroupData( + x: 4, + barRods: [BarChartRodData(toY: state.kcalLimit + data1)], + ), + BarChartGroupData( + x: 5, + barRods: [BarChartRodData(toY: state.kcalLimit + data1)], + ), + BarChartGroupData( + x: 6, + barRods: [BarChartRodData(toY: state.kcalLimit + data1)], + ), + ], + ), + ); + }), + floatingActionButton: OverflowBar( + children: [ + FloatingActionButton( + heroTag: "back", + onPressed: () => Navigator.of(context).pop(), + child: Icon(Icons.arrow_back)), + FloatingActionButton( + heroTag: "fuckup", + onPressed: () { + setState(() { + data1 *= 1.1; + }); + }, + child: Icon(Icons.numbers)), + ], + )); + } +} diff --git a/lib/perdate/perdate_pageview_controller.dart b/lib/perdate/perdate_pageview_controller.dart index db51168..b87e9b8 100644 --- a/lib/perdate/perdate_pageview_controller.dart +++ b/lib/perdate/perdate_pageview_controller.dart @@ -7,6 +7,7 @@ import 'package:calorimeter/perdate/perdate_pageview.dart'; import 'package:calorimeter/utils/app_drawer.dart'; import 'package:calorimeter/utils/calendar_floating_button.dart'; import 'package:calorimeter/utils/date_time_helper.dart'; +import 'package:calorimeter/pages/graphs_page.dart'; import 'package:calorimeter/utils/rectangular_notch_shape.dart'; import 'package:calorimeter/utils/scan_food_floating_button.dart'; import 'package:calorimeter/utils/sum_widget.dart'; @@ -76,6 +77,12 @@ class PerDatePageViewController extends StatelessWidget { OverflowBar _getFABs(BuildContext context) { return OverflowBar( children: [ + FloatingActionButton( + onPressed: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => const GraphsPageWidget())); + }, + child: Icon(Icons.bar_chart)), ScanFoodFAB( onPressed: () { context.read().add( diff --git a/pubspec.lock b/pubspec.lock index 04c747d..702775c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -214,6 +214,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.1" + equatable: + dependency: transitive + description: + name: equatable + sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7" + url: "https://pub.dev" + source: hosted + version: "2.0.7" fake_async: dependency: transitive description: @@ -246,6 +254,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + fl_chart: + dependency: "direct main" + description: + name: fl_chart + sha256: "10ddaf334fe84d59333a12d153043e366f243e0bdfff2df0313e1e249f5bf926" + url: "https://pub.dev" + source: hosted + version: "0.70.1" flutter: dependency: "direct main" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index babf8a4..8de376c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,6 +22,7 @@ dependencies: path_provider_platform_interface: ^2.1.2 plugin_platform_interface: ^2.1.8 http: ^1.2.2 + fl_chart: ^0.70.1 dev_dependencies: flutter_test: