Skip to content

Commit 34c2123

Browse files
committed
macros table cleanup step 1
1 parent 3d2ef58 commit 34c2123

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

lib/widgets/nutrition/macro_nutrients_table.dart

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class MacronutrientsTable extends StatelessWidget {
1717

1818
@override
1919
Widget build(BuildContext context) {
20+
final loc = AppLocalizations.of(context);
21+
2022
return Table(
2123
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
2224
border: TableBorder(
@@ -32,20 +34,20 @@ class MacronutrientsTable extends StatelessWidget {
3234
Padding(
3335
padding: const EdgeInsets.symmetric(vertical: tablePadding),
3436
child: Text(
35-
AppLocalizations.of(context).macronutrients,
37+
loc.macronutrients,
3638
style: const TextStyle(fontWeight: FontWeight.bold),
3739
),
3840
),
3941
Text(
40-
AppLocalizations.of(context).total,
42+
loc.total,
4143
style: const TextStyle(fontWeight: FontWeight.bold),
4244
),
4345
Text(
44-
AppLocalizations.of(context).percentEnergy,
46+
loc.percentEnergy,
4547
style: const TextStyle(fontWeight: FontWeight.bold),
4648
),
4749
Text(
48-
AppLocalizations.of(context).gPerBodyKg,
50+
loc.gPerBodyKg,
4951
style: const TextStyle(fontWeight: FontWeight.bold),
5052
),
5153
],
@@ -54,11 +56,11 @@ class MacronutrientsTable extends StatelessWidget {
5456
children: [
5557
Padding(
5658
padding: const EdgeInsets.symmetric(vertical: tablePadding),
57-
child: Text(AppLocalizations.of(context).energy),
59+
child: Text(loc.energy),
5860
),
5961
Text(
6062
nutritionalGoals.energy != null
61-
? nutritionalGoals.energy!.toStringAsFixed(0) + AppLocalizations.of(context).kcal
63+
? loc.kcalValue(nutritionalGoals.energy!.toStringAsFixed(0))
6264
: '',
6365
),
6466
const Text(''),
@@ -69,10 +71,10 @@ class MacronutrientsTable extends StatelessWidget {
6971
children: [
7072
Padding(
7173
padding: const EdgeInsets.symmetric(vertical: tablePadding),
72-
child: Text(AppLocalizations.of(context).protein),
74+
child: Text(loc.protein),
7375
),
7476
Text(nutritionalGoals.protein != null
75-
? nutritionalGoals.protein!.toStringAsFixed(0) + AppLocalizations.of(context).g
77+
? loc.gValue(nutritionalGoals.protein!.toStringAsFixed(0))
7678
: ''),
7779
Text(plannedValuesPercentage.protein != null
7880
? plannedValuesPercentage.protein!.toStringAsFixed(1)
@@ -86,11 +88,10 @@ class MacronutrientsTable extends StatelessWidget {
8688
children: [
8789
Padding(
8890
padding: const EdgeInsets.symmetric(vertical: tablePadding),
89-
child: Text(AppLocalizations.of(context).carbohydrates),
91+
child: Text(loc.carbohydrates),
9092
),
9193
Text(nutritionalGoals.carbohydrates != null
92-
? nutritionalGoals.carbohydrates!.toStringAsFixed(0) +
93-
AppLocalizations.of(context).g
94+
? loc.gValue(nutritionalGoals.carbohydrates!.toStringAsFixed(0))
9495
: ''),
9596
Text(plannedValuesPercentage.carbohydrates != null
9697
? plannedValuesPercentage.carbohydrates!.toStringAsFixed(1)
@@ -104,24 +105,23 @@ class MacronutrientsTable extends StatelessWidget {
104105
children: [
105106
Padding(
106107
padding: const EdgeInsets.symmetric(vertical: tablePadding, horizontal: 12),
107-
child: Text(AppLocalizations.of(context).sugars),
108+
child: Text(loc.sugars),
108109
),
109110
const Text(''),
110111
const Text(''),
111112
Text(nutritionalGoals.carbohydratesSugar != null
112-
? nutritionalGoals.carbohydratesSugar!.toStringAsFixed(0) +
113-
AppLocalizations.of(context).g
113+
? loc.gValue(nutritionalGoals.carbohydratesSugar!.toStringAsFixed(0))
114114
: ''),
115115
],
116116
),
117117
TableRow(
118118
children: [
119119
Padding(
120120
padding: const EdgeInsets.symmetric(vertical: tablePadding),
121-
child: Text(AppLocalizations.of(context).fat),
121+
child: Text(loc.fat),
122122
),
123123
Text(nutritionalGoals.fat != null
124-
? nutritionalGoals.fat!.toStringAsFixed(0) + AppLocalizations.of(context).g
124+
? loc.gValue(nutritionalGoals.fat!.toStringAsFixed(0))
125125
: ''),
126126
Text(plannedValuesPercentage.fat != null
127127
? plannedValuesPercentage.fat!.toStringAsFixed(1)
@@ -135,38 +135,38 @@ class MacronutrientsTable extends StatelessWidget {
135135
children: [
136136
Padding(
137137
padding: const EdgeInsets.symmetric(vertical: tablePadding, horizontal: 12),
138-
child: Text(AppLocalizations.of(context).saturatedFat),
138+
child: Text(loc.saturatedFat),
139139
),
140140
const Text(''),
141141
const Text(''),
142142
Text(nutritionalGoals.fatSaturated != null
143-
? nutritionalGoals.fatSaturated!.toStringAsFixed(0) + AppLocalizations.of(context).g
143+
? loc.gValue(nutritionalGoals.fatSaturated!.toStringAsFixed(0))
144144
: ''),
145145
],
146146
),
147147
TableRow(
148148
children: [
149149
Padding(
150150
padding: const EdgeInsets.symmetric(vertical: tablePadding),
151-
child: Text(AppLocalizations.of(context).fiber),
151+
child: Text(loc.fiber),
152152
),
153153
const Text(''),
154154
const Text(''),
155155
Text(nutritionalGoals.fiber != null
156-
? nutritionalGoals.fiber!.toStringAsFixed(0) + AppLocalizations.of(context).g
156+
? loc.gValue(nutritionalGoals.fiber!.toStringAsFixed(0))
157157
: ''),
158158
],
159159
),
160160
TableRow(
161161
children: [
162162
Padding(
163163
padding: const EdgeInsets.symmetric(vertical: tablePadding),
164-
child: Text(AppLocalizations.of(context).sodium),
164+
child: Text(loc.sodium),
165165
),
166166
const Text(''),
167167
const Text(''),
168168
Text(nutritionalGoals.sodium != null
169-
? nutritionalGoals.sodium!.toStringAsFixed(0) + AppLocalizations.of(context).g
169+
? loc.gValue(nutritionalGoals.sodium!.toStringAsFixed(0))
170170
: ''),
171171
],
172172
),

0 commit comments

Comments
 (0)