2.0: breakfast and snack meal types across the app

- MealType gains breakfast/snack (chronological order drives slot/row order).
- AppSettings.activeMealTypes: single source of truth for enabled meals, backed
  by new optional enabledMealTypesRaw with legacy mealWindows fallback —
  additive migration, keeps pre-2.0 installs and iCloud snapshots working.
  Legacy field kept coherent by the setter. time(for:) resolves per-meal event
  times (breakfast 8:00 / snack 17:00 defaults on old stores).
- Replaced the 5 duplicated mealWindows→[MealType] derivations (slot sync,
  default plan creation, week calendar, export view) with activeMealTypes.
- CalendarService: per-type event names and times.
- Export styles: per-type accent colors and gradients.
- Widget: generic meals list (N rows) instead of hardcoded lunch/dinner;
  compact families fall back to main meals when >2 are active.
- Settings: 4 meal toggles (min 1) replace the 3-option picker.
- Onboarding: meal step is now multi-select over the 4 types.
- iCloud sync: enabledMealTypesRaw synced (optional, pre-2.0 compatible).
- Localized breakfast/snack in all 6 languages.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BkanrydYtrme8wipTzWssG
This commit is contained in:
alexandrev-tibco
2026-07-12 18:00:50 +02:00
parent 98230c732d
commit e15ff93465
20 changed files with 322 additions and 127 deletions
+20 -7
View File
@@ -61,13 +61,26 @@ struct SettingsView: View {
List {
// Planning section
Section {
Picker("settings_meal_windows", selection: Binding(
get: { settings.mealWindowsEnum },
set: { settings.mealWindowsEnum = $0 }
)) {
Text("meal_windows_dinner_only").tag(MealWindows.dinnerOnly)
Text("meal_windows_lunch_only").tag(MealWindows.lunchOnly)
Text("meal_windows_both").tag(MealWindows.both)
ForEach(MealType.allCases, id: \.self) { mealType in
Toggle(isOn: Binding(
get: { settings.activeMealTypes.contains(mealType) },
set: { enabled in
var types = settings.activeMealTypes
if enabled {
types.append(mealType)
} else if types.count > 1 {
// Keep at least one meal type active.
types.removeAll { $0 == mealType }
}
settings.activeMealTypes = types
}
)) {
Label(
String(localized: String.LocalizationValue(mealType.localizedKey)),
systemImage: mealType.icon
)
}
.tint(.mealMoodCoral)
}
Toggle("settings_include_weekends", isOn: Binding(