Add OPML Export for SwiftUI

This commit is contained in:
Maurice Parker
2019-06-16 11:19:15 -05:00
parent 3af60f0edc
commit d4e2d44d8f
4 changed files with 65 additions and 37 deletions

View File

@@ -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>) {
//
}
}