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
|
|
@ -2,8 +2,9 @@
|
|||
// keyboard). Modes:
|
||||
// search — the box: empty = yesterday's foods (this meal first; + adds one as it was, a tap picks
|
||||
// it to change the portion); typed = My foods · Eaten before · Food database · Products
|
||||
// (+ ones kept from the archive); a barcode (typed or scanned — the camera button) = that
|
||||
// product; "Search all products…" = the archive on the sync server (food_archive.dart)
|
||||
// (+ ones kept from the archive); a barcode (typed or scanned — the camera button) = My foods
|
||||
// with it, else that product; nothing → "New food with barcode …" (it's kept with the food);
|
||||
// "Search all products…" = the archive on the sync server (food_archive.dart)
|
||||
// food — the picked food: amount + unit (g, ml, its portions, tbsp / tsp), the numbers live, meal
|
||||
// totals — an entry without a food (Lifesum imports, estimates): name, kcal / P / C / F
|
||||
// Editing an entry opens it in food or totals mode; Delete = tap twice.
|
||||
|
|
@ -143,8 +144,8 @@ class _FoodSheetState extends State<FoodSheet> {
|
|||
if (rest.isNotEmpty) sections.add(('Yesterday · other meals', [for (final e in rest) _yday(e, already(e))]));
|
||||
final recent = recentFoods(store, '', limit: 8);
|
||||
if (recent.isNotEmpty) sections.add(('Eaten often', [for (final (e, n) in recent) _recent(e, n)]));
|
||||
} else if (RegExp(r'^\d{8,14}$').hasMatch(text)) { // a barcode: that product, here or kept
|
||||
final found = widget.fdb?.byBarcode(text) ?? keptByBarcode(store, text);
|
||||
} else if (RegExp(r'^\d{4,14}$').hasMatch(text)) { // a barcode or its start: My foods, products here or kept
|
||||
final found = _byBarcode(text, prefix: true);
|
||||
sections.add(('Barcode $text', [
|
||||
for (final f in found) _foodTile(f),
|
||||
if (found.isEmpty) const Padding(padding: EdgeInsets.symmetric(vertical: 6),
|
||||
|
|
@ -194,12 +195,13 @@ class _FoodSheetState extends State<FoodSheet> {
|
|||
if (text.isNotEmpty)
|
||||
TextButton.icon(
|
||||
onPressed: () async {
|
||||
final uid = await openFoodEditor(context, widget.sync, name: text);
|
||||
final code = RegExp(r'^\d{8,14}$').hasMatch(text);
|
||||
final uid = await openFoodEditor(context, widget.sync, name: code ? '' : text, barcode: code ? text : '');
|
||||
final f = uid == null ? null : myFoodByUid(widget.sync.store, uid);
|
||||
if (f != null && mounted) _pick(f);
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text('New food “$text” (from its label)'),
|
||||
label: Text(RegExp(r'^\d{8,14}$').hasMatch(text) ? 'New food with barcode $text (from its label)' : 'New food “$text” (from its label)'),
|
||||
),
|
||||
if (text.isNotEmpty)
|
||||
TextButton.icon(
|
||||
|
|
@ -225,11 +227,18 @@ class _FoodSheetState extends State<FoodSheet> {
|
|||
if (f != null && mounted) _pick(f);
|
||||
}
|
||||
|
||||
/// The camera → a barcode: its product here, else straight to the archive.
|
||||
/// My foods with that barcode first, then the food database's product (or a kept one); [prefix]: starting with it.
|
||||
List<Food> _byBarcode(String code, {bool prefix = false}) => [
|
||||
...myFoodsByBarcode(widget.sync.store, code, prefix: prefix),
|
||||
...widget.fdb?.byBarcode(code, prefix: prefix) ?? keptByBarcode(widget.sync.store, code, prefix: prefix),
|
||||
];
|
||||
|
||||
/// The camera → a barcode: My foods / its product here, else straight to the archive (nothing there either:
|
||||
/// the box keeps the barcode, with "New food with barcode …").
|
||||
Future<void> _scan() async {
|
||||
final code = await scanBarcode(context);
|
||||
if (code == null || !mounted) return;
|
||||
final here = widget.fdb?.byBarcode(code) ?? keptByBarcode(widget.sync.store, code);
|
||||
final here = _byBarcode(code);
|
||||
if (here.length == 1) return _pick(here.first);
|
||||
setState(() => q.text = code);
|
||||
if (here.isEmpty) await _archive(code);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue