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

@@ -2,7 +2,7 @@
// DatesStep.swift
// SportsTime
//
// Step 3 of the trip wizard - select travel dates.
// Step 2 of the trip wizard - select travel dates.
//
import SwiftUI
@@ -18,49 +18,22 @@ struct DatesStep: View {
VStack(alignment: .leading, spacing: Theme.Spacing.md) {
StepHeader(
title: "When would you like to travel?",
subtitle: "Pick your trip dates"
subtitle: "Tap to select start and end dates"
)
VStack(spacing: Theme.Spacing.md) {
DatePicker(
"Start Date",
selection: $startDate,
in: Date()...,
displayedComponents: .date
)
.datePickerStyle(.compact)
.onChange(of: startDate) { _, newValue in
// Ensure end date is after start date
if endDate < newValue {
endDate = newValue.addingTimeInterval(86400)
}
hasSetDates = true
onDatesChanged()
}
DatePicker(
"End Date",
selection: $endDate,
in: startDate...,
displayedComponents: .date
)
.datePickerStyle(.compact)
.onChange(of: endDate) { _, _ in
hasSetDates = true
onDatesChanged()
}
DateRangePicker(
startDate: $startDate,
endDate: $endDate
)
.onChange(of: startDate) { _, _ in
// Only mark as complete when user has selected both dates (end > start)
updateHasSetDates()
onDatesChanged()
}
.padding(Theme.Spacing.sm)
.background(Theme.cardBackgroundElevated(colorScheme))
.clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.medium))
// Trip duration indicator
HStack {
Image(systemName: "calendar.badge.clock")
.foregroundStyle(Theme.textMuted(colorScheme))
Text(durationText)
.font(.subheadline)
.foregroundStyle(Theme.textSecondary(colorScheme))
.onChange(of: endDate) { _, _ in
// Only mark as complete when user has selected both dates (end > start)
updateHasSetDates()
onDatesChanged()
}
}
.padding(Theme.Spacing.lg)
@@ -72,15 +45,12 @@ struct DatesStep: View {
}
}
private var durationText: String {
let days = Calendar.current.dateComponents([.day], from: startDate, to: endDate).day ?? 0
if days == 0 {
return "Same day trip"
} else if days == 1 {
return "1 day trip"
} else {
return "\(days) day trip"
}
private func updateHasSetDates() {
// User must select both start and end dates (end date must be after start)
let calendar = Calendar.current
let startDay = calendar.startOfDay(for: startDate)
let endDay = calendar.startOfDay(for: endDate)
hasSetDates = endDay > startDay
}
}

View File

