Files
FamilyMealPlanner/MealMood/Models/ShoppingItem.swift
T
alexandrev-tibco ce88d7b265 2.0: weekly shopping list from planned dishes
- ShoppingItem model (per-week lines; dish-derived or free-text) + schema.
- ShoppingListService.reconcile mirrors planned dishes' ingredients into the
  list, preserving check-off state and user items; plain-text export helper.
- ShoppingListView: grouped by dish, check-off, swipe-delete, free-text adds,
  clear-checked, ShareLink export, and inline on-device "Generate" for planned
  dishes without ingredients (paywall after 3 free generations,
  source=ingredient_generation).
- Home toolbar: cart entry point (all users) + sheet.
- Analytics: shopping_list_opened, shopping_item_added, ingredients_generated.
- Localized in all 6 languages.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BkanrydYtrme8wipTzWssG
2026-07-12 17:47:41 +02:00

35 lines
936 B
Swift

import Foundation
import SwiftData
/// One line of the weekly shopping list. Items are either derived from a
/// planned dish's ingredients (`dishId` set) or added free-hand by the user
/// (`dishId == nil`). Check-off state persists across app launches.
@Model
final class ShoppingItem {
@Attribute(.unique) var id: UUID
var weekStartDate: Date
var title: String
var dishId: UUID?
var isChecked: Bool = false
var sortOrder: Int = 0
var createdAt: Date
init(
id: UUID = UUID(),
weekStartDate: Date,
title: String,
dishId: UUID? = nil,
isChecked: Bool = false,
sortOrder: Int = 0,
createdAt: Date = Date()
) {
self.id = id
self.weekStartDate = weekStartDate
self.title = title
self.dishId = dishId
self.isChecked = isChecked
self.sortOrder = sortOrder
self.createdAt = createdAt
}
}