Backend:
- migration 005: expand menu_items.meal_type CHECK to all 6 types (second_breakfast, afternoon_snack, snack)
- ai/types.go: add Days and MealTypes to MenuRequest for partial generation
- openai/menu.go: parametrize GenerateMenu — use requested meal types and day count; add caloric fractions for all 6 meal types
- menu/repository.go: add UpsertItemsInTx for partial upsert (preserves existing slots); fix meal_type sort order in GetByWeek
- menu/handler.go: add dates+meal_types path to POST /ai/generate-menu; extract fetchImages/saveRecipes helpers; returns {"plans":[...]} for dates mode; backward-compatible with week mode
Client:
- PlanMenuSheet: bottom sheet with 4 planning horizon options
- PlanDatePickerSheet: adaptive sheet with date strip (single day/meal) or custom CalendarRangePicker (multi-day/week); sliding 7-day window for week mode
- menu_service.dart: add generateForDates
- menu_provider.dart: add PlanMenuService (generates + invalidates week providers), lastPlannedDateProvider
- home_screen.dart: add _PlanMenuButton card below quick actions; opens planning wizard
- l10n: 16 new keys for planning UI across all 12 languages
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
102 lines
3.1 KiB
Dart
102 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:food_ai/l10n/app_localizations.dart';
|
|
|
|
/// The planning horizon selected by the user.
|
|
enum PlanMode { singleMeal, singleDay, days, week }
|
|
|
|
/// Bottom sheet that lets the user choose a planning horizon.
|
|
/// Closes itself and calls [onModeSelected] with the chosen mode.
|
|
class PlanMenuSheet extends StatelessWidget {
|
|
const PlanMenuSheet({super.key, required this.onModeSelected});
|
|
|
|
final void Function(PlanMode mode) onModeSelected;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = AppLocalizations.of(context)!;
|
|
final theme = Theme.of(context);
|
|
|
|
return SafeArea(
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 20, 16, 16),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Text(
|
|
l10n.planMenuTitle,
|
|
style: theme.textTheme.titleLarge,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 20),
|
|
_PlanOptionTile(
|
|
icon: Icons.restaurant_outlined,
|
|
title: l10n.planOptionSingleMeal,
|
|
subtitle: l10n.planOptionSingleMealDesc,
|
|
onTap: () => _select(context, PlanMode.singleMeal),
|
|
),
|
|
_PlanOptionTile(
|
|
icon: Icons.today_outlined,
|
|
title: l10n.planOptionDay,
|
|
subtitle: l10n.planOptionDayDesc,
|
|
onTap: () => _select(context, PlanMode.singleDay),
|
|
),
|
|
_PlanOptionTile(
|
|
icon: Icons.date_range_outlined,
|
|
title: l10n.planOptionDays,
|
|
subtitle: l10n.planOptionDaysDesc,
|
|
onTap: () => _select(context, PlanMode.days),
|
|
),
|
|
_PlanOptionTile(
|
|
icon: Icons.calendar_month_outlined,
|
|
title: l10n.planOptionWeek,
|
|
subtitle: l10n.planOptionWeekDesc,
|
|
onTap: () => _select(context, PlanMode.week),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _select(BuildContext context, PlanMode mode) {
|
|
Navigator.pop(context);
|
|
onModeSelected(mode);
|
|
}
|
|
}
|
|
|
|
class _PlanOptionTile extends StatelessWidget {
|
|
const _PlanOptionTile({
|
|
required this.icon,
|
|
required this.title,
|
|
required this.subtitle,
|
|
required this.onTap,
|
|
});
|
|
|
|
final IconData icon;
|
|
final String title;
|
|
final String subtitle;
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return Card(
|
|
margin: const EdgeInsets.only(bottom: 8),
|
|
child: ListTile(
|
|
leading: Icon(icon, color: theme.colorScheme.primary),
|
|
title: Text(title, style: theme.textTheme.titleSmall),
|
|
subtitle: Text(
|
|
subtitle,
|
|
style: theme.textTheme.bodySmall?.copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
trailing: Icon(Icons.chevron_right,
|
|
color: theme.colorScheme.onSurfaceVariant),
|
|
onTap: onTap,
|
|
),
|
|
);
|
|
}
|
|
}
|