document-picker
document-picker copied to clipboard
Support react-native-macos
hello, I do not plan to do this but am open to be hired to do this or review a PR that implements this. 🙂
thank you!
@shahthepro It seems like you have to use Mac Catalyst since UIDocumentPickerViewController doesn't support macOS natively.
https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller?language=objc
AppKit has a different API instead of UIDocumentPickerViewController for dealing with save and open dialogs.
https://github.com/hsjoberg/blixt-wallet/blob/431ff0d60a423c44d77ba48be46da026b92b6bd0/ios/LndMobile/LndMobileTools.swift#L227-L252
Here's a simple example in Swift on how to open a file
DispatchQueue.main.async {
do {
let panel = NSOpenPanel()
panel.allowsMultipleSelection = false
panel.canChooseDirectories = false
if panel.runModal() == .OK {
if let u = panel.url {
let base64 = try Data(contentsOf: u).base64EncodedString())
} else {
// error
}
} else {
// ...
}
}
catch {
// exception
}
}
It seems to be hard because AppKit has NSOpenPanel and NSSavePanel separately.
maybe we have to make separate package to support macOS.