@@ -98,18 +98,20 @@ class NutritionDiaryTable extends StatelessWidget {
98
98
),
99
99
);
100
100
101
- TableRow macroRow (int indent, String title, double Function (NutritionalValues nv) get ) =>
102
- TableRow (
103
- children: [
104
- Padding (
105
- padding: EdgeInsets .symmetric (vertical: tablePadding, horizontal: indent * 12 ),
106
- child: Text (title),
107
- ),
108
- Text (loc.gValue (get (planned).toStringAsFixed (0 )), textAlign: TextAlign .right),
109
- Text (loc.gValue (get (logged).toStringAsFixed (0 )), textAlign: TextAlign .right),
110
- Text ((get (logged) - get (planned)).toStringAsFixed (0 ), textAlign: TextAlign .right),
111
- ],
112
- );
101
+ TableRow macroRow (int indent, bool g, String title, double Function (NutritionalValues nv) get ) {
102
+ final valFn = g ? loc.gValue : loc.kcalValue;
103
+ return TableRow (
104
+ children: [
105
+ Padding (
106
+ padding: EdgeInsets .symmetric (vertical: tablePadding, horizontal: indent * 12 ),
107
+ child: Text (title),
108
+ ),
109
+ Text (valFn (get (planned).toStringAsFixed (0 )), textAlign: TextAlign .right),
110
+ Text (valFn (get (logged).toStringAsFixed (0 )), textAlign: TextAlign .right),
111
+ Text ((get (logged) - get (planned)).toStringAsFixed (0 ), textAlign: TextAlign .right),
112
+ ],
113
+ );
114
+ }
113
115
114
116
return Table (
115
117
defaultVerticalAlignment: TableCellVerticalAlignment .middle,
@@ -124,14 +126,14 @@ class NutritionDiaryTable extends StatelessWidget {
124
126
columnHeader (false , loc.logged),
125
127
columnHeader (false , loc.difference),
126
128
]),
127
- macroRow (0 , loc.energy, (NutritionalValues nv) => nv.energy),
128
- macroRow (0 , loc.protein, (NutritionalValues nv) => nv.protein),
129
- macroRow (0 , loc.carbohydrates, (NutritionalValues nv) => nv.carbohydrates),
130
- macroRow (1 , loc.sugars, (NutritionalValues nv) => nv.carbohydratesSugar),
131
- macroRow (0 , loc.fat, (NutritionalValues nv) => nv.fat),
132
- macroRow (1 , loc.saturatedFat, (NutritionalValues nv) => nv.fatSaturated),
133
- macroRow (0 , loc.fiber, (NutritionalValues nv) => nv.fiber),
134
- macroRow (0 , loc.sodium, (NutritionalValues nv) => nv.sodium),
129
+ macroRow (0 , false , loc.energy, (NutritionalValues nv) => nv.energy),
130
+ macroRow (0 , true , loc.protein, (NutritionalValues nv) => nv.protein),
131
+ macroRow (0 , true , loc.carbohydrates, (NutritionalValues nv) => nv.carbohydrates),
132
+ macroRow (1 , true , loc.sugars, (NutritionalValues nv) => nv.carbohydratesSugar),
133
+ macroRow (0 , true , loc.fat, (NutritionalValues nv) => nv.fat),
134
+ macroRow (1 , true , loc.saturatedFat, (NutritionalValues nv) => nv.fatSaturated),
135
+ macroRow (0 , true , loc.fiber, (NutritionalValues nv) => nv.fiber),
136
+ macroRow (0 , true , loc.sodium, (NutritionalValues nv) => nv.sodium),
135
137
],
136
138
);
137
139
}
0 commit comments