Git Product home page Git Product logo

react-native-camera-roll-picker's Introduction

version npm

react-native-camera-roll-picker

CameraRoll Picker component for React native

Requires react-native >=0.43.0

Add to Project

  • Install component through npm
$ npm install react-native-camera-roll-picker --save
  • Install CameraRoll from @react-native-community
$ npm install @react-native-community/cameraroll
  • Require component
import CameraRollPicker from 'react-native-camera-roll-picker';

Basic Usage

<CameraRollPicker
  callback={this.getSelectedImages} />

Props

  • callback : Callback function when images was selected. (is required!). Return a selected image array and current selected image.
  • initialNumToRender : Specifies how many rows we want to render on our first render pass. (Default: 5)
  • groupTypes : The group where the photos will be fetched, one of 'Album', 'All', 'Event', 'Faces', 'Library', 'PhotoStream' and 'SavedPhotos'. (Default: SavedPhotos)
  • assetType : The asset type, one of 'Photos', 'Videos' or 'All'. (Default: Photos)
  • selected : Already be selected images array. (Default: [])
  • selectSingleItem : Boolean to select only one single image at time. (Default: false)
  • maximum : Maximum number of selected images. (Default: 15)
  • imagesPerRow : Number of images per row. (Default: 3)
  • imageMargin : Margin size of one image. (Default: 5)
  • containerWidth : Width of camer roll picker container. (Default: device width)
  • selectedMarker : Custom selected image marker component. (Default: checkmark).
  • backgroundColor : Set background color. (Default: white).
  • emptyText: Text to display instead of a list when there are no photos found. (Default: 'No photos.')
  • emptyTextStyle: Styles to apply to the emptyText. (Default: textAlign: 'center')
  • loader: Loader component node. (Default: <ActivityIndicator />)

Run Example

$ git clone https://github.com/jeanpan/react-native-camera-roll-picker.git
$ cd react-native-camera-roll-picker
$ cd Example
$ npm install
$ react-native run-ios

react-native-camera-roll-picker's People

Contributors

andrew avatar brouding avatar cooperka avatar dcmdestello avatar designorant avatar faridsafi avatar haroenv avatar i6mi6 avatar jeanpan avatar juliusbuckley avatar kesha-antonov avatar lfoliveir4 avatar luco avatar madyankin avatar mayaa6 avatar sibelius avatar st0ffern avatar superandrew213 avatar timzaak avatar vaukalak avatar wootwoot1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-camera-roll-picker's Issues

performance issue and order

Hi, it seems the component loading slow when there are many photos in the camera roll. Anyone has encountered this and any solution?

Also, is there a way to set the ordering of the photos? I'd like the latest taken photos to be on the top.

Thanks

shown deleted files

I made app that capture camera images and store them into devices at users prompts. After capturing user could delete captured image (I do it with RNFS unlink). But when I reopen camera roll - deleted blank image still present here. I think there some kind problem with cache and each file need to be checked with RNFS.exists before show it thumbnail in the picker.

Camera Roll Empty - No Photos

I already declared camera usage on info.plist:

<key>NSPhotoLibraryUsageDescription</key>
  <string>This app requires access to the photo library.</string>
  <key>NSMicrophoneUsageDescription</key>
  <string>This app does not require access to the microphone.</string>
  <key>NSCameraUsageDescription</key>
  <string>This app requires access to the camera.</string>

And this is in my view:

<CameraRollPicker
            maximum={10}
            imagesPerRow={4}
            callback={this.selectImages}
            selected={[]}
          />

And I still getting No photos.
Any tips?

Callback Prop

the call back only returns selected images, what if an image is deselected how do i call a function?

Listview cannot show thumbnail when there are many items in the listview

There are a lot of photos in my android device. The library camera-roll-picker is so nice and i use it in my app. However, after i scroll down the listview for a few times, the image thumbnails cannot be shown (just see grey grids). May i ask if this issue is related to memory issue of listview? Is there any solution or flatlist version?

Thank you very much for your advice

Android cannot show any video files

In Android, the camera-roll-picker cannot show any video for selecting, no matter i am using All or Videos assetType. Any ideas?

Thanks a lot

Warning - Using <Image> with children is deprecated

I'm getting a warning message when selecting images from the camera roll.

Here is the code:

import { View, ScrollView } from 'react-native';
import CameraRollPicker from 'react-native-camera-roll-picker';

class MyPhotos extends React.Component {

  constructor(props) {
    super(props);

    this.state = {
      photos: [],
    };

    this.getSelectedImages = this.getSelectedImages.bind(this);
  }

  getSelectedImages(images, current) {
    this.setState({
      photos: images,
    });
  }

  render() {
    return (
      <View>
        <ScrollView>
          <CameraRollPicker callback={this.getSelectedImages} />
        </ScrollView>
      </View>
    );
  }
}

