wip
This commit is contained in:
@@ -9,6 +9,7 @@ struct ScheduleListView: View {
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
@State private var viewModel = ScheduleViewModel()
|
||||
@State private var showDatePicker = false
|
||||
@State private var showDiagnostics = false
|
||||
|
||||
private var allGames: [RichGame] {
|
||||
viewModel.gamesBySport.flatMap(\.games)
|
||||
@@ -45,11 +46,22 @@ struct ScheduleListView: View {
|
||||
Label("Clear Filters", systemImage: "xmark.circle")
|
||||
}
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
Button {
|
||||
showDiagnostics = true
|
||||
} label: {
|
||||
Label("Diagnostics", systemImage: "info.circle")
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: viewModel.hasFilters ? "line.3.horizontal.decrease.circle.fill" : "line.3.horizontal.decrease.circle")
|
||||
}
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showDiagnostics) {
|
||||
ScheduleDiagnosticsSheet(diagnostics: viewModel.diagnostics)
|
||||
}
|
||||
.sheet(isPresented: $showDatePicker) {
|
||||
DateRangePickerSheet(
|
||||
startDate: viewModel.startDate,
|
||||
@@ -374,6 +386,89 @@ struct DateRangePickerSheet: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Schedule Diagnostics Sheet
|
||||
|
||||
struct ScheduleDiagnosticsSheet: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
let diagnostics: ScheduleDiagnostics
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
List {
|
||||
Section("Query Details") {
|
||||
if let start = diagnostics.lastQueryStartDate,
|
||||
let end = diagnostics.lastQueryEndDate {
|
||||
LabeledContent("Start Date") {
|
||||
Text(start.formatted(date: .abbreviated, time: .shortened))
|
||||
}
|
||||
LabeledContent("End Date") {
|
||||
Text(end.formatted(date: .abbreviated, time: .shortened))
|
||||
}
|
||||
} else {
|
||||
Text("No query executed")
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
if !diagnostics.lastQuerySports.isEmpty {
|
||||
LabeledContent("Sports Filter") {
|
||||
Text(diagnostics.lastQuerySports.map(\.rawValue).joined(separator: ", "))
|
||||
.font(.caption)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Section("Data Loaded") {
|
||||
LabeledContent("Teams", value: "\(diagnostics.teamsLoaded)")
|
||||
LabeledContent("Stadiums", value: "\(diagnostics.stadiumsLoaded)")
|
||||
LabeledContent("Total Games", value: "\(diagnostics.totalGamesReturned)")
|
||||
}
|
||||
|
||||
if !diagnostics.gamesBySport.isEmpty {
|
||||
Section("Games by Sport") {
|
||||
ForEach(diagnostics.gamesBySport.sorted(by: { $0.key.rawValue < $1.key.rawValue }), id: \.key) { sport, count in
|
||||
LabeledContent {
|
||||
Text("\(count)")
|
||||
.fontWeight(.semibold)
|
||||
} label: {
|
||||
HStack {
|
||||
Image(systemName: sport.iconName)
|
||||
.foregroundStyle(sport.themeColor)
|
||||
Text(sport.rawValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Section("Troubleshooting") {
|
||||
Text("If games are missing:")
|
||||
.font(.subheadline)
|
||||
.fontWeight(.medium)
|
||||
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Label("Check the date range above matches your expectations", systemImage: "1.circle")
|
||||
Label("Verify the sport is enabled in the filter", systemImage: "2.circle")
|
||||
Label("Pull down to refresh the schedule", systemImage: "3.circle")
|
||||
Label("Check Settings > Debug > CloudKit Sync for sync status", systemImage: "4.circle")
|
||||
}
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
.navigationTitle("Schedule Diagnostics")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .confirmationAction) {
|
||||
Button("Done") {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.presentationDetents([.medium, .large])
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
NavigationStack {
|
||||
ScheduleListView()
|
||||
|
||||
Reference in New Issue
Block a user