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
@@ -0,0 +1,80 @@
import SwiftUI
import SwiftData
struct OnboardingView: View {
@Environment(\.modelContext) private var context
@StateObject private var viewModel = OnboardingViewModel()
@Query(sort: \Tag.sortOrder) private var tags: [Tag]
var onComplete: () -> Void
var body: some View {
ZStack {
Color.mealMoodBackground.ignoresSafeArea()
VStack(spacing: 0) {
// Progress indicator
if viewModel.currentStep > 0 {
HStack(spacing: 8) {
ForEach(1..<viewModel.totalSteps, id: \.self) { step in
Capsule()
.fill(step <= viewModel.currentStep ? Color.mealMoodCoral : Color(hex: "#E0E0E0"))
.frame(height: 4)
}
}
.padding(.horizontal, 24)
.padding(.top, 16)
}
TabView(selection: $viewModel.currentStep) {
WelcomeStepView(onNext: { viewModel.nextStep() })
.tag(0)
MealWindowsStepView(
selection: $viewModel.selectedMealWindows,
onNext: { viewModel.nextStep() }
)
.tag(1)
WeekendsStepView(
includeWeekends: $viewModel.includeWeekends,
onNext: { viewModel.nextStep() }
)
.tag(2)
CalendarStepView(
syncEnabled: $viewModel.syncCalendar,
selectedCalendarId: $viewModel.selectedCalendarId,
lunchTime: $viewModel.lunchTime,
dinnerTime: $viewModel.dinnerTime,
onNext: { viewModel.nextStep() },
onSkip: { viewModel.nextStep() }
)
.tag(3)
FirstDishesStepView(
viewModel: viewModel,
tags: tags,
onFinish: {
if viewModel.completeOnboarding(context: context) {
onComplete()
}
}
)
.tag(4)
}
.tabViewStyle(.page(indexDisplayMode: .never))
.animation(.easeInOut(duration: 0.3), value: viewModel.currentStep)
}
}
.onAppear {
ensureDefaultTagsIfNeeded()
}
}
private func ensureDefaultTagsIfNeeded() {
let descriptor = FetchDescriptor<Tag>()
if (try? context.fetch(descriptor))?.isEmpty ?? true {
DefaultDataService.createDefaultTags(context: context)
}
}
}