1.0.6 • Published 1 year ago

@delainetech/react-native-story-camera v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Camera View - DelaineTech

react-native-story-camera


React Native Story Camera is a fully customizable UI library that provide camera picker module for capture photos and record videos in React Native, inspired by WhatsApp's media sharing experience.

🎬 Overview

React Native Story Camera allows users to capture videos and photos, as well as select multiple images and videos from their device gallery. Built with the latest version of React Native. It is simple to use and works on both Android and iOS platforms.

🎬 Features

  • Capture videos and photos: A customizable camera interface
  • Select multiple images and videos: Access the device's media gallery.
  • Pagination: Smooth scrolling for large media lists.
  • Video Recording: Seamless recording experience
  • Fully customizable: Tailor the UI to your needs with available props
  • Cross-platform compatibility: compatible with both Android and iOS platforms
  • Formatted Data: Return formatted and optimized data from camera and gallery for all media type
  • Optimized for performance: Built with modern React Native practices

🎬 Preview


| alt Default


🎬 Quick Access

🎬 Installation | Permissions | Usage | Props | Example | License

Installation

1. Install React Native Story Camera
  npm install @delainetech/react-native-story-camera

--- or ---

  yarn add @delainetech/react-native-story-camera
2. Install peer dependencies

To use React Native Story Camera, you need to install the following dependencies:

react-native-vision-camera is a camera library for React Native apps.

@react-native-camera-roll/camera-roll is used to access media files from device library

react-native-image-crop-picker is a media picker library for React Native apps.

react-native-permissions is added to access camera and storage permission in Android & IOS devices.

react-native-reanimated is a animation library for React Native apps.

react-native-gesture-handler is a gesture effects library for React Native apps.

$ npm install react-native-vision-camera react-native-permissions react-native-reanimated react-native-gesture-handler @react-native-camera-roll/camera-roll react-native-image-crop-picker

# --- or ---

$ yarn add react-native-vision-camera react-native-permissions react-native-reanimated react-native-gesture-handler @react-native-camera-roll/camera-roll react-native-image-crop-picker

Note: If you already have these libraries installed of the latest versions, you are done here! . If not then please Please follow the installation instructions for each dependency on their respective GitHub pages.

3. Install cocoapods in the ios project
cd ios && pod install

Note: Make sure to add Reanimated's babel plugin to your babel.config.js

module.exports = {
      ...   // do not add it here
      plugins: [
          ...
          'react-native-reanimated/plugin',
      ],
  };

Permissions

To use React Native Story Camera, you need to add the following permissions to your project:

1. iOS

Add the following permissions to your project Info.plist file:

<key>NSCameraUsageDescription</key>
<string>Allow access to capture photo</string>

<key>NSMicrophoneUsageDescription</key>
<string>Allow access to record audio</string>

<key>NSPhotoLibraryUsageDescription</key>
<string>Allow access to select photo</string>
2. Android

Add the following permissions to your AndroidManifest.xml file:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEOS"/>

Note: After added these above permission . You are done here . No Need to do extra permission work in your main component file .

Usage


import {  View } from 'react-native'

import React from 'react'

import CameraPicker from 'react-native-story-camera';

export default function App() {
  return (
      <View style={{ flex : 1}}>
        <CameraPicker
          onSelect={(data:any)=>console.log("data : "+JSON.stringify(data))}
          onBackPress={()=>console.log("onBack Press")} />
      </View>
  );
}

Icon Props & styles

PropDefaultTypeDescription
containerStyle{}ViewStyleCameraPicker container view style
backIcondefaultImageApply local icon image with require label
backIconStyle{}ImageStyleApply all style props of Image component react native
flashOnIcondefaultImageApply local icon image with require label
flashOffIcondefaultImageApply local icon image with require label
flashIconStyledefaultImageStyleApply all style props of Image component react native
galleryIcondefaultImageApply local icon image with require label
galleryIconStyle{}ImageStyleApply all style props of Image component react native
cameraToggleIcondefaultImageApply local icon image with require label
cameraToggleIconStyle{}ImageStyleApply all style props of Image component react native
cameraCaptureIcondefaultImageApply local icon image with require label
cameraCaptureIconStyle{}ImageStyleApply all style props of Image component react native
videoCaptureIcon{}ImageApply local icon image with require label
videoCaptureIconStyle{}ImageStyleApply all style props of Image component react native
recordVideoIcondefaultImageApply local icon image with require label
recordVideoIconStyle{}ImageStyleApply all style props of Image component react native
slideUpIcondefaultImageApply local icon image with require label
slideUpIconStyle{}ImageStyleApply all style props of Image component react native
submitButtonStyle{}ViewStyleSubmit Button icon container , Apply all style props of View component
submitButtonIcondefaultImageApply local icon image with require label
submitButtonIconStyle{}ImageStyleApply all style props of Image component
submitButtonTextStyle{}TextStyleApply all style props of Text component react native
mediaSelectIcondefaultImageApply all style props of Image component
mediaSelectIconStyle{}ImageStyleApply all style props of Image component react native


Methods & Others Props

PropDefaultTypeDescription
onBackPress{()=> }functionHandle close button control onPress
onSelect{()=> }functionreturn response after media selection
mediaPerPage10numbernumbers for images and videos render perpage by default
timerContainer{}ViewStyleView styles for timer component display during recording
timerTextStyle{}TextStyleapply TextStyle props for text in timer component
maxRecordDuration30numberpass record duration value i:e 30 is in seconds , you can set your duration according to your need
activeMediaType"Photo"stringDefault media type value when camera picker render for the first time , other one is "Video"
mediaTypeActiveButtonStyle{}ViewStyleApply all style props of View component for Active Media type switch button
mediaTypeButtonStyle{}ViewStyleApply all style props of View component for InActive Media type switch button
mediaTypeTextStyle{}TextStyleApply all style props of Text component for inactive media button label
mediaTypeActiveTextStyle{}TextStyleApply all style props of Text component for active media button label


Contributors

Pardeep Sharma