Flutter-Ernaehrungsapp/lib/pages/nav_pages/subpages/statistics_page/statistics_page.dart

72 lines
2.5 KiB
Dart
Raw Normal View History

2023-05-29 12:08:46 +02:00
import 'package:flutter/material.dart';
2023-06-25 14:43:07 +02:00
import '../../../../helper/format_helper.dart';
import '../../../../services/statistics.dart';
import 'sub_components/chart.dart';
import '../../../shared_components/secondary_text.dart';
import '../../../shared_components/title.dart';
2023-06-25 14:43:07 +02:00
class StatisticsPage extends StatelessWidget {
2023-05-29 12:08:46 +02:00
final String title;
final Color backgroundColor = const Color(0xff47a44b);
2023-06-25 14:43:07 +02:00
const StatisticsPage({Key? key, required this.title}) : super(key: key);
2023-05-29 12:08:46 +02:00
String get getTitle => title;
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return getTitle;
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
2023-06-02 01:42:56 +02:00
child: Column(
children: [
2023-06-16 08:34:41 +02:00
const ChartComponent(),
2023-06-02 01:42:56 +02:00
Container(
margin: const EdgeInsets.fromLTRB(0, 16, 0, 0),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(8))),
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: ValueListenableBuilder(
valueListenable:
2023-06-25 14:43:07 +02:00
DataService.instance.weeklyCaloryRanking,
2023-06-02 01:42:56 +02:00
builder: (context, value, child) {
return Column(
children: [
const TitleComponent(
"Lebensmittel mit dem höchsten Kaloriengehalt"),
const SizedBox(
2023-06-16 11:44:42 +02:00
height: 5,
2023-06-02 01:42:56 +02:00
),
2023-06-16 11:44:42 +02:00
for (var item in value)
2023-06-02 01:42:56 +02:00
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SecondaryTextComponent(
2023-06-16 12:03:04 +02:00
getWeeklyRankingString(item.name,context),
2023-06-16 11:44:42 +02:00
value.indexOf(item)+1
),
2023-06-02 01:42:56 +02:00
SecondaryTextComponent(
2023-06-16 11:44:42 +02:00
item.calories.toString(),
null
),
2023-06-02 01:42:56 +02:00
],
),
],
);
},
),
))
],
2023-05-29 12:08:46 +02:00
),
),
);
}
}