mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-11 08:56:54 +01:00
44 lines
1.3 KiB
Swift
44 lines
1.3 KiB
Swift
//
|
|
// SettingsSubscriptionsImportDocumentPickerView.swift
|
|
// NetNewsWire-iOS
|
|
//
|
|
// Created by Maurice Parker on 6/16/19.
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
import Account
|
|
|
|
struct SettingsSubscriptionsImportDocumentPickerView : UIViewControllerRepresentable {
|
|
var account: Account
|
|
|
|
func makeUIViewController(context: UIViewControllerRepresentableContext<SettingsSubscriptionsImportDocumentPickerView>) -> UIDocumentPickerViewController {
|
|
let docPicker = UIDocumentPickerViewController(documentTypes: ["public.xml", "org.opml.opml"], in: .import)
|
|
docPicker.delegate = context.coordinator
|
|
return docPicker
|
|
}
|
|
|
|
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: UIViewControllerRepresentableContext<SettingsSubscriptionsImportDocumentPickerView>) {
|
|
//
|
|
}
|
|
|
|
func makeCoordinator() -> Coordinator {
|
|
return Coordinator(self)
|
|
}
|
|
|
|
class Coordinator : NSObject, UIDocumentPickerDelegate {
|
|
var parent: SettingsSubscriptionsImportDocumentPickerView
|
|
|
|
init(_ view: SettingsSubscriptionsImportDocumentPickerView) {
|
|
self.parent = view
|
|
}
|
|
|
|
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
|
|
for url in urls {
|
|
parent.account.importOPML(url) { result in}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|