react-native-image-picker / react-native-image-picker

:sunrise_over_mountains: A React Native module that allows you to use native UI to select media from the device library or directly from the camera.
MIT License
8.44k stars 2.08k forks source link

Package Review #1358

Closed Johan-dutoit closed 3 years ago

Johan-dutoit commented 4 years ago

There's been a fair amount of issues regarding the permissions with this package and it's been painful to keep up with (especially with a mostly unfamiliar codebase to me).

My plan is as follows and I'd like to get opinions before proceeding

It's a big ask now but the package has been stale for too long. the alternative is to completely drop this package in favour of expo-image-picker.

Suggestions welcome

angimenez commented 4 years ago

I like your plan 👍

HansBouwmeester commented 4 years ago

Leaving it to the user to sort out permissions is the way to go! There's lots of packages providing assistance, e.g. react-native-permissions.

Would be a real shame seeing this package be dropped just because the permissions jungle is getting in the way!

tsiory commented 4 years ago

I agreed with you.

macavity23 commented 4 years ago

Also agree 100%. Permissions is a thing almost every serious app is going to deal with so it might as well be handled properly by react-native-permissions - this is a community project now so I think it's safe to depend on it & link to it.

Johan-dutoit commented 4 years ago

I started a fresh package a while ago that will eventually replace this (haven't committed it yet) that has the following opinions (created using react-native-community/bob:

That being said, I don't have the time to fully commit to this now. If you are keen to assist, please reach out.

ravirajn22 commented 4 years ago

@Johan-dutoit appreciate your effort. But trying to completely rewrite the library will take huge effort and has high percentage of failure to complete.

I have the following recommendation,

I and many others are ready to contribute if there is guarantee that the pull request will be reviewed, merged to master or rejected in quick time. It should not be left stale.

I am keen to assist, how do we move forward?

Johan-dutoit commented 4 years ago

@ravirajn22 some good points brought up.

I created a new branch for you (and whoever wants to help), called vnext.

PR's into this branch will be reviewed and merge if all looks good.

douglasjunior commented 4 years ago

About expo-image-picker, I don't think that is a good idea for bare React Native projects, because it require react-native-unimodules.

ravirajn22 commented 4 years ago

@Johan-dutoit I suggest we remove ImagePicker.showImagePicker, people if they want can show menu of their choice like using ActionSheetIOS from react-native or simple buttons etc. It's a burden for this library. Community your thoughts?

Johan-dutoit commented 4 years ago

@ravirajn22 Totally agree.

Especially with trying to support all the theming of the action sheet.

Having the following two functions would suffice:

As a nice to have, I'll add an example to the example project that uses react-native-action-sheet.

Let's do this on the vnext branch.

tastafur commented 4 years ago

Other suggestions to improve @Johan-dutoit , the use of the camera when it is in video mode, the only data we give is the video file but it would also be necessary to know the format, the video quality, resolution and more parameters

Johan-dutoit commented 3 years ago

For those interested @ravirajn22 has done a ton of work related to this (which is highly appreciated). These changes live on the vnext branch.

Testing and feedback is greatly welcomed!

Once sufficient feedback has been received (and testing of course), then we can promote to master and release an alpha on npm (to reach a wider audience).

Any issues against vnext should be tagged with the vnext label.

ravirajn22 commented 3 years ago

Also list here any master branch feature unavailable on vnext branch which is a deal breaker to upgrade. We will brainstorm and consider to add to vnext.

ravirajn22 commented 3 years ago

@Johan-dutoit there is no comments from users (I think no one has tried vnext branch). What shall we plan next? release a new major beta version using the vnext branch. We should maintain both branches parallel and release versions for sometime and update master docs to both releases.

ravirajn22 commented 3 years ago

@Johan-dutoit can you provide manage issue, write permission (for vnext branch) for me. So that I can push my changes and handle issues promptly. Any major API changes will obviously go through review process.

Also we can close this issue.

AronBe commented 3 years ago

Hi, what about adding a customButton to the vnext as that seems currently the way to allow users to have an option to upload an image alongside e.g. a pdf document through react-native-document-picker

ravirajn22 commented 3 years ago

@AronBe I don't get your feature request. What customButton?

AronBe commented 3 years ago

@ravirajn22 it is in the response object of ImagePicker, but based on vnext documentation, it is missing

ImagePicker.showImagePicker(options, (response) => {
  console.log('Response = ', response);

  if (response.didCancel) {
    console.log('User cancelled image picker');
  } else if (response.error) {
    console.log('ImagePicker Error: ', response.error);
  } else if (**response.customButton**) {
    console.log('User tapped custom button: ', response.customButton);
  } else {
    const source = { uri: response.uri };

    // You can also display the image using data:
    // const source = { uri: 'data:image/jpeg;base64,' + response.data };

    this.setState({
      avatarSource: source,
    });
  }
});
Johan-dutoit commented 3 years ago

@AronBe please create a new issue with as much detail as possible. It's off topic for this issue and won't easily be able to manage/track it in here.

Johan-dutoit commented 3 years ago

Closing this, as tons of progress has been made regarding this issue. Many thanks to everyone involved, especially @ravirajn22.