Food: week strip shows protein / carbs / fat; over-target days in red
Each day's bar is stacked by the share of the energy from protein, carbs and fat (as in the History chart); hovering shows the calories and grams. A day more than 5 % over its target shows its calories in bold red. Dashboard and app. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c54f66c3c2
commit
2869a208f1
5 changed files with 46 additions and 11 deletions
|
|
@ -19,6 +19,8 @@ What changed in each published build of the app. `tool/publish.sh` shows the ent
|
|||
search box, finds that food first.
|
||||
- Food: a barcode nothing is found for offers "New food with barcode …", which opens the editor with the
|
||||
barcode filled in. The dashboard does the same.
|
||||
- Food: the week strip's day pills show the day's protein / carbs / fat in their colours (by their share of the
|
||||
energy), and a day over its target has its calories in red. The dashboard does the same.
|
||||
|
||||
## 1.1.3 — 2026-10-26
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ class _FoodPageState extends State<FoodPage> {
|
|||
Widget _week(double target) {
|
||||
final mon = plus(d, -(d.weekday - 1));
|
||||
final k = kcalByDay(widget.sync.store, dayIso(mon), dayIso(plus(mon, 6)));
|
||||
final m = dayTotals(widget.sync.store, dayIso(mon), dayIso(plus(mon, 6)));
|
||||
return Row(children: [
|
||||
for (var i = 0; i < 7; i++)
|
||||
() {
|
||||
|
|
@ -140,12 +141,13 @@ class _FoodPageState extends State<FoodPage> {
|
|||
const SizedBox(height: 3),
|
||||
Container(
|
||||
width: 12, height: 32, alignment: Alignment.bottomCenter,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(color: card2, borderRadius: BorderRadius.circular(3)),
|
||||
child: FractionallySizedBox(heightFactor: h / 1.15,
|
||||
child: Container(decoration: BoxDecoration(color: over ? bad : good, borderRadius: BorderRadius.circular(3)))),
|
||||
child: FractionallySizedBox(heightFactor: h / 1.15, child: _macroFill(m[dayIso(x)], kc)),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(kc == null ? '' : '${kc.round()}', style: const TextStyle(fontSize: 10.5, color: muted)),
|
||||
Text(kc == null ? '' : '${kc.round()}',
|
||||
style: TextStyle(fontSize: 10.5, color: over ? bad : muted, fontWeight: over ? FontWeight.bold : null)),
|
||||
]),
|
||||
),
|
||||
),
|
||||
|
|
@ -154,6 +156,20 @@ class _FoodPageState extends State<FoodPage> {
|
|||
]);
|
||||
}
|
||||
|
||||
/// A week pill's fill, bottom up: protein / carbs / fat by their share of the energy, the rest grey
|
||||
/// (views._macro_segs — as the History chart stacks them).
|
||||
Widget _macroFill(Map<String, double>? t, double? kcal) {
|
||||
if (t == null || kcal == null || kcal <= 0) return const SizedBox();
|
||||
final e = {for (final k in macros) k: (t[k] ?? 0) * kcalPerG[k]!};
|
||||
final total = max(kcal, e.values.fold<double>(0, (a, b) => a + b));
|
||||
final rest = total - e.values.fold<double>(0, (a, b) => a + b);
|
||||
return Column(children: [
|
||||
if (rest / total > 0.005) Expanded(flex: (rest / total * 1000).round(), child: Container(color: muted.withValues(alpha: 0.5))),
|
||||
for (final k in macros.reversed)
|
||||
if (e[k]! > 0) Expanded(flex: (e[k]! / total * 1000).round(), child: Container(color: macroColors[k])),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _meal(String m, List<Entry> es) {
|
||||
final t = totals(es);
|
||||
// a long-pressed food can be dropped on another meal's card (db.move: only the meal changes)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue