Version casi lista

This commit is contained in:
alexandrev-tibco
2026-02-17 13:34:02 +01:00
commit e593453abd
99 changed files with 10867 additions and 0 deletions
+136
View File
@@ -0,0 +1,136 @@
import SwiftUI
struct WeekPlanShareView: View {
let plan: WeekPlan
let settings: AppSettings
let dishes: [Dish]
let tags: [Tag]
private var dayRange: ClosedRange<Int> {
settings.includeWeekends ? 0...6 : 0...4
}
private var mealTypes: [MealType] {
switch settings.mealWindowsEnum {
case .dinnerOnly: return [.dinner]
case .lunchOnly: return [.lunch]
case .both: return [.lunch, .dinner]
}
}
var body: some View {
ZStack {
LinearGradient(
colors: [
Color(hex: "#FFF6F0"),
Color(hex: "#F6FCFA")
],
startPoint: .topLeading,
endPoint: .bottomTrailing
)
.ignoresSafeArea()
VStack(alignment: .leading, spacing: 28) {
HStack(spacing: 16) {
AppIconPlaceholder(size: 72)
VStack(alignment: .leading, spacing: 6) {
Text("MealMood")
.font(.system(size: 44, weight: .bold))
.foregroundColor(.mealMoodTextPrimary)
Text(plan.weekStartDate.formattedWeekRange())
.font(.system(size: 26, weight: .medium))
.foregroundColor(.mealMoodTextSecondary)
}
Spacer()
Text(Date.now.formatted(date: .abbreviated, time: .omitted))
.font(.system(size: 20, weight: .medium))
.foregroundColor(.mealMoodTextSecondary)
}
Grid(horizontalSpacing: 10, verticalSpacing: 10) {
GridRow {
gridHeaderCell("")
.frame(minWidth: 220)
ForEach(Array(dayRange), id: \.self) { day in
gridHeaderCell(dayTitle(for: day))
}
}
ForEach(mealTypes, id: \.self) { mealType in
GridRow {
gridMealCell(mealTypeLabel(mealType), icon: mealType.icon)
.frame(minWidth: 220)
ForEach(Array(dayRange), id: \.self) { day in
gridDishCell(dishName(day: day, mealType: mealType))
}
}
}
}
Spacer()
Text("share_week_title")
.font(.system(size: 18, weight: .medium))
.foregroundColor(.mealMoodTextSecondary)
}
.padding(56)
}
.frame(width: 2400, height: 1700)
}
private func dayTitle(for day: Int) -> String {
let keys = ["day_mon", "day_tue", "day_wed", "day_thu", "day_fri", "day_sat", "day_sun"]
let localizedDay = day >= 0 && day < keys.count ? NSLocalizedString(keys[day], comment: "") : ""
let dayDate = plan.weekStartDate.addingDays(day)
let dayNumber = Calendar.current.component(.day, from: dayDate)
return "\(localizedDay) \(dayNumber)"
}
private func mealTypeLabel(_ mealType: MealType) -> String {
mealType == .lunch ? String(localized: "lunch") : String(localized: "dinner")
}
private func dishName(day: Int, mealType: MealType) -> String {
let slot = plan.slots.first { $0.dayOfWeek == day && $0.mealType == mealType.rawValue }
guard let slot, let dishId = slot.dishId, let dish = dishes.first(where: { $0.id == dishId }) else {
return ""
}
return dish.name
}
private func gridHeaderCell(_ title: String) -> some View {
Text(title)
.font(.system(size: 24, weight: .semibold))
.foregroundColor(.mealMoodTextPrimary)
.frame(maxWidth: .infinity, minHeight: 92)
.padding(.horizontal, 10)
.background(Color.white.opacity(0.95))
.clipShape(RoundedRectangle(cornerRadius: 14))
}
private func gridMealCell(_ title: String, icon: String) -> some View {
HStack(spacing: 8) {
Image(systemName: icon)
Text(title)
}
.font(.system(size: 24, weight: .semibold))
.foregroundColor(.mealMoodTextPrimary)
.frame(maxWidth: .infinity, minHeight: 130)
.padding(.horizontal, 14)
.background(Color.white.opacity(0.95))
.clipShape(RoundedRectangle(cornerRadius: 14))
}
private func gridDishCell(_ title: String) -> some View {
Text(title)
.font(.system(size: 26, weight: .medium))
.foregroundColor(.mealMoodTextPrimary)
.multilineTextAlignment(.center)
.lineLimit(3)
.minimumScaleFactor(0.6)
.frame(maxWidth: .infinity, minHeight: 130)
.padding(.horizontal, 10)
.background(Color.white.opacity(0.92))
.clipShape(RoundedRectangle(cornerRadius: 14))
}
}