Draft: wip graphs #12
102
lib/pages/graphs_page.dart
Normal file
102
lib/pages/graphs_page.dart
Normal file
@ -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<GraphsPageWidget> createState() => _GraphsPageWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GraphsPageWidgetState extends State<GraphsPageWidget> {
|
||||||
|
late double data1;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
data1 = 40;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: BlocBuilder<SettingsDataBloc, SettingsState>(
|
||||||
|
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)),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ import 'package:calorimeter/perdate/perdate_pageview.dart';
|
|||||||
import 'package:calorimeter/utils/app_drawer.dart';
|
import 'package:calorimeter/utils/app_drawer.dart';
|
||||||
import 'package:calorimeter/utils/calendar_floating_button.dart';
|
import 'package:calorimeter/utils/calendar_floating_button.dart';
|
||||||
import 'package:calorimeter/utils/date_time_helper.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/rectangular_notch_shape.dart';
|
||||||
import 'package:calorimeter/utils/scan_food_floating_button.dart';
|
import 'package:calorimeter/utils/scan_food_floating_button.dart';
|
||||||
import 'package:calorimeter/utils/sum_widget.dart';
|
import 'package:calorimeter/utils/sum_widget.dart';
|
||||||
@ -76,6 +77,12 @@ class PerDatePageViewController extends StatelessWidget {
|
|||||||
OverflowBar _getFABs(BuildContext context) {
|
OverflowBar _getFABs(BuildContext context) {
|
||||||
return OverflowBar(
|
return OverflowBar(
|
||||||
children: [
|
children: [
|
||||||
|
FloatingActionButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
|
builder: (context) => const GraphsPageWidget()));
|
||||||
|
},
|
||||||
|
child: Icon(Icons.bar_chart)),
|
||||||
ScanFoodFAB(
|
ScanFoodFAB(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.read<FoodEntryBloc>().add(
|
context.read<FoodEntryBloc>().add(
|
||||||
|
16
pubspec.lock
16
pubspec.lock
@ -214,6 +214,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "3.0.1"
|
||||||
|
equatable:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: equatable
|
||||||
|
sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.7"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -246,6 +254,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
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:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -22,6 +22,7 @@ dependencies:
|
|||||||
path_provider_platform_interface: ^2.1.2
|
path_provider_platform_interface: ^2.1.2
|
||||||
plugin_platform_interface: ^2.1.8
|
plugin_platform_interface: ^2.1.8
|
||||||
http: ^1.2.2
|
http: ^1.2.2
|
||||||
|
fl_chart: ^0.70.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
Reference in New Issue
Block a user