Skip to content

Commit d6788b8

Browse files
authored
Merge pull request #2582 from GetStream/PBE-5070-rn-image-picker
fix: change react-native-image-crop-picker to react-native-image-picker and made it optional
2 parents b6039f3 + 4f8dbad commit d6788b8

File tree

52 files changed

+640
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+640
-416
lines changed

docusaurus/docs/reactnative/basics/installation.mdx

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ Stream Chat React Native SDK requires installing some peer dependencies to provi
5656
<TabItem value='rncli'>
5757

5858
```bash title="Terminal"
59-
yarn add @react-native-camera-roll/camera-roll @react-native-community/netinfo react-native-gesture-handler react-native-image-crop-picker @bam.tech/react-native-image-resizer react-native-reanimated react-native-svg
59+
yarn add @react-native-camera-roll/camera-roll @react-native-community/netinfo react-native-gesture-handler @bam.tech/react-native-image-resizer react-native-reanimated react-native-svg
6060
```
6161

6262
</TabItem>
6363

6464
<TabItem value='expo'>
6565

6666
```bash title="Terminal"
67-
npx expo install @react-native-community/netinfo expo-image-manipulator expo-image-picker expo-media-library react-native-gesture-handler react-native-reanimated react-native-svg
67+
npx expo install @react-native-community/netinfo expo-image-manipulator expo-media-library react-native-gesture-handler react-native-reanimated react-native-svg
6868
```
6969

