fix(wizard): improve UX with step reordering and UI polish

- Reorder wizard steps: dates before sports (enables availability check)
- Add contentShape(Rectangle()) for full tap targets on all cards
- Fix route preference showing preselected value
- Fix sport cards having inconsistent heights
- Speed up step reveal animation (0.3s → 0.15s)
- Add debounced scroll delay to avoid interrupting selection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-01-12 21:13:45 -06:00
parent 8a958a0f7e
commit 94bb68d431
9 changed files with 348 additions and 162 deletions

View File

@@ -16,6 +16,8 @@ struct TripWizardView: View {
@State private var planningError: String?
@State private var showError = false
private let planningEngine = TripPlanningEngine()
var body: some View {
NavigationStack {
ScrollViewReader { proxy in
@@ -25,19 +27,7 @@ struct TripWizardView: View {
PlanningModeStep(selection: $viewModel.planningMode)
.id("planningMode")
// Step 2: Sports (after mode selected)
if viewModel.isSportsStepVisible {
SportsStep(
selectedSports: $viewModel.selectedSports,
sportAvailability: viewModel.sportAvailability,
isLoading: viewModel.isLoadingSportAvailability,
canSelectSport: viewModel.canSelectSport
)
.id("sports")
.transition(.move(edge: .bottom).combined(with: .opacity))
}
// Step 3: Dates (after sport selected)
// Step 2: Dates (after mode selected)
if viewModel.isDatesStepVisible {
DatesStep(
startDate: $viewModel.startDate,
@@ -53,6 +43,18 @@ struct TripWizardView: View {
.transition(.move(edge: .bottom).combined(with: .opacity))
}
// Step 3: Sports (after dates set)
if viewModel.isSportsStepVisible {
SportsStep(
selectedSports: $viewModel.selectedSports,
sportAvailability: viewModel.sportAvailability,
isLoading: viewModel.isLoadingSportAvailability,
canSelectSport: viewModel.canSelectSport
)
.id("sports")
.transition(.move(edge: .bottom).combined(with: .opacity))
}
// Step 4: Regions (after dates set)
if viewModel.isRegionsStepVisible {
RegionsStep(selectedRegions: $viewModel.selectedRegions)
@@ -106,12 +108,15 @@ struct TripWizardView: View {
}
}
.padding(Theme.Spacing.md)
.animation(.easeInOut(duration: 0.3), value: viewModel.revealState)
.animation(.easeInOut(duration: 0.15), value: viewModel.revealState)
}
.onChange(of: viewModel.revealState) { _, _ in
// Auto-scroll to newly revealed section
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
withAnimation {
.onChange(of: viewModel.revealState) { _, newState in
// Auto-scroll to newly revealed section after a delay
// to avoid interrupting user interactions
DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) {
// Only scroll if state hasn't changed (user stopped interacting)
guard viewModel.revealState == newState else { return }
withAnimation(.easeInOut(duration: 0.25)) {
scrollToLatestStep(proxy: proxy)
}
}
@@ -130,7 +135,9 @@ struct TripWizardView: View {
options: tripOptions,
games: [:],
preferences: buildPreferences(),
convertToTrip: { _ in nil }
convertToTrip: { option in
convertOptionToTrip(option)
}
)
}
.alert("Planning Error", isPresented: $showError) {
@@ -154,10 +161,10 @@ struct TripWizardView: View {
proxy.scrollTo("routePreference", anchor: .top)
} else if viewModel.isRegionsStepVisible {
proxy.scrollTo("regions", anchor: .top)
} else if viewModel.isDatesStepVisible {
proxy.scrollTo("dates", anchor: .top)
} else if viewModel.isSportsStepVisible {
proxy.scrollTo("sports", anchor: .top)
} else if viewModel.isDatesStepVisible {
proxy.scrollTo("dates", anchor: .top)
}
}
@@ -177,37 +184,37 @@ struct TripWizardView: View {
endDate: preferences.endDate
)
// Build dictionaries from arrays
let teamsById = Dictionary(uniqueKeysWithValues: AppDataProvider.shared.teams.map { ($0.id, $0) })
let stadiumsById = Dictionary(uniqueKeysWithValues: AppDataProvider.shared.stadiums.map { ($0.id, $0) })
// Build planning request
let request = PlanningRequest(
preferences: preferences,
availableGames: games,
teams: AppDataProvider.shared.teams,
stadiums: AppDataProvider.shared.stadiums
teams: teamsById,
stadiums: stadiumsById
)
// Run planning engine
let result = await TripPlanningEngine.shared.plan(request: request)
let result = planningEngine.planItineraries(request: request)
await MainActor.run {
switch result {
case .success(let options):
if options.isEmpty {
planningError = "No valid trip options found for your criteria. Try expanding your date range or regions."
showError = true
} else {
tripOptions = options
showTripOptions = true
}
case .failure(let failure):
planningError = failure.message
switch result {
case .success(let options):
if options.isEmpty {
planningError = "No valid trip options found for your criteria. Try expanding your date range or regions."
showError = true
} else {
tripOptions = options
showTripOptions = true
}
}
} catch {
await MainActor.run {
planningError = error.localizedDescription
case .failure(let failure):
planningError = failure.message
showError = true
}
} catch {
planningError = error.localizedDescription
showError = true
}
}
@@ -223,6 +230,42 @@ struct TripWizardView: View {
selectedRegions: viewModel.selectedRegions
)
}
private func convertOptionToTrip(_ option: ItineraryOption) -> Trip {
let preferences = buildPreferences()
// Convert ItineraryStops to TripStops
let tripStops = option.stops.enumerated().map { index, stop in
TripStop(
stopNumber: index + 1,
city: stop.city,
state: stop.state,
coordinate: stop.coordinate,
arrivalDate: stop.arrivalDate,
departureDate: stop.departureDate,
games: stop.games,
isRestDay: stop.games.isEmpty
)
}
return Trip(
name: generateTripName(from: tripStops),
preferences: preferences,
stops: tripStops,
travelSegments: option.travelSegments,
totalGames: option.totalGames,
totalDistanceMeters: option.totalDistanceMiles * 1609.34,
totalDrivingSeconds: option.totalDrivingHours * 3600
)
}
private func generateTripName(from stops: [TripStop]) -> String {
let cities = stops.compactMap { $0.city }.prefix(3)
if cities.count <= 1 {
return cities.first ?? "Road Trip"
}
return cities.joined(separator: "")
}
}
// MARK: - Preview