Created
March 27, 2022 15:02
-
-
Save jayala/6bf869c77e86ff6477e267baa6d74db1 to your computer and use it in GitHub Desktop.
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
RCT_EXPORT_METHOD(pick:(NSDictionary *)options | |
resolver:(RCTPromiseResolveBlock)resolve | |
rejecter:(RCTPromiseRejectBlock)reject) | |
{ | |
mode = options[@"mode"] && [options[@"mode"] isEqualToString:@"open"] ? UIDocumentPickerModeOpen : UIDocumentPickerModeImport; | |
copyDestination = options[@"copyTo"]; | |
UIModalPresentationStyle presentationStyle = [RCTConvert UIModalPresentationStyle:options[@"presentationStyle"]]; | |
[promiseWrapper setPromiseWithInProgressCheck:resolve rejecter:reject fromCallSite:@"pick"]; | |
NSArray *allowedUTIs = [RCTConvert NSArray:options[OPTION_TYPE]]; | |
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:allowedUTIs inMode:mode]; | |
documentPicker.modalPresentationStyle = presentationStyle; | |
documentPicker.delegate = self; | |
documentPicker.presentationController.delegate = self; | |
documentPicker.allowsMultipleSelection = [RCTConvert BOOL:options[OPTION_MULTIPLE]]; | |
UIViewController *rootViewController = RCTPresentedViewController(); | |
[rootViewController presentViewController:documentPicker animated:YES completion:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment