2.0: Dish gains optional ingredients + photo; on-device ingredient generation
- Dish: ingredients [String] (default [], never required) and photoData (externalStorage). Additive SwiftData migration — existing stores unaffected. - ICloudSyncService: sync ingredients (optional in payload so pre-2.0 snapshots still decode); photos deliberately excluded from KV sync (1MB limit). - IngredientGenerator: Foundation Models (iOS 26+) generates localized ingredient lines from the dish name, fully on-device. isAvailable gates the UI affordance on older OS/devices; failures record to Crashlytics and return []. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BkanrydYtrme8wipTzWssG
This commit is contained in:
@@ -10,13 +10,24 @@ final class Dish {
|
||||
var createdAt: Date
|
||||
var isPriority: Bool = false
|
||||
|
||||
/// Optional ingredient lines (one per entry, e.g. "200g spaghetti").
|
||||
/// Populated lazily — manually or via on-device generation — and only for
|
||||
/// the dishes a user actually shops for. Never required to create a dish.
|
||||
var ingredients: [String] = []
|
||||
|
||||
/// Optional dish photo. Stored outside the main store to keep it light and
|
||||
/// CloudKit-friendly.
|
||||
@Attribute(.externalStorage) var photoData: Data?
|
||||
|
||||
init(
|
||||
id: UUID = UUID(),
|
||||
name: String,
|
||||
descriptionText: String? = nil,
|
||||
tagIds: [UUID] = [],
|
||||
createdAt: Date = Date(),
|
||||
isPriority: Bool = false
|
||||
isPriority: Bool = false,
|
||||
ingredients: [String] = [],
|
||||
photoData: Data? = nil
|
||||
) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
@@ -24,6 +35,8 @@ final class Dish {
|
||||
self.tagIds = tagIds
|
||||
self.createdAt = createdAt
|
||||
self.isPriority = isPriority
|
||||
self.ingredients = ingredients
|
||||
self.photoData = photoData
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user