Pass selected sport from quick start to trip creation
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user