Allow PDF data export when AI is unavailable on Reports screen

Users without Apple Intelligence can now export their mood data as a
visual PDF with charts and statistics instead of seeing a disabled
Generate button. The existing ExportService.exportPDF is reused for
the non-AI path, gated behind the same privacy confirmation dialog.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-03-17 23:04:50 -05:00
parent c7f05335c8
commit 0f128da154
4 changed files with 154 additions and 24 deletions

View File

@@ -55,6 +55,10 @@ class ReportsViewModel: ObservableObject {
validEntryCount >= 3 && isAIAvailable
}
var canExportData: Bool {
validEntryCount >= 1
}
var daySpan: Int {
let components = Calendar.current.dateComponents([.day], from: startDate, to: endDate)
return (components.day ?? 0) + 1
@@ -139,6 +143,22 @@ class ReportsViewModel: ObservableObject {
// MARK: - PDF Export
func exportDataPDF() {
let entries = entriesInRange
guard !entries.isEmpty else { return }
let url = ExportService.shared.exportPDF(entries: entries)
if let url {
exportedPDFURL = url
showShareSheet = true
AnalyticsManager.shared.track(.reportExported(
type: "data_export",
entryCount: entries.count
))
}
}
func exportPDF() {
guard let report = generatedReport else { return }