Food, sync and warmer updates from 2026-10-26
- Food: "All products" lists what's here first (My foods, the food database, kept products), then Open Food Facts; the start of a barcode (4+ digits) finds the products starting with it (dashboard, app, server search). - Food: My foods barcodes; entries follow edits of their food or meal, and meals made with a changed food are worked out again (nested meals too); a save that changes nothing isn't written. - Food: the week strip shows protein / carbs / fat per day, over-target calories in red; the header's arrows go by week, days swap in place with prefetch on hover; the app's arrows go by week, a sideways swipe by day. - Food search: stomach / žalúdok / pipotă find gizzards, kurací / pui chicken, morčací / curcan turkey. - Sync: tables a plugin makes after start-up are prepared at the next sync and their file read from the start once. - Warmers build pages as each admin account and wait while someone is using the dashboard; slow page builds are logged. - Stations: impossible sensor readings are dropped; chart ticks never fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fb3c01cdd7
commit
4193de4262
26 changed files with 704 additions and 111 deletions
|
|
@ -92,7 +92,18 @@ class _FoodPageState extends State<FoodPage> {
|
|||
label: Text(es.isEmpty ? 'Make a meal' : 'Make a meal (from this day’s entries)'),
|
||||
),
|
||||
];
|
||||
return ListView(padding: const EdgeInsets.fromLTRB(12, 10, 12, 24), children: [
|
||||
// the arrows go by week; a swipe sideways goes by day
|
||||
return GestureDetector(
|
||||
onHorizontalDragEnd: (e) {
|
||||
final v = e.primaryVelocity ?? 0;
|
||||
if (v.abs() < 300) return;
|
||||
if (v > 0) {
|
||||
setState(() => d = plus(d, -1));
|
||||
} else if (daysBetween(today(), d) < ahead) {
|
||||
setState(() => d = plus(d, 1));
|
||||
}
|
||||
},
|
||||
child: ListView(padding: const EdgeInsets.fromLTRB(12, 10, 12, 24), children: [
|
||||
if (wide)
|
||||
Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Expanded(child: Column(children: head)),
|
||||
|
|
@ -100,13 +111,14 @@ class _FoodPageState extends State<FoodPage> {
|
|||
Expanded(child: Column(children: meals)),
|
||||
])
|
||||
else ...[...head, const SizedBox(height: 10), ...meals],
|
||||
]);
|
||||
]),
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
Widget _nav() => Row(children: [
|
||||
IconButton(onPressed: () => setState(() => d = plus(d, -1)), icon: const Icon(Icons.chevron_left)),
|
||||
IconButton(tooltip: 'Week before', onPressed: () => setState(() => d = plus(d, -7)), icon: const Icon(Icons.chevron_left)),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => setState(() => d = today()),
|
||||
|
|
@ -115,13 +127,15 @@ class _FoodPageState extends State<FoodPage> {
|
|||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: daysBetween(today(), d) < ahead ? () => setState(() => d = plus(d, 1)) : null,
|
||||
tooltip: 'Week after',
|
||||
onPressed: daysBetween(today(), d) + 7 <= ahead ? () => setState(() => d = plus(d, 7)) : null,
|
||||
icon: const Icon(Icons.chevron_right)),
|
||||
]);
|
||||
|
||||
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 +154,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 +169,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