export default ActivationPhotos;

The exact warning message is:
Using <Image> with children is deprecated and will be an error in the near future. Please reconsider the layout or use <ImageBackground> instead.

I'm using:

react-native: 0.46.1
react: 16.0.0-alpha.12
react-native-camera-roll-picker: 1.2.2

Any idea on how to fix this?

EXC_BAD_INSTRUCTION on iOS when tapping a photo

The library was working perfectly and is suddenly crashing the application when I tap one of the images. No JS error is given when I run the application in Debug Mode, just this error on XCode:

screen shot 2017-08-30 at 9 09 35 am

So far I tried unlinking and uninstalling, and then reinstalling and relinking, but no luck.

I'm using the latest stable release of React Native, 0.47.2, and the latest release of this library, 1.2.0

Photo selection lag

When I tap on a photo, there is a lag until it renders as selected.
If I scroll down and the list grows, the lag grows with it.

Video example available here: https://cl.ly/muq8
As you can see there's a slight lag at start, and after scroll an even larger lag.

any idea?

undefined is not an object (evaluating 'RCTCameraRollManager.getPhotos)

hello
I try to get cameraroll and get this error on iphone 5s.

in xcode, libraries , I added RCTCameraRoll.xocde.proj
then in "build phases" link binary with libraries i dropped the "libRCTCameraRoll.a"

the project build is ok but error on the iphone

undefined is not an object (evaluating 'RCTCameraRollManager.getPhotos)

I used the code in the demo

Any idea please ?

her a screenshot of xcode
http://imgur.com/a/LQl8n

suggestions

Hello, great component!
I am using it in a project and I suggest the following features:

  • loading indicator
  • custom circle-check image

I will try to prepare a pull request

Element type is Invalid Error

Hiii,
Iam using this module and i got the error i am attaching the screenshot here
simulator screen shot 12-aug-2016 4 54 06 pm

anyone knows the solutions please reply back.
Thanks..

video marker

@jeanpan Can we add a video marker to indicate it's a video? Right now it just blends into the photos. Maybe another prop to accept a video marker?

My app drops when rendering CameraRollPicker

My app drops when rendering CameraRollPicker.
Show my code below. Is something wrong?

"react": "15.4.1",
"react-native": "0.39.2",
"react-native-camera-roll-picker": "^1.1.9"
import React, { Component } from 'react'
import CameraRollPicker from 'react-native-camera-roll-picker'

class CameraRollView extends Component {
  constructor(props) {
    super(props)
    this.state = { images: [] }
  }

  render() {
    return (
      <CameraRollPicker
        selected={this.state.images}
        callback={(images) => this.setState({ images })}
      />
    )
  }
}

android filename

I ask, when I choose photographs, only ios can crawl to filename, android not capture filename. There are ways to solve?

Crash

The next crash is happened to me when add

selected={this.state.imagesSelected}

CRASH:

Unhandled JS Exception: TypeError: array.map is not a function. (In 'array.map(function (o) {
        return o[property];
      })', 'array.map' is undefined)


_arrayObjectIndexOf(array, property, value) {
    return array.map((o) => { return o[property]; }).indexOf(value);
  }

example:

 getSelectedImages(images: any, current: any) {
    this.setState({ imagesSelected: current });
  }

 <CameraRollPicker
          style={{ flex: 1 }}
          groupTypes='All'
          batchSize={5}
          assetType={'Photos'}
          selected={this.state.imagesSelected} => Here crash it does not happen when I do not put this prop
          selectedMarker={<Image style={styles.containerMarker} source={Images.approveCheck} />}
          callback={this.getSelectedImages}
        />
Environment:
  OS: macOS Sierra 10.12.6
  Node: 8.9.1
  Yarn: 1.3.2
  npm: 5.5.1
  Watchman: 4.7.0
  Xcode: Xcode 8.3.2 Build version 8E2002
  Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
  react: 16.0.0 => 16.0.0
  react-native: 0.51.0 => 0.51.0

camera-roll-picker does not re-render after state change

issue_camera_picker

After changing value of All to Albums, camera roll picker does not re-render. It only renders one time when component mount and take the value for groupTypes which was provided to it. And when I change the value in state and provide that new value to groupTypes it does not re-render.

Permission Error on Android

Hello, I get this error on android and I can't find a way to set these permissions, any idea?

Error: Could not get photos: need READ_EXTERNAL_STORAGE permission

Latest commits?

@jeanpan

Batchsize:
Why use batchSize, it makes no sense?

Retriving 5 images or 4000 images in a fetch has a difference of 93 ns.
With SGListView it will only render items that are in the view and flush them again if they are out of bounds.

Facebook use batchSize because they render all the items in the list at load, and rendering 4000 at once will require batchSize

Example:
Why add Android, and IOS folders to the repo?
I cleaned them out as a exampe only need to have the components explaning the usage. not full repo of a React Native application.?
Just put it all into the .gitignore

GIFs not animating when importing uri

I'm trying to display images and gifs in my app on React Native's default Image component, but the uri's from the gifs selected using this library display a static unanimated image rather than the animated gif on the Image component. When I test out the component with a web url of a gif, it animates fine, so it appears to be an issue with how the uri from the camera roll picker

How to link manually in Xcode

Hello. I'm newbie for iOS and XCode.
I don't find .xcodeproj in this package (node_modules\react-native-camera-roll-picker)
and RCTCameraRoll.xcodeproj is showed in red color (in Libraries)
what I need to do?
screenshot1

Doesn't show any video file

On my Android Galaxy S6, it does not show video files.

The settings should be fine:

                    scrollRenderAheadDistance={500}
                    initialListSize={1}
                    pageSize={3}
                    removeClippedSubviews={true}
                    groupTypes='All'
                    batchSize={5}
                    maximum={10}
                    selected={this.state.selected}
                    assetType='All'
                    imagesPerRow={3}
                    imageMargin={5}
                    callback={this.getSelectedImages.bind(this)}

Custom empty list view

I find it more useful to allow a custom view to be injected into the component when the camera roll list is empty instead of just showing text (albeit, styled text).

Something like this:

<CameraRollPicker emptyState={(<MyCustomEmptyStateComponent />)}>

Thoughts?

can not shown Videos but photos shown

i dont know why videos is not showing [Android] CameraRoll does not support videos. This is my code
<CameraRollPicker
maximum={10}
assetType={'All'}
pageSize={2}
removeClippedSubviews={true}
imagesPerRow={3}
callback={this.selectImages}
selected={[]}
>

Image keep selected after reopen the screen

I checked the component, it very nice.

I opened the screen and select images, then go back. When reopen the screen again the selected marker still available on image.

I want to clear the selected from the previous opened.
Here is my segment of codes.

<CameraRollPicker callback={this._getSelectedImages.bind(this)} removeClippedSubViews={true} assetType={'Photos'} backgroundColor={'#f6f8f9'} selectedMarker={ <View style={styles.selectedPicker}> <Image style={styles.pickerIcon} source={require('../assets/icons/ic-image-picker-checked.png')} /> </View> } maximum={10}/>

How can I clear it? Thanks for your help.

Interest in a PR with a FlatList reimplementation?

Hi there!

Currently this component is implemented with a ListView which was deprecated a few months ago in favor of FlatLists which are supposed to have better performance and an easier API.

I have already a working implementation of the camera-roll-picker using a FlatList, would you be interested in me submitting a PR with that reimplementation?

The main consequences of this change are:

Dependencies:

  • Requires react-native 0.43.0 or superior.

Props:

  • scrollRenderAheadDistance disappears.
  • pageSize disappears.
  • removeClippedSubviews disappears.
  • initialListSize is renamed to initialNumToRender. (In the same way as currently, it refers to the initial number of rows, not images.)

Cheers.

How can I get file type?

Hello there!

How can I get file type? For example "image/png"
I am using react-native-aws3 and I need pass type prop there

Thanks for any help.

How to get the URI of the actual image for upload ?

Hello gents!

I'm having issues understanding how to get the actual path of the files so I can upload them ?
The array of images sent back from the picker is as follows:

data: {
    filename: "IMG_0005.JPG",
    height: 2002,
    isStored: true,
    playableDuration: 0,
    uri:"assets-library://asset/asset.JPG?id=ED7AC36B-A150-4C38-BB8C-B6D696F4F2ED&ext=JPG",
    width: 3000
}

I understand I need to use "data.filename" .. but what's the absolute path ? Where or how to get it from ? Thanks!

is there a way to preselect items?

Hi, after selecting some images, I would like to preserve the state so when I go back to it they're already selected. Is there a way to do that currently?

Thanks!

With assetType="Videos", Video thumbnails are not showing.

I want to load all the videos of my gallery. I set the assetType="Videos". Then the video thumbnails are not showing. But when i tap on empty screen, something gets selected and in console log I can see the video path (uri: "content://media/external/video/media/31929"). How to fix this problem, so I can see thumbnails of videos.

No geotag info in images

Thank you for the great library!

It looks like in this line the rest of the node information is lost, specifically the geotag information that our project needs. Would you consider passing along the entire node instead of just the width and height information of the image? I am willing to create a PR for this if needed.

var image = item.node.image;

Used this library to showcase my library

Hi!
I used this library to showcase my library react-native-photos-framework.Your code from this library is used in my example-folder. I have only changed your example to use my library instead of RN's CameraRoll.

But I saw now that you did not have any LICENSE in your repo. Let me know if you want me to delete your code from my repo!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.