@@ -20,7 +20,7 @@ struct PlanningModeStep: View {
VStack(spacing: Theme.Spacing.sm) {
ForEach(PlanningMode.allCases) { mode in
PlanningModeCard(
WizardModeCard(
mode: mode,
isSelected: selection == mode,
onTap: { selection = mode }
@@ -38,9 +38,9 @@ struct PlanningModeStep: View {
}
}
// MARK: - Planning Mode Card
// MARK: - Wizard Mode Card
private struct PlanningModeCard: View {
private struct WizardModeCard: View {
@Environment(\.colorScheme) private var colorScheme
let mode: PlanningMode
let isSelected: Bool
@@ -74,6 +74,7 @@ private struct PlanningModeCard: View {
.padding(Theme.Spacing.md)
.background(isSelected ? Theme.warmOrange.opacity(0.1) : Color.clear)
.clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.medium))
.contentShape(Rectangle())
.overlay(
RoundedRectangle(cornerRadius: Theme.CornerRadius.medium)
.stroke(isSelected ? Theme.warmOrange : Theme.textMuted(colorScheme).opacity(0.3), lineWidth: isSelected ? 2 : 1)

View File

@@ -11,37 +11,19 @@ struct RegionsStep: View {
@Environment(\.colorScheme) private var colorScheme
@Binding var selectedRegions: Set<Region>
private let columns = [
GridItem(.flexible()),
GridItem(.flexible())
]
var body: some View {
VStack(alignment: .leading, spacing: Theme.Spacing.md) {
StepHeader(
title: "Where do you want to go?",
subtitle: "Select one or more regions"
subtitle: "Tap the map to select regions"
)
LazyVGrid(columns: columns, spacing: Theme.Spacing.sm) {
ForEach(Region.allCases.filter { $0 != .crossCountry }) { region in
RegionCard(
region: region,
isSelected: selectedRegions.contains(region),
onTap: { toggleRegion(region) }
)
RegionMapSelector(
selectedRegions: $selectedRegions,
onToggle: { region in
toggleRegion(region)
}
}
if !selectedRegions.isEmpty {
HStack {
Image(systemName: "mappin.circle.fill")
.foregroundStyle(Theme.warmOrange)
Text("\(selectedRegions.count) region\(selectedRegions.count == 1 ? "" : "s") selected")
.font(.subheadline)
.foregroundStyle(Theme.textSecondary(colorScheme))
}
}
)
}
.padding(Theme.Spacing.lg)
.background(Theme.cardBackground(colorScheme))
@@ -61,40 +43,6 @@ struct RegionsStep: View {
}
}
// MARK: - Region Card
private struct RegionCard: View {
@Environment(\.colorScheme) private var colorScheme
let region: Region
let isSelected: Bool
let onTap: () -> Void
var body: some View {
Button(action: onTap) {
VStack(spacing: Theme.Spacing.xs) {
Image(systemName: region.iconName)
.font(.title)
.foregroundStyle(isSelected ? Theme.warmOrange : Theme.textSecondary(colorScheme))
Text(region.shortName)
.font(.caption)
.fontWeight(.medium)
.foregroundStyle(isSelected ? Theme.warmOrange : Theme.textPrimary(colorScheme))
.multilineTextAlignment(.center)
}
.frame(maxWidth: .infinity)
.padding(.vertical, Theme.Spacing.md)
.background(isSelected ? Theme.warmOrange.opacity(0.1) : Color.clear)
.clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.medium))
.overlay(
RoundedRectangle(cornerRadius: Theme.CornerRadius.medium)
.stroke(isSelected ? Theme.warmOrange : Theme.textMuted(colorScheme).opacity(0.3), lineWidth: isSelected ? 2 : 1)
)
}
.buttonStyle(.plain)
}
}
// MARK: - Preview
#Preview {

View File

@@ -77,6 +77,7 @@ private struct OptionButton: View {
.padding(Theme.Spacing.md)
.background(isSelected ? Theme.warmOrange.opacity(0.1) : Color.clear)
.clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.medium))
.contentShape(Rectangle())
.overlay(
RoundedRectangle(cornerRadius: Theme.CornerRadius.medium)
.stroke(isSelected ? Theme.warmOrange : Theme.textMuted(colorScheme).opacity(0.3), lineWidth: isSelected ? 2 : 1)

View File

@@ -23,7 +23,7 @@ struct RoutePreferenceStep: View {
ForEach(RoutePreference.allCases) { preference in
RoutePreferenceCard(
preference: preference,
isSelected: routePreference == preference,
isSelected: hasSetRoutePreference && routePreference == preference,
onTap: {
routePreference = preference
hasSetRoutePreference = true
@@ -78,6 +78,7 @@ private struct RoutePreferenceCard: View {
.padding(Theme.Spacing.md)
.background(isSelected ? Theme.warmOrange.opacity(0.1) : Color.clear)
.clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.medium))
.contentShape(Rectangle())
.overlay(
RoundedRectangle(cornerRadius: Theme.CornerRadius.medium)
.stroke(isSelected ? Theme.warmOrange : Theme.textMuted(colorScheme).opacity(0.3), lineWidth: isSelected ? 2 : 1)

View File

@@ -2,7 +2,7 @@
// SportsStep.swift
// SportsTime
//
// Step 2 of the trip wizard - select sports leagues.
// Step 3 of the trip wizard - select sports leagues.
//
import SwiftUI
@@ -92,16 +92,15 @@ private struct SportCard: View {
.fontWeight(.medium)
.foregroundStyle(cardColor)
if !isAvailable {
Text("No games")
.font(.caption2)
.foregroundStyle(Theme.textMuted(colorScheme))
}
Text(isAvailable ? " " : "No games")
.font(.caption2)
.foregroundStyle(Theme.textMuted(colorScheme))
}
.frame(maxWidth: .infinity)
.padding(.vertical, Theme.Spacing.md)
.background(backgroundColor)
.clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.medium))
.contentShape(Rectangle())
.overlay(
RoundedRectangle(cornerRadius: Theme.CornerRadius.medium)
.stroke(borderColor, lineWidth: isSelected ? 2 : 1)