platos: segundo plato por comida (ensalada + salmon)
- MealSlot.secondaryDishId (opcional, aditivo CloudKit); se limpia al sustituir/quitar/vaciar/marcar comer fuera y viaja en swaps, copia de semana anterior, undo y snapshot KV de iCloud (retrocompatible) - Picker de hueco lleno: toggle "anadir como segundo plato" + boton para quitarlo; HomeViewModel.assignSecondaryDish/removeSecondaryDish - Se muestra "Plato + Segundo" en calendario, widget y export; la lista de la compra incluye los ingredientes del segundo; stats lo cuentan - Evento analytics secondary_dish_added; strings en 6 idiomas Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013H6bXqGX1ygwib1Dm3n3UG
This commit is contained in:
@@ -115,6 +115,7 @@ final class ICloudSyncService {
|
||||
dayOfWeek: $0.dayOfWeek,
|
||||
mealType: $0.mealType,
|
||||
dishId: $0.dishId,
|
||||
secondaryDishId: $0.secondaryDishId,
|
||||
calendarEventId: $0.calendarEventId,
|
||||
isRuleOverridden: $0.isRuleOverridden
|
||||
)
|
||||
@@ -210,6 +211,7 @@ final class ICloudSyncService {
|
||||
dayOfWeek: slotPayload.dayOfWeek,
|
||||
mealType: slotPayload.mealType,
|
||||
dishId: slotPayload.dishId,
|
||||
secondaryDishId: slotPayload.secondaryDishId,
|
||||
calendarEventId: slotPayload.calendarEventId,
|
||||
isRuleOverridden: slotPayload.isRuleOverridden
|
||||
)
|
||||
@@ -289,6 +291,8 @@ private struct MealSlotPayload: Codable {
|
||||
let dayOfWeek: Int
|
||||
let mealType: String
|
||||
let dishId: UUID?
|
||||
// Optional so payloads written by older installs (no key) still decode.
|
||||
var secondaryDishId: UUID?
|
||||
let calendarEventId: String?
|
||||
let isRuleOverridden: Bool
|
||||
}
|
||||
|
||||
@@ -26,10 +26,12 @@ enum WidgetDataStore {
|
||||
let appDayOfWeek = (weekday + 5) % 7
|
||||
|
||||
let meals: [TodayMealData.Meal] = settings.activeMealTypes.map { mealType in
|
||||
let dishId = plan?.slotList.first {
|
||||
let slot = plan?.slotList.first {
|
||||
$0.dayOfWeek == appDayOfWeek && $0.mealType == mealType.rawValue
|
||||
}?.dishId
|
||||
let name = dishId.flatMap { id in dishes.first { $0.id == id }?.name }
|
||||
}
|
||||
let primaryName = slot?.dishId.flatMap { id in dishes.first { $0.id == id }?.name }
|
||||
let secondaryName = slot?.secondaryDishId.flatMap { id in dishes.first { $0.id == id }?.name }
|
||||
let name = primaryName.map { p in secondaryName.map { "\(p) + \($0)" } ?? p }
|
||||
return TodayMealData.Meal(
|
||||
type: mealType.rawValue,
|
||||
label: String(localized: String.LocalizationValue(mealType.localizedKey)),
|
||||
|
||||
Reference in New Issue
Block a user