拾取前如何首先查看图像(本机)?

时间:2019-06-24 17:39:01

标签: react-native react-native-image-picker

我正在使用react-native-image-picker,在这里尝试拾取图像,效果很好。

但是我的期望是:

我想先看到然后再拾取图像,就像Whatsapp,viber或IMO一样。

为什么?

由于某人需要将图像发送给他/她的朋友,他/她将首先要查看,无论他/她是否要发送图像。

当前,如果我触摸图像,则会立即将其拾取或发送。

我当前的代码:

const options = {
   noData: true,
   quality: 0.5,
   maxWidth: 2100,
   maxHeight: 2100
};

ImagePicker.launchCamera(options, async (response) => {

 try {

   const uri = response.path;
   const id = idGenerator();

   if (uri !== undefined) {

      const dir = `${FileSystem.ExternalStorageDirectoryPath}/MyAppImages/`;
       if (!(await FileSystem.exists(dir))) {
          await FileSystem.mkdir(dir);
       }

       const path = `${dir}/${id}.jpg`;
       await FileSystem.moveFile(uri, path);

       FileSystem.unlink(uri).catch(e=>{});

       props.sendImage(id, path, bytesToSize(response.fileSize));
       props.toglMdl();
   }

  } catch (e) {
    alert(JSON.stringify(e))
  }

});

0 个答案:

没有答案