chore: remove scraper, add docs, add marketing-videos gitignore
- Remove Scripts/ directory (scraper no longer needed) - Add themed background documentation to CLAUDE.md - Add .gitignore for marketing-videos to prevent node_modules tracking Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,6 @@ struct SportsIconImageGenerator {
|
||||
"figure.soccer",
|
||||
// Venues/events
|
||||
"sportscourt.fill",
|
||||
"stadium.fill",
|
||||
"trophy.fill",
|
||||
"ticket.fill",
|
||||
// Travel/navigation
|
||||
|
||||
@@ -65,6 +65,11 @@ final class TripWizardViewModel {
|
||||
var startLocation: LocationInput? = nil
|
||||
var endLocation: LocationInput? = nil
|
||||
|
||||
// MARK: - Mode-Specific: teamFirst
|
||||
|
||||
var teamFirstSport: Sport? = nil
|
||||
var teamFirstSelectedTeamIds: Set<String> = []
|
||||
|
||||
// MARK: - Planning State
|
||||
|
||||
var isPlanning: Bool = false
|
||||
@@ -106,6 +111,10 @@ final class TripWizardViewModel {
|
||||
planningMode == .locations
|
||||
}
|
||||
|
||||
var showTeamFirstStep: Bool {
|
||||
planningMode == .teamFirst
|
||||
}
|
||||
|
||||
// MARK: - Validation
|
||||
|
||||
/// All required fields must be set before planning
|
||||
@@ -124,6 +133,8 @@ final class TripWizardViewModel {
|
||||
return startLocation != nil && endLocation != nil && hasSetDates && !selectedSports.isEmpty
|
||||
case .followTeam:
|
||||
return selectedTeamId != nil && hasSetDates
|
||||
case .teamFirst:
|
||||
return teamFirstSport != nil && teamFirstSelectedTeamIds.count >= 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +150,9 @@ final class TripWizardViewModel {
|
||||
selectedGames: selectedGameIds.isEmpty ? .missing : .valid,
|
||||
selectedTeam: selectedTeamId == nil ? .missing : .valid,
|
||||
startLocation: startLocation == nil ? .missing : .valid,
|
||||
endLocation: endLocation == nil ? .missing : .valid
|
||||
endLocation: endLocation == nil ? .missing : .valid,
|
||||
teamFirstTeams: teamFirstSelectedTeamIds.count >= 2 ? .valid : .missing,
|
||||
teamFirstTeamCount: teamFirstSelectedTeamIds.count
|
||||
)
|
||||
}
|
||||
|
||||
@@ -198,6 +211,10 @@ final class TripWizardViewModel {
|
||||
// locations mode fields
|
||||
startLocation = nil
|
||||
endLocation = nil
|
||||
|
||||
// teamFirst mode fields
|
||||
teamFirstSport = nil
|
||||
teamFirstSelectedTeamIds = []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,6 +240,8 @@ struct FieldValidation {
|
||||
let selectedTeam: Status
|
||||
let startLocation: Status
|
||||
let endLocation: Status
|
||||
let teamFirstTeams: Status
|
||||
let teamFirstTeamCount: Int
|
||||
|
||||
/// Returns only the fields that are required for the current planning mode
|
||||
var requiredFields: [(name: String, status: Status)] {
|
||||
@@ -261,6 +280,12 @@ struct FieldValidation {
|
||||
("Route Preference", routePreference),
|
||||
("Repeat Cities", repeatCities)
|
||||
]
|
||||
case .teamFirst:
|
||||
fields = [
|
||||
("Teams", teamFirstTeams),
|
||||
("Route Preference", routePreference),
|
||||
("Repeat Cities", repeatCities)
|
||||
]
|
||||
}
|
||||
|
||||
return fields
|
||||
|
||||
189
SportsTime/Features/Trip/Views/TeamPickerView.swift
Normal file
189
SportsTime/Features/Trip/Views/TeamPickerView.swift
Normal file
@@ -0,0 +1,189 @@
|
||||
//
|
||||
// TeamPickerView.swift
|
||||
// SportsTime
|
||||
//
|
||||
// Multi-select team picker grid for Team-First planning mode.
|
||||
// Users select multiple teams (>=2) and the app finds optimal trip windows.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct TeamPickerView: View {
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
|
||||
let sport: Sport
|
||||
@Binding var selectedTeamIds: Set<String>
|
||||
|
||||
@State private var searchText = ""
|
||||
|
||||
private let columns = [
|
||||
GridItem(.flexible()),
|
||||
GridItem(.flexible()),
|
||||
GridItem(.flexible())
|
||||
]
|
||||
|
||||
private var teams: [Team] {
|
||||
let allTeams = AppDataProvider.shared.teams
|
||||
.filter { $0.sport == sport }
|
||||
.sorted { $0.fullName < $1.fullName }
|
||||
|
||||
if searchText.isEmpty {
|
||||
return allTeams
|
||||
}
|
||||
|
||||
return allTeams.filter {
|
||||
$0.fullName.localizedCaseInsensitiveContains(searchText) ||
|
||||
$0.city.localizedCaseInsensitiveContains(searchText) ||
|
||||
$0.abbreviation.localizedCaseInsensitiveContains(searchText)
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: Theme.Spacing.md) {
|
||||
// Search bar
|
||||
HStack {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.foregroundStyle(Theme.textMuted(colorScheme))
|
||||
|
||||
TextField("Search teams...", text: $searchText)
|
||||
.textFieldStyle(.plain)
|
||||
|
||||
if !searchText.isEmpty {
|
||||
Button {
|
||||
searchText = ""
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.foregroundStyle(Theme.textMuted(colorScheme))
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(Theme.Spacing.sm)
|
||||
.background(Theme.cardBackgroundElevated(colorScheme))
|
||||
.clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.medium))
|
||||
|
||||
// Selection count badge
|
||||
if !selectedTeamIds.isEmpty {
|
||||
HStack {
|
||||
Text("\(selectedTeamIds.count) team\(selectedTeamIds.count == 1 ? "" : "s") selected")
|
||||
.font(.caption)
|
||||
.fontWeight(.medium)
|
||||
.foregroundStyle(.white)
|
||||
.padding(.horizontal, Theme.Spacing.sm)
|
||||
.padding(.vertical, Theme.Spacing.xs)
|
||||
.background(Theme.warmOrange)
|
||||
.clipShape(Capsule())
|
||||
|
||||
Spacer()
|
||||
|
||||
Button("Clear all") {
|
||||
withAnimation(Theme.Animation.spring) {
|
||||
selectedTeamIds.removeAll()
|
||||
}
|
||||
}
|
||||
.font(.caption)
|
||||
.foregroundStyle(Theme.warmOrange)
|
||||
}
|
||||
}
|
||||
|
||||
// Team grid
|
||||
ScrollView {
|
||||
LazyVGrid(columns: columns, spacing: Theme.Spacing.sm) {
|
||||
ForEach(teams) { team in
|
||||
TeamCard(
|
||||
team: team,
|
||||
isSelected: selectedTeamIds.contains(team.id),
|
||||
onTap: { toggleTeam(team) }
|
||||
)
|
||||
}
|
||||
}
|
||||
.padding(.bottom, Theme.Spacing.lg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func toggleTeam(_ team: Team) {
|
||||
withAnimation(Theme.Animation.spring) {
|
||||
if selectedTeamIds.contains(team.id) {
|
||||
selectedTeamIds.remove(team.id)
|
||||
} else {
|
||||
selectedTeamIds.insert(team.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Team Card
|
||||
|
||||
private struct TeamCard: View {
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
|
||||
let team: Team
|
||||
let isSelected: Bool
|
||||
let onTap: () -> Void
|
||||
|
||||
var body: some View {
|
||||
Button(action: onTap) {
|
||||
VStack(spacing: Theme.Spacing.xs) {
|
||||
// Team color circle with checkmark overlay
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(teamColor)
|
||||
.frame(width: 44, height: 44)
|
||||
|
||||
if isSelected {
|
||||
Circle()
|
||||
.fill(Color.black.opacity(0.3))
|
||||
.frame(width: 44, height: 44)
|
||||
|
||||
Image(systemName: "checkmark")
|
||||
.font(.title3)
|
||||
.fontWeight(.bold)
|
||||
.foregroundStyle(.white)
|
||||
}
|
||||
}
|
||||
|
||||
// Team name
|
||||
Text(team.name)
|
||||
.font(.caption)
|
||||
.fontWeight(isSelected ? .semibold : .regular)
|
||||
.foregroundStyle(isSelected ? Theme.warmOrange : Theme.textPrimary(colorScheme))
|
||||
.lineLimit(1)
|
||||
.minimumScaleFactor(0.8)
|
||||
|
||||
// City
|
||||
Text(team.city)
|
||||
.font(.caption2)
|
||||
.foregroundStyle(Theme.textMuted(colorScheme))
|
||||
.lineLimit(1)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, Theme.Spacing.sm)
|
||||
.background(isSelected ? Theme.warmOrange.opacity(0.15) : 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)
|
||||
)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
private var teamColor: Color {
|
||||
if let hex = team.primaryColor {
|
||||
return Color(hex: hex)
|
||||
}
|
||||
return team.sport.themeColor
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Preview
|
||||
|
||||
#Preview {
|
||||
TeamPickerView(
|
||||
sport: .mlb,
|
||||
selectedTeamIds: .constant(["team_mlb_bos", "team_mlb_nyy"])
|
||||
)
|
||||
.padding()
|
||||
.themedBackground()
|
||||
}
|
||||
@@ -27,6 +27,7 @@ struct ReviewStep: View {
|
||||
var selectedTeamName: String? = nil
|
||||
var startLocationName: String? = nil
|
||||
var endLocationName: String? = nil
|
||||
var teamFirstTeamCount: Int = 0
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: Theme.Spacing.md) {
|
||||
@@ -114,6 +115,8 @@ struct ReviewStep: View {
|
||||
return startLocationName ?? "Not selected"
|
||||
case "End Location":
|
||||
return endLocationName ?? "Not selected"
|
||||
case "Teams":
|
||||
return teamFirstTeamCount >= 2 ? "\(teamFirstTeamCount) teams selected" : "Select at least 2 teams"
|
||||
default:
|
||||
return "—"
|
||||
}
|
||||
@@ -180,7 +183,9 @@ private struct ReviewRow: View {
|
||||
selectedGames: .valid,
|
||||
selectedTeam: .valid,
|
||||
startLocation: .valid,
|
||||
endLocation: .valid
|
||||
endLocation: .valid,
|
||||
teamFirstTeams: .valid,
|
||||
teamFirstTeamCount: 0
|
||||
),
|
||||
onPlan: {}
|
||||
)
|
||||
@@ -210,7 +215,9 @@ private struct ReviewRow: View {
|
||||
selectedGames: .valid,
|
||||
selectedTeam: .valid,
|
||||
startLocation: .valid,
|
||||
endLocation: .valid
|
||||
endLocation: .valid,
|
||||
teamFirstTeams: .valid,
|
||||
teamFirstTeamCount: 0
|
||||
),
|
||||
onPlan: {}
|
||||
)
|
||||
|
||||
347
SportsTime/Features/Trip/Views/Wizard/TeamFirstWizardStep.swift
Normal file
347
SportsTime/Features/Trip/Views/Wizard/TeamFirstWizardStep.swift
Normal file
@@ -0,0 +1,347 @@
|
||||
//
|
||||
// TeamFirstWizardStep.swift
|
||||
// SportsTime
|
||||
//
|
||||
// Wizard step for Team-First planning mode.
|
||||
// Uses sheet-based drill-down matching TeamPickerStep: Sport → Teams (multi-select).
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct TeamFirstWizardStep: View {
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
|
||||
@Binding var selectedSport: Sport?
|
||||
@Binding var selectedTeamIds: Set<String>
|
||||
|
||||
@State private var showTeamPicker = false
|
||||
|
||||
private var selectedTeams: [Team] {
|
||||
selectedTeamIds.compactMap { teamId in
|
||||
AppDataProvider.shared.teams.first { $0.id == teamId }
|
||||
}.sorted { $0.fullName < $1.fullName }
|
||||
}
|
||||
|
||||
private var isValid: Bool {
|
||||
selectedTeamIds.count >= 2
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: Theme.Spacing.md) {
|
||||
StepHeader(
|
||||
title: "Which teams do you want to see?",
|
||||
subtitle: "Select 2 or more teams to find optimal trip windows"
|
||||
)
|
||||
|
||||
// Selection button
|
||||
Button {
|
||||
showTeamPicker = true
|
||||
} label: {
|
||||
HStack {
|
||||
if !selectedTeams.isEmpty {
|
||||
// Show selected teams
|
||||
teamPreview
|
||||
|
||||
Spacer()
|
||||
|
||||
Button {
|
||||
selectedTeamIds.removeAll()
|
||||
selectedSport = nil
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.foregroundStyle(Theme.textMuted(colorScheme))
|
||||
}
|
||||
} else {
|
||||
// Empty state
|
||||
Image(systemName: "person.2.fill")
|
||||
.foregroundStyle(Theme.warmOrange)
|
||||
|
||||
Text("Select teams")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(Theme.textMuted(colorScheme))
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(systemName: "chevron.right")
|
||||
.font(.caption)
|
||||
.foregroundStyle(Theme.textMuted(colorScheme))
|
||||
}
|
||||
}
|
||||
.padding(Theme.Spacing.md)
|
||||
.background(Theme.cardBackgroundElevated(colorScheme))
|
||||
.clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.medium))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: Theme.CornerRadius.medium)
|
||||
.stroke(isValid ? Theme.warmOrange : Theme.textMuted(colorScheme).opacity(0.3), lineWidth: isValid ? 2 : 1)
|
||||
)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
|
||||
// Validation message
|
||||
if selectedTeamIds.isEmpty {
|
||||
validationLabel(text: "Select at least 2 teams", isValid: false)
|
||||
} else if selectedTeamIds.count == 1 {
|
||||
validationLabel(text: "Select 1 more team (minimum 2)", isValid: false)
|
||||
} else {
|
||||
validationLabel(text: "Ready to find trips for \(selectedTeamIds.count) teams", isValid: true)
|
||||
}
|
||||
}
|
||||
.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)
|
||||
}
|
||||
.sheet(isPresented: $showTeamPicker) {
|
||||
TeamFirstPickerSheet(
|
||||
selectedSport: $selectedSport,
|
||||
selectedTeamIds: $selectedTeamIds
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Team Preview
|
||||
|
||||
@ViewBuilder
|
||||
private var teamPreview: some View {
|
||||
if selectedTeams.count <= 3 {
|
||||
// Show individual teams
|
||||
HStack(spacing: Theme.Spacing.sm) {
|
||||
ForEach(selectedTeams.prefix(3)) { team in
|
||||
HStack(spacing: Theme.Spacing.xs) {
|
||||
Circle()
|
||||
.fill(team.primaryColor.map { Color(hex: $0) } ?? team.sport.themeColor)
|
||||
.frame(width: 20, height: 20)
|
||||
|
||||
Text(team.abbreviation)
|
||||
.font(.caption)
|
||||
.fontWeight(.medium)
|
||||
.foregroundStyle(Theme.textPrimary(colorScheme))
|
||||
}
|
||||
.padding(.horizontal, Theme.Spacing.sm)
|
||||
.padding(.vertical, Theme.Spacing.xs)
|
||||
.background(Theme.cardBackground(colorScheme))
|
||||
.clipShape(Capsule())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Show count with first few team colors
|
||||
HStack(spacing: -8) {
|
||||
ForEach(Array(selectedTeams.prefix(4).enumerated()), id: \.element.id) { index, team in
|
||||
Circle()
|
||||
.fill(team.primaryColor.map { Color(hex: $0) } ?? team.sport.themeColor)
|
||||
.frame(width: 24, height: 24)
|
||||
.overlay(
|
||||
Circle()
|
||||
.stroke(Theme.cardBackgroundElevated(colorScheme), lineWidth: 2)
|
||||
)
|
||||
.zIndex(Double(4 - index))
|
||||
}
|
||||
}
|
||||
|
||||
Text("\(selectedTeamIds.count) teams")
|
||||
.font(.subheadline)
|
||||
.fontWeight(.medium)
|
||||
.foregroundStyle(Theme.textPrimary(colorScheme))
|
||||
}
|
||||
}
|
||||
|
||||
private func validationLabel(text: String, isValid: Bool) -> some View {
|
||||
HStack(spacing: Theme.Spacing.xs) {
|
||||
Image(systemName: isValid ? "checkmark.circle.fill" : "info.circle.fill")
|
||||
.foregroundStyle(isValid ? .green : Theme.warmOrange)
|
||||
|
||||
Text(text)
|
||||
.font(.caption)
|
||||
.foregroundStyle(Theme.textMuted(colorScheme))
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Team First Picker Sheet
|
||||
|
||||
private struct TeamFirstPickerSheet: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
|
||||
@Binding var selectedSport: Sport?
|
||||
@Binding var selectedTeamIds: Set<String>
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
List {
|
||||
ForEach(Sport.supported, id: \.self) { sport in
|
||||
NavigationLink {
|
||||
TeamMultiSelectListView(
|
||||
sport: sport,
|
||||
selectedTeamIds: $selectedTeamIds,
|
||||
onDone: {
|
||||
selectedSport = sport
|
||||
dismiss()
|
||||
}
|
||||
)
|
||||
} label: {
|
||||
HStack(spacing: Theme.Spacing.sm) {
|
||||
Image(systemName: sport.iconName)
|
||||
.font(.title2)
|
||||
.foregroundStyle(sport.themeColor)
|
||||
.frame(width: 32)
|
||||
|
||||
Text(sport.rawValue)
|
||||
.font(.body)
|
||||
.foregroundStyle(Theme.textPrimary(colorScheme))
|
||||
|
||||
Spacer()
|
||||
|
||||
Text("\(teamsCount(for: sport)) teams")
|
||||
.font(.caption)
|
||||
.foregroundStyle(Theme.textMuted(colorScheme))
|
||||
}
|
||||
.padding(.vertical, Theme.Spacing.xs)
|
||||
}
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.navigationTitle("Select Sport")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button("Cancel") { dismiss() }
|
||||
}
|
||||
}
|
||||
}
|
||||
.presentationDetents([.large])
|
||||
}
|
||||
|
||||
private func teamsCount(for sport: Sport) -> Int {
|
||||
AppDataProvider.shared.teams.filter { $0.sport == sport }.count
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Team Multi-Select List View
|
||||
|
||||
private struct TeamMultiSelectListView: View {
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
|
||||
let sport: Sport
|
||||
@Binding var selectedTeamIds: Set<String>
|
||||
let onDone: () -> Void
|
||||
|
||||
@State private var searchText = ""
|
||||
|
||||
private var teams: [Team] {
|
||||
let allTeams = AppDataProvider.shared.teams
|
||||
.filter { $0.sport == sport }
|
||||
.sorted { $0.fullName < $1.fullName }
|
||||
|
||||
if searchText.isEmpty {
|
||||
return allTeams
|
||||
}
|
||||
|
||||
return allTeams.filter {
|
||||
$0.fullName.localizedCaseInsensitiveContains(searchText) ||
|
||||
$0.city.localizedCaseInsensitiveContains(searchText)
|
||||
}
|
||||
}
|
||||
|
||||
private var selectionCount: Int {
|
||||
// Count only teams from the current sport
|
||||
let sportTeamIds = Set(AppDataProvider.shared.teams.filter { $0.sport == sport }.map { $0.id })
|
||||
return selectedTeamIds.intersection(sportTeamIds).count
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
ForEach(teams) { team in
|
||||
Button {
|
||||
toggleTeam(team)
|
||||
} label: {
|
||||
HStack(spacing: Theme.Spacing.sm) {
|
||||
Circle()
|
||||
.fill(team.primaryColor.map { Color(hex: $0) } ?? sport.themeColor)
|
||||
.frame(width: 28, height: 28)
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(team.fullName)
|
||||
.font(.body)
|
||||
.foregroundStyle(Theme.textPrimary(colorScheme))
|
||||
|
||||
Text(team.city)
|
||||
.font(.caption)
|
||||
.foregroundStyle(Theme.textMuted(colorScheme))
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
if selectedTeamIds.contains(team.id) {
|
||||
Image(systemName: "checkmark.circle.fill")
|
||||
.foregroundStyle(Theme.warmOrange)
|
||||
} else {
|
||||
Image(systemName: "circle")
|
||||
.foregroundStyle(Theme.textMuted(colorScheme).opacity(0.5))
|
||||
}
|
||||
}
|
||||
.padding(.vertical, Theme.Spacing.xs)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.searchable(text: $searchText, prompt: "Search teams")
|
||||
.navigationTitle(sport.rawValue)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .confirmationAction) {
|
||||
Button {
|
||||
onDone()
|
||||
} label: {
|
||||
if selectionCount >= 2 {
|
||||
Text("Done (\(selectionCount))")
|
||||
.fontWeight(.semibold)
|
||||
} else {
|
||||
Text("Done")
|
||||
}
|
||||
}
|
||||
.disabled(selectionCount < 2)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
// Clear selections from other sports when entering
|
||||
let sportTeamIds = Set(AppDataProvider.shared.teams.filter { $0.sport == sport }.map { $0.id })
|
||||
selectedTeamIds = selectedTeamIds.intersection(sportTeamIds)
|
||||
}
|
||||
}
|
||||
|
||||
private func toggleTeam(_ team: Team) {
|
||||
withAnimation(.easeInOut(duration: 0.15)) {
|
||||
if selectedTeamIds.contains(team.id) {
|
||||
selectedTeamIds.remove(team.id)
|
||||
} else {
|
||||
selectedTeamIds.insert(team.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Preview
|
||||
|
||||
#Preview("Empty") {
|
||||
TeamFirstWizardStep(
|
||||
selectedSport: .constant(nil),
|
||||
selectedTeamIds: .constant([])
|
||||
)
|
||||
.padding()
|
||||
.themedBackground()
|
||||
}
|
||||
|
||||
#Preview("Teams Selected") {
|
||||
TeamFirstWizardStep(
|
||||
selectedSport: .constant(.mlb),
|
||||
selectedTeamIds: .constant(["team_mlb_bos", "team_mlb_nyy", "team_mlb_chc"])
|
||||
)
|
||||
.padding()
|
||||
.themedBackground()
|
||||
}
|
||||
@@ -60,6 +60,13 @@ struct TripWizardView: View {
|
||||
)
|
||||
}
|
||||
|
||||
if viewModel.showTeamFirstStep {
|
||||
TeamFirstWizardStep(
|
||||
selectedSport: $viewModel.teamFirstSport,
|
||||
selectedTeamIds: $viewModel.teamFirstSelectedTeamIds
|
||||
)
|
||||
}
|
||||
|
||||
// Common steps (conditionally shown)
|
||||
if viewModel.showDatesStep {
|
||||
DatesStep(
|
||||
@@ -116,7 +123,8 @@ struct TripWizardView: View {
|
||||
selectedGameCount: viewModel.selectedGameIds.count,
|
||||
selectedTeamName: selectedTeamName,
|
||||
startLocationName: viewModel.startLocation?.name,
|
||||
endLocationName: viewModel.endLocation?.name
|
||||
endLocationName: viewModel.endLocation?.name,
|
||||
teamFirstTeamCount: viewModel.teamFirstSelectedTeamIds.count
|
||||
)
|
||||
}
|
||||
.transition(.opacity)
|
||||
@@ -167,7 +175,12 @@ struct TripWizardView: View {
|
||||
// For gameFirst mode, use the UI-selected date range (set by GamePickerStep)
|
||||
// The date range is a 7-day span centered on the selected game(s)
|
||||
var games: [Game]
|
||||
if viewModel.planningMode == .gameFirst && !viewModel.selectedGameIds.isEmpty {
|
||||
if viewModel.planningMode == .teamFirst {
|
||||
// Team-First mode: fetch ALL games for the season
|
||||
// ScenarioEPlanner will generate sliding windows across the full season
|
||||
games = try await AppDataProvider.shared.allGames(for: preferences.sports)
|
||||
print("🔍 TripWizard: Team-First mode - fetched \(games.count) games for \(preferences.sports)")
|
||||
} else if viewModel.planningMode == .gameFirst && !viewModel.selectedGameIds.isEmpty {
|
||||
// Fetch all games for the selected sports within the UI date range
|
||||
// GamePickerStep already set viewModel.startDate/endDate to a 7-day span
|
||||
let allGames = try await AppDataProvider.shared.allGames(for: preferences.sports)
|
||||
@@ -248,6 +261,8 @@ struct TripWizardView: View {
|
||||
sports = viewModel.gamePickerSports
|
||||
} else if viewModel.planningMode == .followTeam, let sport = viewModel.teamPickerSport {
|
||||
sports = [sport]
|
||||
} else if viewModel.planningMode == .teamFirst, let sport = viewModel.teamFirstSport {
|
||||
sports = [sport]
|
||||
} else {
|
||||
sports = viewModel.selectedSports
|
||||
}
|
||||
@@ -264,7 +279,8 @@ struct TripWizardView: View {
|
||||
routePreference: viewModel.routePreference,
|
||||
allowRepeatCities: viewModel.allowRepeatCities,
|
||||
selectedRegions: viewModel.selectedRegions,
|
||||
followTeamId: viewModel.selectedTeamId
|
||||
followTeamId: viewModel.selectedTeamId,
|
||||
selectedTeamIds: viewModel.teamFirstSelectedTeamIds
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user