72 lines
2.5 KiB
Dart
72 lines
2.5 KiB
Dart
|
import 'package:flutter/material.dart';
|
||
|
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';
|
||
|
|
||
|
class StatisticsPage extends StatelessWidget {
|
||
|
final String title;
|
||
|
final Color backgroundColor = const Color(0xff47a44b);
|
||
|
|
||
|
const StatisticsPage({Key? key, required this.title}) : super(key: key);
|
||
|
|
||
|
String get getTitle => title;
|
||
|
|
||
|
@override
|
||
|
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||
|
return getTitle;
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
body: SingleChildScrollView(
|
||
|
child: Column(
|
||
|
children: [
|
||
|
const ChartComponent(),
|
||
|
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:
|
||
|
DataService.instance.weeklyCaloryRanking,
|
||
|
builder: (context, value, child) {
|
||
|
return Column(
|
||
|
children: [
|
||
|
const TitleComponent(
|
||
|
"Lebensmittel mit dem höchsten Kaloriengehalt"),
|
||
|
const SizedBox(
|
||
|
height: 5,
|
||
|
),
|
||
|
for (var item in value)
|
||
|
Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
|
children: [
|
||
|
SecondaryTextComponent(
|
||
|
getWeeklyRankingString(item.name,context),
|
||
|
value.indexOf(item)+1
|
||
|
),
|
||
|
SecondaryTextComponent(
|
||
|
item.calories.toString(),
|
||
|
null
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
},
|
||
|
),
|
||
|
))
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|