feat: add file export option to HistoryDetailsView for saving activities to Files app#55
Open
odrinateur wants to merge 1 commit into
Open
feat: add file export option to HistoryDetailsView for saving activities to Files app#55odrinateur wants to merge 1 commit into
odrinateur wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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
.filesoption. - 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") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#54 !