Skip to content

Commit f18e604

Browse files
authored
Merge pull request #310 from Elxas866/309-feature-show-exceeded-kcals
Show "x kcal too much" when exceeding calorie goal by x kcal.
2 parents 9c646a2 + ba43467 commit f18e604

4 files changed

Lines changed: 21 additions & 6 deletions

File tree

lib/features/home/presentation/widgets/dashboard_widget.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,19 @@ class DashboardWidget extends StatefulWidget {
3737
class _DashboardWidgetState extends State<DashboardWidget> {
3838
@override
3939
Widget build(BuildContext context) {
40-
double kcalLeftLabel = 0;
40+
double kcalValue = 0;
4141
double gaugeValue = 0;
42+
String kcalLabelText = S.of(context).kcalLeftLabel;
43+
4244
if (widget.totalKcalLeft > widget.totalKcalDaily) {
43-
kcalLeftLabel = widget.totalKcalDaily;
45+
kcalValue = widget.totalKcalDaily;
4446
gaugeValue = 0;
4547
} else if (widget.totalKcalLeft < 0) {
46-
kcalLeftLabel = 0;
48+
kcalValue = widget.totalKcalLeft.abs();
4749
gaugeValue = 1;
50+
kcalLabelText = S.of(context).kcalTooMuchLabel;
4851
} else {
49-
kcalLeftLabel = widget.totalKcalLeft;
52+
kcalValue = widget.totalKcalLeft;
5053
gaugeValue = (widget.totalKcalDaily - widget.totalKcalLeft) /
5154
widget.totalKcalDaily;
5255
}
@@ -98,7 +101,7 @@ class _DashboardWidgetState extends State<DashboardWidget> {
98101
children: [
99102
AnimatedFlipCounter(
100103
duration: const Duration(milliseconds: 1000),
101-
value: kcalLeftLabel.toInt(),
104+
value: kcalValue.toInt(),
102105
textStyle: Theme.of(
103106
context,
104107
).textTheme.headlineMedium?.copyWith(
@@ -107,7 +110,7 @@ class _DashboardWidgetState extends State<DashboardWidget> {
107110
),
108111
),
109112
Text(
110-
S.of(context).kcalLeftLabel,
113+
kcalLabelText,
111114
style: Theme.of(
112115
context,
113116
).textTheme.titleMedium?.copyWith(

lib/generated/l10n.dart

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/l10n/intl_de.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"suppliedLabel": "zugeführt",
109109
"burnedLabel": "verbrannt",
110110
"kcalLeftLabel": "kcal übrig",
111+
"kcalTooMuchLabel": "kcal zu viel",
111112
"nutritionInfoLabel": "Nährwertangaben",
112113
"kcalLabel": "kcal",
113114
"carbsLabel": "Kohlenhydrate",

lib/l10n/intl_en.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"suppliedLabel": "supplied",
114114
"burnedLabel": "burned",
115115
"kcalLeftLabel": "kcal left",
116+
"kcalTooMuchLabel": "kcal too much",
116117
"nutritionInfoLabel": "Nutrition Information",
117118
"kcalLabel": "kcal",
118119
"carbsLabel": "carbs",

0 commit comments

Comments
 (0)