-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Import/Eport/Delete collection (New strings added #68 )
- Loading branch information
Showing
8 changed files
with
355 additions
and
93 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Binary file not shown.
This file contains 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
61 changes: 61 additions & 0 deletions
61
ACHNBrowserUI/ACHNBrowserUI/representables/DocumentPickerView.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// DocumentPickerView.swift | ||
// ACHNBrowserUI | ||
// | ||
// Created by Thomas Ricouard on 14/05/2020. | ||
// Copyright © 2020 Thomas Ricouard. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
#if !os(tvOS) | ||
public final class DocumentPickerView: NSObject, UIViewControllerRepresentable, UIDocumentPickerDelegate { | ||
public let url: URL? | ||
public let mode: UIDocumentPickerMode | ||
|
||
@Binding var importedFile: URL? | ||
|
||
public init(url: URL?, mode: UIDocumentPickerMode, importedFile: Binding<URL?>) { | ||
self.url = url | ||
self.mode = mode | ||
self._importedFile = importedFile | ||
} | ||
|
||
public class Coordinator: NSObject, UIDocumentPickerDelegate { | ||
var parent: DocumentPickerView | ||
|
||
init(_ parent: DocumentPickerView) { | ||
self.parent = parent | ||
} | ||
|
||
public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { | ||
if let file = urls.first { | ||
parent.importedFile = file | ||
} | ||
} | ||
} | ||
|
||
public func makeCoordinator() -> Coordinator { | ||
Coordinator(self) | ||
} | ||
|
||
public func makeUIViewController(context: UIViewControllerRepresentableContext<DocumentPickerView>) -> UIDocumentPickerViewController { | ||
if let url = url, mode == .exportToService { | ||
let picker = UIDocumentPickerViewController(url: url, in: mode) | ||
return picker | ||
} else { | ||
let picker = UIDocumentPickerViewController(documentTypes: ["com.thomasricouard.ACNH.achelper"], | ||
in: .import) | ||
picker.delegate = context.coordinator | ||
return picker | ||
} | ||
} | ||
|
||
public func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, | ||
context: UIViewControllerRepresentableContext<DocumentPickerView>) { | ||
|
||
} | ||
} | ||
#endif | ||
|
Oops, something went wrong.