Backend: - Translate all recognition prompts (receipt, products, dish) from Russian to English - Add lang parameter to Recognizer interface and pass locale.FromContext in handlers - DishResult type uses candidates array for multi-candidate responses Client: - Add meal tracking: diary provider, date selector, meal type model - DishResult parser: backward-compatible with legacy flat format and new candidates format - DishResultScreen: sticky bottom button, full-width portion/meal-type inputs, КБЖУ disclaimer moved under nutrition card, add date field to diary POST body - Recognition prompts now return dish/product names in user's preferred language - Onboarding, profile, home screen visual updates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
1.3 KiB
Dart
36 lines
1.3 KiB
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../../shared/models/home_summary.dart';
|
|
import 'home_service.dart';
|
|
|
|
// ── Selected date (persists while app is open) ────────────────
|
|
|
|
/// The date currently viewed on the home screen.
|
|
/// Defaults to today; can be changed via the date selector.
|
|
final selectedDateProvider = StateProvider<DateTime>((ref) => DateTime.now());
|
|
|
|
/// Formats a [DateTime] to the 'YYYY-MM-DD' string expected by the diary API.
|
|
String formatDateForDiary(DateTime date) =>
|
|
'${date.year}-${date.month.toString().padLeft(2, '0')}-'
|
|
'${date.day.toString().padLeft(2, '0')}';
|
|
|
|
// ── Home summary ──────────────────────────────────────────────
|
|
|
|
class HomeNotifier extends StateNotifier<AsyncValue<HomeSummary>> {
|
|
final HomeService _service;
|
|
|
|
HomeNotifier(this._service) : super(const AsyncValue.loading()) {
|
|
load();
|
|
}
|
|
|
|
Future<void> load() async {
|
|
state = const AsyncValue.loading();
|
|
state = await AsyncValue.guard(() => _service.getSummary());
|
|
}
|
|
}
|
|
|
|
final homeProvider =
|
|
StateNotifierProvider<HomeNotifier, AsyncValue<HomeSummary>>(
|
|
(ref) => HomeNotifier(ref.read(homeServiceProvider)),
|
|
);
|