mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add OPML Export for SwiftUI
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// SettingsSubscriptionsExportDocumentPickerView.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Maurice Parker on 6/16/19.
|
||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Account
|
||||
|
||||
struct SettingsSubscriptionsExportDocumentPickerView : UIViewControllerRepresentable {
|
||||
var account: Account
|
||||
|
||||
func makeUIViewController(context: UIViewControllerRepresentableContext<SettingsSubscriptionsExportDocumentPickerView>) -> UIDocumentPickerViewController {
|
||||
|
||||
let accountName = account.nameForDisplay.replacingOccurrences(of: " ", with: "").trimmingCharacters(in: .whitespaces)
|
||||
let filename = "Subscriptions-\(accountName).opml"
|
||||
let tempFile = FileManager.default.temporaryDirectory.appendingPathComponent(filename)
|
||||
|
||||
let opmlString = OPMLExporter.OPMLString(with: account, title: filename)
|
||||
try? opmlString.write(to: tempFile, atomically: true, encoding: String.Encoding.utf8)
|
||||
|
||||
return UIDocumentPickerViewController(url: tempFile, in: .exportToService)
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: UIViewControllerRepresentableContext<SettingsSubscriptionsExportDocumentPickerView>) {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user