From aadc82db73e7bfc4ba4715d38c9578b83de277b5 Mon Sep 17 00:00:00 2001 From: Trey t Date: Thu, 8 Jan 2026 09:54:44 -0600 Subject: [PATCH] Pass selected sport from quick start to trip creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add initialSport parameter to TripCreationView - Set selected sport when quick start button is tapped - Auto-select that sport in trip planning view on appear - Clear selection when sheet is dismissed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- SportsTime/Features/Home/Views/HomeView.swift | 9 ++++++++- SportsTime/Features/Trip/Views/TripCreationView.swift | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/SportsTime/Features/Home/Views/HomeView.swift b/SportsTime/Features/Home/Views/HomeView.swift index 1942858..1935b80 100644 --- a/SportsTime/Features/Home/Views/HomeView.swift +++ b/SportsTime/Features/Home/Views/HomeView.swift @@ -12,6 +12,7 @@ struct HomeView: View { @Query(sort: \SavedTrip.updatedAt, order: .reverse) private var savedTrips: [SavedTrip] @State private var showNewTrip = false + @State private var selectedSport: Sport? @State private var selectedTab = 0 var body: some View { @@ -88,7 +89,12 @@ struct HomeView: View { } .tint(Theme.warmOrange) .sheet(isPresented: $showNewTrip) { - TripCreationView() + TripCreationView(initialSport: selectedSport) + } + .onChange(of: showNewTrip) { _, isShowing in + if !isShowing { + selectedSport = nil + } } } @@ -146,6 +152,7 @@ struct HomeView: View { HStack(spacing: Theme.Spacing.sm) { ForEach(Sport.supported) { sport in QuickSportButton(sport: sport) { + selectedSport = sport showNewTrip = true } } diff --git a/SportsTime/Features/Trip/Views/TripCreationView.swift b/SportsTime/Features/Trip/Views/TripCreationView.swift index 2b9c0bd..61c635d 100644 --- a/SportsTime/Features/Trip/Views/TripCreationView.swift +++ b/SportsTime/Features/Trip/Views/TripCreationView.swift @@ -9,7 +9,13 @@ struct TripCreationView: View { @Environment(\.dismiss) private var dismiss @Environment(\.colorScheme) private var colorScheme + let initialSport: Sport? + @State private var viewModel = TripCreationViewModel() + + init(initialSport: Sport? = nil) { + self.initialSport = initialSport + } @State private var showGamePicker = false @State private var showCityInput = false @State private var cityInputType: CityInputType = .mustStop @@ -161,6 +167,11 @@ struct TripCreationView: View { .task { await viewModel.loadScheduleData() } + .onAppear { + if let sport = initialSport { + viewModel.selectedSports = [sport] + } + } } }