- 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>
69 lines
2.0 KiB
Swift
69 lines
2.0 KiB
Swift
//
|
|
// DatesStep.swift
|
|
// SportsTime
|
|
//
|
|
// Step 2 of the trip wizard - select travel dates.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct DatesStep: View {
|
|
@Environment(\.colorScheme) private var colorScheme
|
|
@Binding var startDate: Date
|
|
@Binding var endDate: Date
|
|
@Binding var hasSetDates: Bool
|
|
let onDatesChanged: () -> Void
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: Theme.Spacing.md) {
|
|
StepHeader(
|
|
title: "When would you like to travel?",
|
|
subtitle: "Tap to select start and end dates"
|
|
)
|
|
|
|
DateRangePicker(
|
|
startDate: $startDate,
|
|
endDate: $endDate
|
|
)
|
|
.onChange(of: startDate) { _, _ in
|
|
// Only mark as complete when user has selected both dates (end > start)
|
|
updateHasSetDates()
|
|
onDatesChanged()
|
|
}
|
|
.onChange(of: endDate) { _, _ in
|
|
// Only mark as complete when user has selected both dates (end > start)
|
|
updateHasSetDates()
|
|
onDatesChanged()
|
|
}
|
|
}
|
|
.padding(Theme.Spacing.lg)
|
|
.background(Theme.cardBackground(colorScheme))
|
|
.clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.large))
|
|
.overlay {
|
|
RoundedRectangle(cornerRadius: Theme.CornerRadius.large)
|
|
.stroke(Theme.surfaceGlow(colorScheme), lineWidth: 1)
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
// MARK: - Preview
|
|
|
|
#Preview {
|
|
DatesStep(
|
|
startDate: .constant(Date()),
|
|
endDate: .constant(Date().addingTimeInterval(86400 * 5)),
|
|
hasSetDates: .constant(true),
|
|
onDatesChanged: {}
|
|
)
|
|
.padding()
|
|
.themedBackground()
|
|
}
|