diff --git a/MealMood/Views/Home/HomeView.swift b/MealMood/Views/Home/HomeView.swift index 266454b..39b38a9 100644 --- a/MealMood/Views/Home/HomeView.swift +++ b/MealMood/Views/Home/HomeView.swift @@ -202,6 +202,15 @@ struct HomeView: View { HStack(spacing: 10) { if let settings = settings, let plan = fetchWeekPlan(for: viewModel.currentWeekStart) { + if plan.slotList.contains(where: { $0.dishId != nil || $0.isEatingOut }) { + Button { + requestWeekShare(plan: plan, settings: settings) + } label: { + Image(systemName: "square.and.arrow.up") + .foregroundColor(.mealMoodTextPrimary) + } + .accessibilityLabel(Text("share_week_button")) + } if viewModel.canEditCurrentWeek { Button { viewModel.autoComplete(plan: plan, dishes: dishes, tags: tags, settings: settings, allPlans: weekPlans) @@ -330,7 +339,10 @@ struct HomeView: View { } let filledCount = plan.slotList.filter { $0.dishId != nil || $0.isEatingOut }.count - if filledCount > 0 && !isExportCalloutDismissed(plan) { + let emptyCount = plan.slotList.filter { $0.dishId == nil && !$0.isEatingOut }.count + // Only surface the export banner once the week is actually + // complete (no empty slots) — and let the user dismiss it. + if filledCount > 0 && emptyCount == 0 && !isExportCalloutDismissed(plan) { exportCallout(plan: plan, settings: settings) } @@ -338,7 +350,6 @@ struct HomeView: View { weekRatingRow(plan: plan) } - let emptyCount = plan.slotList.filter { $0.dishId == nil && !$0.isEatingOut }.count if viewModel.canEditCurrentWeek && !dishes.isEmpty && emptyCount > 0 { autoAssignBanner(emptyCount: emptyCount, plan: plan, settings: settings) } @@ -1013,6 +1024,17 @@ struct HomeView: View { ) } + /// Entry point for the toolbar share action: premium shares directly, free + /// is routed to the paywall (same gating as the export banner). + private func requestWeekShare(plan: WeekPlan, settings: AppSettings) { + if settings.isPremium { + startShareFlow(plan: plan, settings: settings) + } else { + paywallSource = "share_week" + showPremiumFromExport = true + } + } + private func startShareFlow(plan: WeekPlan, settings: AppSettings) { if settings.weekExportStyle == nil { pendingExportPlan = plan