7070
</TabItem>
@@ -85,7 +85,6 @@ values={[
8585
- [`@react-native-camera-roll/camera-roll`](https://github.com/react-native-cameraroll/react-native-cameraroll) for accessing device gallery.
8686
- [`@react-native-community/netinfo`](https://github.com/react-native-netinfo/react-native-netinfo) for SDK to respond to network changes.
8787
- [`react-native-gesture-handler`](https://github.com/software-mansion/react-native-gesture-handler) to handle gestures within the SDK.
88-
- [`react-native-image-crop-picker`](https://github.com/ivpusic/react-native-image-crop-picker) to capture images to attach them in the message.
8988
- [`@bam.tech/react-native-image-resizer`](https://github.com/bamlab/react-native-image-resizer) to compress image uploads.
9089
- [`react-native-reanimated`](https://github.com/software-mansion/react-native-reanimated) to compress image uploads.
9190
- [`react-native-svg`](https://github.com/react-native-svg/react-native-svg) for SVG support.
@@ -96,7 +95,6 @@ values={[
9695
- [`expo-media-library`](https://docs.expo.dev/versions/latest/sdk/media-library/) for accessing device gallery.
9796
- [`@react-native-community/netinfo`](https://github.com/react-native-netinfo/react-native-netinfo) for SDK to respond to network changes.
9897
- [`react-native-gesture-handler`](https://github.com/software-mansion/react-native-gesture-handler) to handle gestures within the SDK.
99-
- [`expo-image-picker`](https://docs.expo.dev/versions/latest/sdk/imagepicker/) to capture images to attach them in the message.
10098
- [`expo-image-manipulator`](https://docs.expo.dev/versions/latest/sdk/imagemanipulator/) to compress image uploads.
10199
- [`react-native-reanimated`](https://github.com/software-mansion/react-native-reanimated) to compress image uploads.
102100
- [`react-native-svg`](https://docs.expo.dev/versions/latest/sdk/svg/) for SVG support.
@@ -282,6 +280,36 @@ npx expo install expo-document-picker
282280

283281
</Tabs>
284282

283+
### Capture image and upload attachment
284+
285+
Capture images from the camera and upload them as attachments in the chat.
286+
287+
<Tabs
288+
defaultValue='rncli'
289+
groupId='rn-platform'
290+
values={[
291+
{ label: 'RN CLI', value: 'rncli' },
292+
{ label: 'Expo', value: 'expo' },
293+
]}
294+
>
295+
<TabItem value='rncli'>
296+
297+
```bash title="Terminal"
298+
yarn add react-native-image-picker
299+
```
300+
301+
</TabItem>
302+
303+
<TabItem value='expo'>
304+
305+
```bash title="Terminal"
306+
npx expo install expo-image-picker
307+
```
308+
309+
</TabItem>
310+
311+
</Tabs>
312+
285313
### Offline support
286314

287315
Enable offline support in the app.
@@ -330,6 +358,7 @@ values={[
330358
- [`react-native-haptic-feedback`](https://github.com/junina-de/react-native-haptic-feedback) for user haptics feedback.
331359
- [`@react-native-clipboard/clipboard`](https://github.com/react-native-clipboard/clipboard) for Copy message support.
332360
- [`react-native-document-picker`](https://github.com/rnmods/react-native-document-picker) to access device media files.
361+
- [`react-native-image-picker`](https://github.com/react-native-image-picker/react-native-image-picker) to capture images to attach them in the message.
333362
- [`@op-engineering/op-sqlite`](https://github.com/OP-Engineering/op-sqlite) to enable Offline support in the app.
334363

335364
</TabItem>
@@ -341,6 +370,7 @@ values={[
341370
- [`expo-haptics`](https://docs.expo.dev/versions/latest/sdk/haptics/) for user haptics support.
342371
- [`expo-clipboard`](https://docs.expo.dev/versions/latest/sdk/clipboard/) for Copy message support.
343372
- [`expo-document-picker`](https://docs.expo.dev/versions/latest/sdk/document-picker/) to access device media files.
373+
- [`expo-image-picker`](https://docs.expo.dev/versions/latest/sdk/imagepicker/) to capture images to attach them in the message.
344374
- [`@op-engineering/op-sqlite`](https://github.com/OP-Engineering/op-sqlite) to enable Offline support in the app.
345375

346376
</TabItem>
@@ -365,7 +395,7 @@ values={[
365395
<TabItem value='rncli'>
366396

367397
- [`@react-native-camera-roll/camera-roll`](https://github.com/react-native-cameraroll/react-native-cameraroll?tab=readme-ov-file#permissions) for gallery/photo library access.
368-
- [`react-native-image-crop-picker`](https://github.com/ivpusic/react-native-image-crop-picker?tab=readme-ov-file#step-3) for camera access.
398+
- [`react-native-image-picker`](https://github.com/react-native-image-picker/react-native-image-picker?tab=readme-ov-file#post-install-steps) for camera access.
369399
- [`react-native-audio-recorder-player`](https://github.com/hyochan/react-native-audio-recorder-player?tab=readme-ov-file#post-installation) for microphone access for voice recording.
370400

371401
An example `AndroidManifest.xml` would look like this with permissions:
@@ -477,7 +507,7 @@ The entry point of your app exists usually either in `index.js` or `App.tsx` fil
477507
Please also follow the steps mentioned in the links below for corresponding dependencies:
478508

479509
- `react-native` - [additional installation steps](https://reactnative.dev/docs/image#gif-and-webp-support-on-android)
480-
- `react-native-image-crop-picker` - [additional installation steps](https://github.com/ivpusic/react-native-image-crop-picker#step-3)
510+
- `react-native-image-picker` - [additional installation steps](https://github.com/react-native-image-picker/react-native-image-picker?tab=readme-ov-file#post-install-steps)
481511
- `react-native-cameraroll` - [additional installation steps](https://github.com/react-native-cameraroll/react-native-cameraroll#permissions)
482512

483513
Now you should be able to run the app on simulator by running following command:

docusaurus/docs/reactnative/basics/migrating-from-5.x-to-6.x.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ yarn remove react-native-image-resizer
3333
yarn add @bam.tech/react-native-image-resizer
3434
```
3535

36+
### Change `react-native-image-crop-picker` to `react-native-image-picker`
37+
38+
The `react-native-image-crop-picker` package has been replaced with `react-native-image-picker`. This is a better alternative, and can help us with our new architecture endeavors.
39+
40+
You can replace it by running the following commands:
41+
42+
```bash
43+
yarn remove react-native-image-crop-picker
44+
yarn add react-native-image-picker
45+
```
46+
47+
Also, the dependency is made optional now, so if you don't want to use the image picker, you can remove it from your project and the camera selector icon on the Attachment picker will be simply hidden for you.
48+
3649
### Change `react-native-quick-sqlite` to `op-sqlite`
3750

3851
The `react-native-quick-sqlite` package has been replaced with `op-sqlite`. This is a faster alternative, and can help us with our new architecture endeavors.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Enable the file picker on the [`MessageInput`](../../../../ui-components/message-input.mdx) component.
2+
3+
| Type | Default |
4+
| ------- | ------- |
5+
| Boolean | `true` |

docusaurus/docs/reactnative/common-content/ui-components/channel/props/has_file_picker.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Enable the file picker on the [`MessageInput`](../../../../ui-components/message
22

33
| Type | Default |
44
| ------- | ------- |
5-
| boolean | true |
5+
| Boolean | `true` |

docusaurus/docs/reactnative/common-content/ui-components/channel/props/has_image_picker.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Enable the image picker on the [`MessageInput`](../../../../ui-components/messag
22

33
| Type | Default |
44
| ------- | ------- |
5-
| boolean | true |
5+
| Boolean | `true` |

docusaurus/docs/reactnative/contexts/message-input-context.mdx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import DoDocUploadRequest from '../common-content/ui-components/channel/props/do
2626
import DoImageUploadRequest from '../common-content/ui-components/channel/props/do_image_upload_request.mdx';
2727
import EmojiSearchIndex from '../common-content/ui-components/channel/props/emoji_search_index.mdx';
2828
import FileUploadPreview from '../common-content/ui-components/channel/props/file_upload_preview.mdx';
29+
import HasCameraPicker from '../common-content/ui-components/channel/props/has_camera_picker.mdx';
2930
import HasCommands from '../common-content/ui-components/channel/props/has_commands.mdx';
3031
import HasFilePicker from '../common-content/ui-components/channel/props/has_file_picker.mdx';
3132
import HasImagePicker from '../common-content/ui-components/channel/props/has_image_picker.mdx';
@@ -182,15 +183,19 @@ const { sendMessage, toggleAttachmentPicker } = useMessageInputContext();
182183

183184
<EmojiSearchIndex />
184185

186+
### <div class="label description">_forwarded from [Channel](../../core-components/channel#hascamerapicker)_ props</div> `hasCameraPicker` {#hascamerapicker}
187+
188+
<HasCameraPicker />
189+
185190
### <div class="label description">_forwarded from [Channel](../../core-components/channel#hascommands)_ props</div> `hasCommands` {#hascommands}
186191

187192
<HasCommands />
188193

189-
### <div class="label description">_forwarded from [Channel](../../core-components/channel#hasfilepicker)_ props</div> hasFilePicker {#hasfilepicker}
194+
### <div class="label description">_forwarded from [Channel](../../core-components/channel#hasfilepicker)_ props</div> `hasFilePicker` {#hasfilepicker}
190195

191196
<HasFilePicker />
192197

193-
### <div class="label description">_forwarded from [Channel](../../core-components/channel#hasimagepicker)_ props</div> hasImagePicker {#hasimagepicker}
198+
### <div class="label description">_forwarded from [Channel](../../core-components/channel#hasimagepicker)_ props</div> `hasImagePicker` {#hasimagepicker}
194199

195200
<HasImagePicker />
196201

docusaurus/docs/reactnative/core-components/channel.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import HandleQuotedReply from '../common-content/ui-components/channel/props/han
7474
import HandleReaction from '../common-content/ui-components/channel/props/handle_reaction.mdx';
7575
import HandleRetry from '../common-content/ui-components/channel/props/handle_retry.mdx';
7676
import HandleThreadReply from '../common-content/ui-components/channel/props/handle_thread_reply.mdx';
77+
import HasCameraPicker from '../common-content/ui-components/channel/props/has_camera_picker.mdx';
7778
import HasCommands from '../common-content/ui-components/channel/props/has_commands.mdx';
7879
import HasFilePicker from '../common-content/ui-components/channel/props/has_file_picker.mdx';
7980
import HasImagePicker from '../common-content/ui-components/channel/props/has_image_picker.mdx';
@@ -524,6 +525,10 @@ The max allowable is 255, which when reached displays as `255+`.
524525

525526
<HandleThreadReply />
526527

528+
### `hasCameraPicker`
529+
530+
<HasCameraPicker />
531+
527532
### `hasCommands`
528533

529534
<HasCommands />

docusaurus/docs/reactnative/customization/native-handlers.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ A function to provide a given image to the native sharing functionality of the O
122122

123123
A function that opens the OS specific camera and returns an image when one is taken.
124124

125-
| React Native CLI | Expo |
126-
| --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
127-
| [`react-native-image-crop-picker`](https://github.com/ivpusic/react-native-image-crop-picker) | [`expo-image-picker`](https://docs.expo.io/versions/latest/sdk/imagepicker/) |
125+
| React Native CLI | Expo |
126+
| ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
127+
| [`react-native-image-picker`](https://github.com/react-native-image-picker/react-native-image-picker) | [`expo-image-picker`](https://docs.expo.io/versions/latest/sdk/imagepicker/) |
128128

129129
### `triggerHaptic`
130130

docusaurus/docs/reactnative/guides/custom-message-input.mdx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ const CustomAttachButton = () => {
418418
```
419419

420420
Now let's hook the relevant action handlers for buttons within ActionSheet.
421-
[`react-native-image-crop-picker`](https://github.com/ivpusic/react-native-image-crop-picker) provides an image picker functionality
422-
with good support for configurable compression, multiple images and cropping. And selected images from image picker or camera can be wired in
421+
[`react-native-image-picker`](https://github.com/react-native-image-picker/react-native-image-picker) provides an image picker functionality
422+
with good support for multiple images. And selected images from image picker or camera can be wired in
423423
with upload previews ([`ImageUploadPreview`](../ui-components/image-upload-preview.mdx)) within `MessageInput` component
424424
by using a function `uploadNewImage` provided by [`MessageInputContext`](../../contexts/message-input-context#uploadnewimage).
425425

@@ -429,15 +429,15 @@ provided by the [`MessageInputContext`](../../contexts/message-input-context#pic
429429
```tsx {4,10,12-21,23-30,43,46,49}
430430
import { AttachButton, Channel, useMessageInputContext } from 'stream-chat-react-native';
431431
import { ActionSheetProvider, useActionSheet } from '@expo/react-native-action-sheet';
432-
import ImagePicker from 'react-native-image-crop-picker';
432+
import ImagePicker from 'react-native-image-picker';
433433

434434
const CustomAttachButton = () => {
435435
const { showActionSheetWithOptions } = useActionSheet();
436436
const { pickFile, uploadNewImage } = useMessageInputContext();
437437

438438
const pickImageFromGallery = () =>
439-
ImagePicker.openPicker({
440-
multiple: true,
439+
ImagePicker.launchImageLibrary({
440+
selectionLimit: 0,
441441
}).then(images =>
442442
images.forEach(image =>
443443
uploadNewImage({
@@ -447,9 +447,7 @@ const CustomAttachButton = () => {
447447
);
448448

449449
const pickImageFromCamera = () =>
450-
ImagePicker.openCamera({
451-
cropping: true,
452-
}).then(image =>
450+
ImagePicker.launchCamera({}).then(image =>
453451
uploadNewImage({
454452
uri: image.path,
455453
}),

examples/ExpoMessaging/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"expo-file-system": "~17.0.1",
2323
"expo-haptics": "~13.0.1",
2424
"expo-image-manipulator": "~12.0.5",
25-
"expo-image-picker": "~15.0.6",
25+
"expo-image-picker": "~15.0.7",
2626
"expo-linking": "~6.3.1",
2727
"expo-media-library": "~16.0.4",
2828
"expo-router": "~3.5.17",
@@ -31,7 +31,7 @@
3131
"expo-status-bar": "~1.12.1",
3232
"react": "18.2.0",
3333
"react-dom": "18.2.0",
34-
"react-native": "0.74.2",
34+
"react-native": "0.74.3",
3535
"react-native-gesture-handler": "~2.16.1",
3636
"react-native-reanimated": "~3.10.1",
3737
"react-native-safe-area-context": "4.10.1",

0 commit comments

Comments
 (0)