{"id":20924184,"url":"https://github.com/s-pro/react-native-reusable-code","last_synced_at":"2025-10-06T05:54:59.836Z","repository":{"id":86313123,"uuid":"152855236","full_name":"S-PRO/react-native-reusable-code","owner":"S-PRO","description":"Some reusable code","archived":false,"fork":false,"pushed_at":"2018-11-03T10:50:51.000Z","size":17,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-24T15:09:56.442Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/S-PRO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-10-13T09:16:19.000Z","updated_at":"2018-11-03T10:50:52.000Z","dependencies_parsed_at":"2023-03-10T16:30:11.524Z","dependency_job_id":null,"html_url":"https://github.com/S-PRO/react-native-reusable-code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/S-PRO/react-native-reusable-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-PRO%2Freact-native-reusable-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-PRO%2Freact-native-reusable-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-PRO%2Freact-native-reusable-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-PRO%2Freact-native-reusable-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/S-PRO","download_url":"https://codeload.github.com/S-PRO/react-native-reusable-code/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-PRO%2Freact-native-reusable-code/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278565511,"owners_count":26007757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T20:19:54.958Z","updated_at":"2025-10-06T05:54:59.831Z","avatar_url":"https://github.com/S-PRO.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-reusable-code:\n\n## MAP:\n\n1. [imagePicker](#imagePicker)\n\n2. [actionSheet](#actionSheet)\n\n3. [audio](#audio)\n\n4. [documentPicker module](#documentPicker-module)\n\n\n## imagePicker:\n\n### Uses:\n\n* [react-native-permissions v \"1.1.1\"](https://github.com/yonahforst/react-native-permissions)\n\n* [react-native-image-crop-picker v \"0.21.1\"](https://github.com/ivpusic/react-native-image-crop-picker)\n\n* [@yfuks/react-native-action-sheet v \"0.0.5\"](https://github.com/yfuks/react-native-action-sheet)\n\n* [actionSheet.js](actionSheet.js)\n\n### Methods:\n\n|method | arguments | description|\n|------ | ---- | -------|\n|launchImageLibrary | ```{ height?: number, width?: number}``` - optional | calls default phone gallery; `height` and `width` params (if provided) will be set for cropping area; returns `Promise`;|\n|launchCamera | ```{ height?: number, width?: number}``` - optional | calls default phone camera; `height` and `width` params (if provided) will be set for cropping area; returns `Promise`;|\n|open | ```{ cameraLabel: string, galleryLabel: string, cancelLabel: string, onSelect: (base64: string) =\u003e {}, options?: { height?: number, width?: number}}``` | Opens `actionSheet` with 3 buttons (Camera, Gallery, Cancel);|\n\n### How to use:\n\n1. Install [react-native-permissions](https://github.com/yonahforst/react-native-permissions), [react-native-image-crop-picker](https://github.com/ivpusic/react-native-image-crop-picker) and [@yfuks/react-native-action-sheet](https://github.com/yfuks/react-native-action-sheet)\n2. Copy `imagePicker.js` to your project;\n3. Copy `actionSheet.js` to your project;\n4. Import `ImagePicker from 'src/imagePicker.js'`;\n5. Call one of supported methods;\n\n### Examples:\n\n1. `launchImageLibrary` method:\n\n```\nImagePicker\n.launchImageLibrary({width: 200, height: 200})\n.then((base64: string) =\u003e {})\n```\n\n2. `launchCamera` method:\n\n```\nImagePicker\n.launchCamera({width: 200, height: 200})\n.then((base64: string) =\u003e {})\n```\n\n3. `open` method:\n\n```\nImagePicker.open({\n  cameraLabel: \"Open Camera\",\n  galleryLabel: \"Open Gallery\",\n  cancelLabel: \"Cancel\",\n  onSelect: (base64string) =\u003e {}\n});\n```\n\n\n## actionSheet:\n\n### Uses:\n\n* [@yfuks/react-native-action-sheet v \"0.0.5\"](https://github.com/yfuks/react-native-action-sheet)\n\n### Methods:\n\n|method | arguments | description|\n|------ | ---- | -------|\n|show | ```Array\u003c{ label: string, onPress: Function, isCancel?: boolean }\u003e``` | calls default phone gallery; `height` and `width` params (if provided) will be set for cropping area;|\n\n### How to use:\n\n1. Install [@yfuks/react-native-action-sheet](https://github.com/yfuks/react-native-action-sheet)\n2. Copy `actionSheet.js` to your project;\n3. Import `ActionSheet from 'src/actionSheet.js'`;\n4. Call `show` method with supported arguments;\n\n\n### Examples:\n\n\n1. `show` method:\n\n```\nconst options = [\n  {\n    label: props.cameraLabel,\n    onPress: () =\u003e {}\n  },\n  {\n    label: props.galleryLabel,\n    onPress: () =\u003e {}\n  },\n  {\n    label: props.cancelLabel,\n    onPress: () =\u003e {},\n    isCancel: true,\n  },\n];\nActionSheet.show(options);\n```\n\n\n\n## audio:\n\n### Uses:\n\n* [react-native-audio-recorder-player v \"2.0.8\"](https://github.com/dooboolab/react-native-audio-recorder-player)\n* [react-native-audio-toolkit v \"2.0.8\"](https://github.com/futurice/react-native-audio-toolkit)\n\n### Methods:\n\n|method | arguments | description|\n|------ | ---- | -------|\n|onStartRecord | ```{ callback: (err: string, path: string) =\u003e void }``` | starts recording audio to a file, by default record.mp4;|\n|onStopRecord | ```{ callback: (err: string) =\u003e void }``` | stop recording audio;|\n|onStartPlay | ```{ path: string }``` | starts play audio from url or local file; return Promise|\n|onPausePlay | ```{ }``` | Pause the player;|\n|onStopPlay | ```{ }``` | Stops the player and removes the listener;|\n\n### How to use:\n\n1. Install [react-native-audio-recorder-player](https://github.com/dooboolab/react-native-audio-recorder-player)\n2. Install [react-native-audio-toolkit](https://github.com/futurice/react-native-audio-toolkit)\n3. Copy `audio.js` to your project;\n3. Import `import AudioRecorder from 'src/audio';`\n4. Call `onStartRecord` method with supported arguments;\n4. Call `onStopRecord` method with supported arguments;\n4. Call `onStartPlay` method with supported arguments;\n4. Call `onPausePlay` method with supported arguments;\n4. Call `onStopPlay` method with supported arguments;\n\n\n### Examples:\n\n1. initial for use AudioRecorder:\n```\naudioRecorder = new AudioRecorder();\n```\n2. `onStartRecord` method:\n\n```\nthis.audioRecorder.onStartRecord((err, filename) =\u003e {\n  if (err) {\n    console.log(err);\n  }\n\n  this.setState(() =\u003e ({ filename }));\n});\n```\n\n3. `onStopRecord` method:\n\n```\n  this.audioRecorder.onStopRecord((err) =\u003e {\n    if (err) {\n      console.log(\"error stop recording\", err);\n    }\n  });\n```\n\n4. `onStartPlay` method:\n\n```\n  this.audioRecorder.onStartPlay(\"https://somelink/record.mp4\");\n  this.audioRecorder.onStartPlay(\"file:///sdcard/record.mp4\");\n```\n\n5. `onPausePlay` method:\n\n```\n  this.audioRecorder.onPausePlay();\n```\n\n6. `onStopPlay` method:\n\n```\n  this.audioRecorder.onStopPlay();\n```\n\n\n## documentPicker module:\n\n* [documentPicker.js](documentPicker/documentPicker.js)\n* [file.helper.js](documentPicker/file.helper.js)\n* [attachment.config.js](documentPicker/attachment.config.js)\n\n### Uses:\n\n* [react-native-document-picker v \"2.1.0\"](https://github.com/Elyx0/react-native-document-picker)\n\n* [react-native-doc-viewer v \"2.7.8\"](https://github.com/philipphecht/react-native-doc-viewer)\n\n* [react-native-mime-types v \"2.2.1\"](https://github.com/Liroo/react-native-mime-types)\n\n\n### documentPicker.js methods:\n\n|method | arguments | description|\n|------ | ---- | -------|\n|init | none | opens native document picker; returns `Promise` with file; uses [react-native-document-picker v \"2.1.0\"](https://github.com/Elyx0/react-native-document-picker);|\n|openFile | ```{ uri: string, fileName: string, type: string }``` | opens document viewer; for iOS: only `uri` required; for Android: `uri`, `fileName`, `type` fields required; returns `void`; uses [react-native-doc-viewer v \"2.7.8\"](https://github.com/philipphecht/react-native-doc-viewer);|\n\n### file.helper.js methods:\n\n|method | arguments | description|\n|------ | ---- | -------|\n|checkType | `type: string` | checks if provided `type` is in list of possible extensions (listed in [attachment.config.js](documentPicker/attachment.config.js)); returns `boolean`;|\n|getType | `name: string` | return mime type for provided `name`; returns `string`; uses [react-native-mime-types v \"2.2.1\"](https://github.com/Liroo/react-native-mime-types);|\n|getFileName | `url: string` | return filename for provided `url`; returns `string`; |\n\n### How to use `documentPicker.js`:\n\n1. Install [react-native-document-picker](https://github.com/Elyx0/react-native-document-picker), [react-native-doc-viewer](https://github.com/philipphecht/react-native-doc-viewer) and [react-native-mime-types](https://github.com/Liroo/react-native-mime-types)\n2. Copy `documentPicker` folder to your project;\n3. Import `DocumentPicker from 'src/documentPicker/documentPicker'`;\n4. Call one of supported methods;\n\n### Examples:\n\n1. `init` method:\n\n```\nDocumentPicker\n.init()\n.then((res: {\n  type: string,\n  fileName: string,\n  uri: string,\n  data?: {},\n  fileSize: number\n}) =\u003e {})\n```\n\n2. `openFile` method:\n\n```\nDocumentPicker\n.openFile({\n  uri,\n  fileName,\n  type\n})\n```\n\n\n### How to use `file.helper.js`:\n\n1. Install [react-native-mime-types](https://github.com/Liroo/react-native-mime-types)\n2. Copy `documentPicker` folder to your project;\n3. Import `* as FileHelper from 'src/documentPicker/file.helper'`;\n4. Call one of supported methods;\n\n### Examples:\n\n1. `checkType` method:\n\n```\nFileHelper\n.checkType(\"image/jpeg\"); // boolean here\n```\n\n2. `getType` method:\n\n```\nFileHelper\n.getType(\"image.jpeg\"); // `image/jpeg` here\n```\n\n2. `getFileName` method:\n\n```\nFileHelper\n.getFileName(\"file:///folder1/folder2/image.jpeg\"); // `image.jpeg` here\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs-pro%2Freact-native-reusable-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs-pro%2Freact-native-reusable-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs-pro%2Freact-native-reusable-code/lists"}