feat: dish recognition job context, diary linkage, home widget, history page
Backend: - Rename recognition_jobs → dish_recognition_jobs; add target_date and target_meal_type columns to capture scan context at submission time - Add job_id FK on meal_diary so entries are linked to their origin job - New GET /ai/jobs endpoint returns today's unlinked jobs for the current user - diary.Entry and CreateRequest gain job_id field; repository reads/writes it - CORS middleware: allow Accept-Language and Cache-Control headers - Logging middleware: implement http.Flusher on responseWriter (needed for SSE) - Consolidate migrations into a single 001_initial_schema.sql Flutter: - POST /ai/recognize-dish now sends target_date and target_meal_type - DishResultSheet accepts jobId; _addToDiary includes it in the diary payload, saves last-used meal type to SharedPreferences, invalidates todayJobsProvider - TodayJobsNotifier + todayJobsProvider: loads unlinked jobs via GET /ai/jobs - Home screen shows _TodayJobsWidget (up to 3 tiles) between macros and meals; tapping a done tile reopens DishResultSheet with the stored result - Quick Actions row: third button "История" → /scan/history - New RecognitionHistoryScreen: full-screen list of today's unlinked jobs - LocalPreferences wrapper over SharedPreferences (last_used_meal_type) - app_theme: apply Google Fonts Roboto as default font family Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../core/storage/local_preferences_provider.dart';
|
||||
import '../../features/menu/menu_provider.dart';
|
||||
import '../../features/home/home_provider.dart';
|
||||
import '../../shared/models/meal_type.dart';
|
||||
@@ -15,11 +16,13 @@ class DishResultSheet extends ConsumerStatefulWidget {
|
||||
required this.dish,
|
||||
required this.onAdded,
|
||||
this.preselectedMealType,
|
||||
this.jobId,
|
||||
});
|
||||
|
||||
final DishResult dish;
|
||||
final VoidCallback onAdded;
|
||||
final String? preselectedMealType;
|
||||
final String? jobId;
|
||||
|
||||
@override
|
||||
ConsumerState<DishResultSheet> createState() => _DishResultSheetState();
|
||||
@@ -107,7 +110,10 @@ class _DishResultSheetState extends ConsumerState<DishResultSheet> {
|
||||
'portion_g': _portionGrams,
|
||||
'source': 'recognition',
|
||||
if (_selected.dishId != null) 'dish_id': _selected.dishId,
|
||||
if (widget.jobId != null) 'job_id': widget.jobId,
|
||||
});
|
||||
await ref.read(localPreferencesProvider).setLastUsedMealType(_mealType);
|
||||
ref.invalidate(todayJobsProvider);
|
||||
if (mounted) widget.onAdded();
|
||||
} catch (addError) {
|
||||
debugPrint('Add to diary error: $addError');
|
||||
|
||||
Reference in New Issue
Block a user