react-native-documents / document-picker

Document Picker for React Native
https://react-native-documents.github.io/
MIT License
1.35k stars 440 forks source link

Support react-native-macos #361

Open shahthepro opened 4 years ago

shahthepro commented 4 years ago

Feature request

Add support for react-native-macos npm package and macOS target.

vonovak commented 3 years ago

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!

jihoobyeon commented 2 years ago

@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

hsjoberg commented 2 years ago

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

hsjoberg commented 2 years ago

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
 }
}
jihoobyeon commented 2 years ago

It seems to be hard because AppKit has NSOpenPanel and NSSavePanel separately.\ maybe we have to make separate package to support macOS.

danilaplee commented 1 year ago

https://github.com/rnmods/react-native-document-picker/pull/612 added the barebones support can anyone test this one in ios, because i currently don't have a stable ios build of my app

I have tested only on mac os

danilaplee commented 1 year ago

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!

done https://github.com/rnmods/react-native-document-picker/pull/612