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:
@@ -20,6 +20,7 @@ import '../../features/recipes/recipe_detail_screen.dart';
|
||||
import '../../features/recipes/recipes_screen.dart';
|
||||
import '../../features/profile/profile_screen.dart';
|
||||
import '../../features/products/product_provider.dart';
|
||||
import '../../features/scan/recognition_history_screen.dart';
|
||||
import '../../shared/models/recipe.dart';
|
||||
import '../../shared/models/saved_recipe.dart';
|
||||
|
||||
@@ -140,6 +141,10 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
return RecognitionConfirmScreen(items: items);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/scan/history',
|
||||
builder: (_, __) => const RecognitionHistoryScreen(),
|
||||
),
|
||||
ShellRoute(
|
||||
builder: (context, state, child) => MainShell(child: child),
|
||||
routes: [
|
||||
|
||||
17
client/lib/core/storage/local_preferences.dart
Normal file
17
client/lib/core/storage/local_preferences.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// Thin wrapper over SharedPreferences for app-level local settings.
|
||||
class LocalPreferences {
|
||||
const LocalPreferences(this._prefs);
|
||||
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
static const _keyLastUsedMealType = 'last_used_meal_type';
|
||||
|
||||
/// Returns the last meal type the user selected when adding to diary, or null.
|
||||
String? getLastUsedMealType() => _prefs.getString(_keyLastUsedMealType);
|
||||
|
||||
/// Persists the last used meal type.
|
||||
Future<void> setLastUsedMealType(String mealTypeId) =>
|
||||
_prefs.setString(_keyLastUsedMealType, mealTypeId);
|
||||
}
|
||||
9
client/lib/core/storage/local_preferences_provider.dart
Normal file
9
client/lib/core/storage/local_preferences_provider.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'local_preferences.dart';
|
||||
|
||||
/// Provider for [LocalPreferences]. Must be overridden in [ProviderScope]
|
||||
/// after SharedPreferences is initialised in main().
|
||||
final localPreferencesProvider = Provider<LocalPreferences>(
|
||||
(ref) => throw UnimplementedError('localPreferencesProvider not overridden'),
|
||||
);
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'app_colors.dart';
|
||||
|
||||
ThemeData appTheme() {
|
||||
@@ -23,6 +24,7 @@ ThemeData appTheme() {
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: base,
|
||||
fontFamily: GoogleFonts.roboto().fontFamily,
|
||||
scaffoldBackgroundColor: AppColors.background,
|
||||
|
||||
// ── AppBar ────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user