0.2.1 • Published 2 years ago

@paraboly/react-native-media-picker v0.2.1

Weekly downloads
13
License
MIT
Repository
github
Last release
2 years ago

Battle Tested ✅

Easy to use media picker modal for React Native by Paraboly

npm version npm Platform - Android and iOS License: MIT styled with prettier

Installation

Add the dependency:

npm i @paraboly/react-native-media-picker

Peer Dependencies

IMPORTANT! You need install them
"@freakycoder/react-native-helpers": ">= 0.1.2",
"react-native-image-crop-picker": ">= 0.26.2",
"react-native-modalize": ">= 2.0.0",
"react-native-vector-icons": ">= 6.6.0",
"react-native-dynamic-vector-icons": ">= 0.2.1",

iOS & Android Permissions

iOS

<key>NSCameraUsageDescription</key>
<string>This allows us to capture and use the the captured photo</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This allows us to show/pick a photo from your library</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This allows us to show/pick a photo from your library</string>

Android

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Usage

Import

import MediaPicker from "@paraboly/react-native-media-picker";

Basic Usage

<MediaPicker>

Advanced Usage

You can check the example :) Put your own logic for galleryOnPress or cameraOnPress both returns the callback of the images.

<MediaPicker
  multiple
  ref={(ref) => (this.mediaPicker = ref)}
  cameraOnPress={(image: any) => {
    this.setState({ image });
  }}
  galleryOnPress={(images: any) => {
    this.setState({
      image: null,
      images: images.map((image: any) => {
        return {
          uri: image.path,
          width: image.width,
          height: image.height,
          mime: image.mime,
        };
      }),
    });
    // ? Single Image (Multiple = false)
    // this.setState({
    //   image: {
    //     uri: image.path,
    //     width: image.width,
    //     height: image.height,
    //     mime: image.mime
    //   }
    // });
  }}
/>

Open/Close The MediaPicker Modal

Open

this.mediaPicker.openModal();

Close

this.mediaPicker.closeModal();

Configuration - Props

PropertyTypeDefaultDescription
IconComponentcomponentIconset your own Icon component such as Icon from react-native-vector-icons
multiplebooleantruechange the picking media's as single or multiple at once
cameraTextstringCamerachange the camera button's text
galleryTextstringGallerychange the gallery button's text
backgroundColorcolor#90a1fcchange the modal's background color
onCameraPressfunctiondefaultset your own logic when camera is on pressed (please check the example)
onGalleryPressfunctiondefaultset your own logic when gallery is on pressed (please check the example)
cameraIconNamestringcamerachange the camera's icon name
cameraIconTypestringFontAwesomechange the camera's icon type
cameraIconColorcolor#fdfdfdchange the camera's icon color
cameraIconSizenumber20change the camera's icon size
galleryIconNamestringmd-photoschange the gallery's icon name
galleryIconTypestringIoniconschange the gallery's icon type
galleryIconColorcolor#fdfdfdchange the gallery's icon color
galleryIconSizenumber20change the gallery's icon size
cameraButtonBackgroundColorcolor#fdfdfdchange the camera button's background color
galleryButtonBackgroundColorcolor#fdfdfdchange the gallery button's background color
cameraButtonSizenumber50change the camera button's whole size
galleryButtonSizenumber50change the gallery button's whole size
cameraTextColorcolor#fdfdfdchange the camera button's text color
galleryTextColorcolor#fdfdfdchange the gallery button's text color
compressImageQualitynumber0.5change the quality of your photo
onCameraButtonPressedfunctiondefaultset instead of react-native-image-crop-picker library when preesing camera
onGalleryButtonPressedfunctiondefaultset instead of react-native-image-crop-picker library when preesing gallery

Future Plans

  • LICENSE
  • Write an article about the lib on Medium

Author

FreakyCoder, kurayogun@gmail.com

License

React Native Media Picker by Paraboly is available under the MIT license. See the LICENSE file for more info.

0.2.1

2 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago