Files
FamilyMealPlanner/MealMood/Models/Dish.swift
T
alexandrev-tibco a4dfb38feb 1.0.6: Priority dishes, day rules, auto-assign CTA, tap-to-replace, export incomplete weeks, Sunday notification
- Dish.isPriority: mark dishes as priority; auto-assign gives them 2.5x weight
- Tag.dayRestriction: restrict tags to weekdays or weekend only
- Auto-assign CTA banner shown when there are empty slots (was hidden in context menu)
- Tap on filled slot opens picker to replace dish directly (no need to remove first)
- Export callout visible as soon as ≥1 slot is filled (not only when week is complete)
- WeekPlanShareView shows localized "TBD" / "Eating out" for empty/eating-out slots
- Second Sunday 17:00 push notification to plan next week
- DishDrawer sorts: priority first, then by historical usage, then alphabetically
- Search in SlotDishPickerSheet already shipped in 1.0.5 (verified ✓)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 00:00:53 +02:00

40 lines
944 B
Swift

import Foundation
import SwiftData
@Model
final class Dish {
@Attribute(.unique) var id: UUID
var name: String
var descriptionText: String?
var tagIds: [UUID]
var createdAt: Date
var isPriority: Bool
init(
id: UUID = UUID(),
name: String,
descriptionText: String? = nil,
tagIds: [UUID] = [],
createdAt: Date = Date(),
isPriority: Bool = false
) {
self.id = id
self.name = name
self.descriptionText = descriptionText
self.tagIds = tagIds
self.createdAt = createdAt
self.isPriority = isPriority
}
}
extension Dish {
static func stableSortedForDisplay(_ dishes: [Dish]) -> [Dish] {
dishes.sorted { lhs, rhs in
if lhs.createdAt != rhs.createdAt {
return lhs.createdAt > rhs.createdAt
}
return lhs.id.uuidString < rhs.id.uuidString
}
}
}