2019-06-16 17:54:18 +02:00
|
|
|
//
|
2019-06-16 18:19:15 +02:00
|
|
|
// SettingsSubscriptionsImportDocumentPickerView.swift
|
2019-06-16 17:54:18 +02:00
|
|
|
// NetNewsWire-iOS
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 6/16/19.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
import Account
|
|
|
|
|
2019-06-16 18:19:15 +02:00
|
|
|
struct SettingsSubscriptionsImportDocumentPickerView : UIViewControllerRepresentable {
|
|
|
|
var account: Account
|
2019-06-16 17:54:18 +02:00
|
|
|
|
2019-06-16 18:19:15 +02:00
|
|
|
func makeUIViewController(context: UIViewControllerRepresentableContext<SettingsSubscriptionsImportDocumentPickerView>) -> UIDocumentPickerViewController {
|
2019-06-16 17:54:18 +02:00
|
|
|
let docPicker = UIDocumentPickerViewController(documentTypes: ["public.xml", "org.opml.opml"], in: .import)
|
|
|
|
docPicker.delegate = context.coordinator
|
|
|
|
return docPicker
|
|
|
|
}
|
|
|
|
|
2019-06-16 18:19:15 +02:00
|
|
|
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: UIViewControllerRepresentableContext<SettingsSubscriptionsImportDocumentPickerView>) {
|
2019-06-16 17:54:18 +02:00
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeCoordinator() -> Coordinator {
|
|
|
|
return Coordinator(self)
|
|
|
|
}
|
|
|
|
|
|
|
|
class Coordinator : NSObject, UIDocumentPickerDelegate {
|
2019-06-16 18:19:15 +02:00
|
|
|
var parent: SettingsSubscriptionsImportDocumentPickerView
|
2019-06-16 17:54:18 +02:00
|
|
|
|
2019-06-16 18:19:15 +02:00
|
|
|
init(_ view: SettingsSubscriptionsImportDocumentPickerView) {
|
2019-06-16 17:54:18 +02:00
|
|
|
self.parent = view
|
|
|
|
}
|
|
|
|
|
|
|
|
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
|
|
|
|
for url in urls {
|
2019-06-16 18:19:15 +02:00
|
|
|
parent.account.importOPML(url) { result in}
|
2019-06-16 17:54:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|