Skip to content

feat: add file export option to HistoryDetailsView for saving activities to Files app#55

Open
odrinateur wants to merge 1 commit into
msimms:masterfrom
odrinateur:feat/export-to-local-files
Open

feat: add file export option to HistoryDetailsView for saving activities to Files app#55
odrinateur wants to merge 1 commit into
msimms:masterfrom
odrinateur:feat/export-to-local-files

Conversation

@odrinateur
Copy link
Copy Markdown

#54 !

Copilot AI review requested due to automatic review settings May 21, 2026 06:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a local “Save to Files” export destination to the iOS History Details screen so users can export activity files (GPX/TCX/FIT/CSV) to the Files app without relying on iCloud.

Changes:

  • Extended export destination selection to include a new .files option.
  • Introduced a UIKit-based document picker flow to export a generated temp file to Files.
  • Updated export-format actions (GPX/TCX/FIT/CSV) to route through the selected destination (iCloud / Files / email).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +65 to +76
class FileExportViewController: UIViewController {
func displayFileExporterSheet(fileName: String) {
let keyWindow = UIApplication.shared.connectedScenes
.filter({$0.activationState == .foregroundActive})
.compactMap({$0 as? UIWindowScene})
.first?.windows
.filter({$0.isKeyWindow}).first

let fileUrl = URL(fileURLWithPath: fileName)
let picker = UIDocumentPickerViewController(forExporting: [fileUrl], asCopy: true)
keyWindow?.rootViewController?.present(picker, animated: true)
}
Comment on lines +66 to +73
func displayFileExporterSheet(fileName: String) {
let keyWindow = UIApplication.shared.connectedScenes
.filter({$0.activationState == .foregroundActive})
.compactMap({$0 as? UIWindowScene})
.first?.windows
.filter({$0.isKeyWindow}).first

let fileUrl = URL(fileURLWithPath: fileName)
Comment on lines +518 to +522
else if self.exportDestination == ExportDest.files {
let tempFileName = try self.activityVM.exportActivityToTempFile(fileFormat: FILE_GPX)
let fileExportController = FileExportViewController()
fileExportController.displayFileExporterSheet(fileName: tempFileName)
}
Comment on lines 511 to +527
if IsHistoricalActivityMovingActivity(self.activityVM.activityId) {
Button("GPX") {
do {
if self.exportDestination == ExportDest.icloud {
let _ = try self.activityVM.exportActivityToICloudFile(fileFormat: FILE_GPX)
self.showingExportSucceededError = true
}
else {
let tempFileName = try self.activityVM.exportActivityToTempFile(fileFormat: FILE_GPX)
let mailController = MailComposeViewController()
try mailController.displayEmailComposerSheet(subjectStr: "", bodyStr: "", fileName: tempFileName, mimeType: "text/xml")
}
do {
if self.exportDestination == ExportDest.icloud {
let _ = try self.activityVM.exportActivityToICloudFile(fileFormat: FILE_GPX)
self.showingExportSucceededError = true
}
else if self.exportDestination == ExportDest.files {
let tempFileName = try self.activityVM.exportActivityToTempFile(fileFormat: FILE_GPX)
let fileExportController = FileExportViewController()
fileExportController.displayFileExporterSheet(fileName: tempFileName)
}
else {
let tempFileName = try self.activityVM.exportActivityToTempFile(fileFormat: FILE_GPX)
let mailController = MailComposeViewController()
try mailController.displayEmailComposerSheet(subjectStr: "", bodyStr: "", fileName: tempFileName, mimeType: "text/xml")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants