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:
@@ -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 }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user