Skip to content

Commit d7152f9

Browse files
authored
feat: make cameraroll library optional (#2604)
* feat: make cameraroll library optional * feat: introduce native image picker if cameraroll is not available * fix: native package export
1 parent ecc77bd commit d7152f9

File tree

102 files changed

+1360
-632
lines changed

Some content is hidden

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

102 files changed

+1360
-632
lines changed

docusaurus/docs/reactnative/basics/installation.mdx

Lines changed: 6 additions & 5 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 @stream-io/flat-list-mvcp react-native-fs react-native-gesture-handler react-native-image-resizer react-native-reanimated react-native-svg
59+
yarn add @react-native-community/netinfo @stream-io/flat-list-mvcp react-native-fs react-native-gesture-handler 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 @stream-io/flat-list-mvcp @react-native-community/netinfo expo-file-system expo-image-manipulator expo-media-library react-native-gesture-handler react-native-reanimated react-native-svg
67+
npx expo install @stream-io/flat-list-mvcp @react-native-community/netinfo expo-file-system expo-image-manipulator react-native-gesture-handler react-native-reanimated react-native-svg
6868
```
6969

7070
</TabItem>
@@ -82,7 +82,6 @@ values={[
8282
>
8383
<TabItem value='rncli'>
8484

85-
- [`@react-native-camera-roll/camera-roll`](https://github.com/react-native-cameraroll/react-native-cameraroll) for accessing device gallery.
8685
- [`@react-native-community/netinfo`](https://github.com/react-native-netinfo/react-native-netinfo) for accessing device gallery.
8786
- [`@stream-io/flat-list-mvcp`](https://github.com/GetStream/flat-list-mvcp) for bi-directional FlatList support.
8887
- [`react-native-fs`](https://github.com/itinance/react-native-fs) to perform file operations like save, delete, etc.
@@ -94,7 +93,6 @@ values={[
9493
</TabItem>
9594
<TabItem value="expo">
9695

97-
- [`expo-media-library`](https://docs.expo.dev/versions/latest/sdk/media-library/) for accessing device gallery.
9896
- [`@react-native-community/netinfo`](https://github.com/react-native-netinfo/react-native-netinfo) for accessing device gallery.
9997
- [`@stream-io/flat-list-mvcp`](https://github.com/GetStream/flat-list-mvcp) for bi-directional FlatList support.
10098
- [`expo-file-system`](https://docs.expo.dev/versions/latest/sdk/filesystem/) to perform file operations like save, delete, etc.
@@ -124,6 +122,7 @@ values={[
124122
>
125123
<TabItem value='rncli'>
126124

125+
- [`@react-native-camera-roll/camera-roll`](https://github.com/react-native-cameraroll/react-native-cameraroll) for accessing device gallery.
127126
- [`react-native-image-crop-picker`](https://github.com/ivpusic/react-native-image-crop-picker) to capture images to attach them in the message.
128127
- [`react-native-video`](https://github.com/react-native-video/react-native-video) for Video and Audio playback support.
129128
- [`react-native-audio-recorder-player`](https://github.com/hyochan/react-native-audio-recorder-player) for Audio recording and async audio messages support.
@@ -132,11 +131,13 @@ values={[
132131
- [`@react-native-clipboard/clipboard`](https://github.com/react-native-clipboard/clipboard) for Copy message support.
133132
- [`react-native-document-picker`](https://github.com/rnmods/react-native-document-picker) to access device media files.
134133
- [`react-native-quick-sqlite`](https://github.com/margelo/react-native-quick-sqlite) to enable Offline support in the app.
134+
- [`react-native-image-picker`](https://github.com/react-native-image-picker/react-native-image-picker) to use native photo picker.
135135

136136
</TabItem>
137137
<TabItem value="expo">
138138

139139
- [`expo-av`](https://docs.expo.dev/versions/latest/sdk/av/) for Video and Audio playback, recording and async audio messages support.
140+
- [`expo-media-library`](https://docs.expo.dev/versions/latest/sdk/media-library/) for accessing device gallery.
140141
- [`expo-image-picker`](https://docs.expo.dev/versions/latest/sdk/imagepicker/) to capture images to attach them in the message.
141142
- [`expo-sharing`](https://docs.expo.dev/versions/latest/sdk/sharing/) for Attachments sharing support.
142143
- [`expo-haptics`](https://docs.expo.dev/versions/latest/sdk/haptics/) for user haptics support.
@@ -279,7 +280,7 @@ Please also follow the steps mentioned in the links below for corresponding depe
279280

280281
- `react-native` - [additional installation steps](https://reactnative.dev/docs/image#gif-and-webp-support-on-android)
281282
- `react-native-image-crop-picker` - [additional installation steps](https://github.com/ivpusic/react-native-image-crop-picker#step-3)
282-
- `react-native-cameraroll` - [additional installation steps](https://github.com/react-native-cameraroll/react-native-cameraroll#permissions)
283+
- `@react-native-camera-roll/camera-roll` - [additional installation steps](https://github.com/react-native-cameraroll/react-native-cameraroll#permissions)
283284

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

docusaurus/docs/reactnative/basics/overview.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ The SDK tries to keep the list of external dependencies to a minimum, these are
6060
>
6161
<TabItem value='rncli'>
6262

63-
- [`@react-native-camera-roll/camera-roll`](https://github.com/react-native-cameraroll/react-native-cameraroll) for accessing device gallery.
6463
- [`@react-native-community/netinfo`](https://github.com/react-native-netinfo/react-native-netinfo) for accessing device gallery.
6564
- [`@stream-io/flat-list-mvcp`](https://github.com/GetStream/flat-list-mvcp) for bi-directional FlatList support.
6665
- [`react-native-fs`](https://github.com/itinance/react-native-fs) to perform file operations like save, delete, etc.
@@ -74,7 +73,6 @@ The SDK tries to keep the list of external dependencies to a minimum, these are
7473
</TabItem>
7574
<TabItem value="expo">
7675

77-
- [`expo-media-library`](https://docs.expo.dev/versions/latest/sdk/media-library/) for accessing device gallery.
7876
- [`@react-native-community/netinfo`](https://github.com/react-native-netinfo/react-native-netinfo) for accessing device gallery.
7977
- [`@stream-io/flat-list-mvcp`](https://github.com/GetStream/flat-list-mvcp) for bi-directional FlatList support.
8078
- [`expo-file-system`](https://docs.expo.dev/versions/latest/sdk/filesystem/) to perform file operations like save, delete, etc.
@@ -102,18 +100,21 @@ There are a few optional dependencies that can be added by our users to have mor
102100
>
103101
<TabItem value='rncli'>
104102

103+
- [`@react-native-camera-roll/camera-roll`](https://github.com/react-native-cameraroll/react-native-cameraroll) for accessing device gallery.
105104
- [`react-native-video`](https://github.com/react-native-video/react-native-video) for Video and Audio playback support.
106105
- [`react-native-audio-recorder-player`](https://github.com/hyochan/react-native-audio-recorder-player) for Audio recording and async audio messages support.
107106
- [`react-native-share`](https://github.com/react-native-share/react-native-share) for Attachment sharing support.
108107
- [`react-native-haptic-feedback`](https://github.com/junina-de/react-native-haptic-feedback) for user haptics feedback.
109108
- [`@react-native-clipboard/clipboard`](https://github.com/react-native-clipboard/clipboard) for Copy message support.
110109
- [`react-native-document-picker`](https://github.com/rnmods/react-native-document-picker) to access device media files.
111110
- [`react-native-quick-sqlite`](https://github.com/margelo/react-native-quick-sqlite) to enable Offline support in the app.
111+
- [`react-native-image-picker`](https://github.com/react-native-image-picker/react-native-image-picker) to use native photo picker.
112112

113113
</TabItem>
114114
<TabItem value="expo">
115115

116116
- [`expo-av`](https://docs.expo.dev/versions/latest/sdk/av/) for Video and Audio playback, recording and async audio messages support.
117+
- [`expo-media-library`](https://docs.expo.dev/versions/latest/sdk/media-library/) for accessing device gallery.
117118
- [`expo-sharing`](https://docs.expo.dev/versions/latest/sdk/sharing/) for Attachments sharing support.
118119
- [`expo-haptics`](https://docs.expo.dev/versions/latest/sdk/haptics/) for user haptics support.
119120
- [`expo-clipboard`](https://docs.expo.dev/versions/latest/sdk/clipboard/) for Copy message support.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Function to customize the behaviour when the [AttachButton](../../../../ui-components/attach-button.mdx) is pressed in the message input.
2+
3+
| Type |
4+
| ------------ |
5+
| `() => void` |

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

Lines changed: 5 additions & 0 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 HandleAttachButtonPress from '../common-content/ui-components/channel/props/handle_attach_button_press.mdx';
2930
import HasCameraPicker from '../common-content/ui-components/channel/props/has_camera_picker.mdx';
3031
import HasCommands from '../common-content/ui-components/channel/props/has_commands.mdx';
3132
import HasFilePicker from '../common-content/ui-components/channel/props/has_file_picker.mdx';
@@ -183,6 +184,10 @@ const { sendMessage, toggleAttachmentPicker } = useMessageInputContext();
183184

184185
<EmojiSearchIndex />
185186

187+
### <div class="label description">_forwarded from [Channel](../../core-components/channel#handleattachbuttonpress)_ props</div> `handleAttachButtonPress` {#handleAttachButtonPress}
188+
189+
<HandleAttachButtonPress />
190+
186191
### <div class="label description">_forwarded from [Channel](../../core-components/channel#hascamerapicker)_ props</div> `hasCameraPicker` {#hascamerapicker}
187192

188193
<HasCameraPicker />

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import GetMessagesGroupStyles from '../common-content/ui-components/channel/prop
6363
import Giphy from '../common-content/ui-components/channel/props/giphy.mdx';
6464
import GiphyEnabled from '../common-content/ui-components/channel/props/giphy_enabled.mdx';
6565
import GiphyVersion from '../common-content/ui-components/channel/props/giphy_version.mdx';
66+
import HandleAttachButtonPress from '../common-content/ui-components/channel/props/handle_attach_button_press.mdx';
6667
import HandleBlock from '../common-content/ui-components/channel/props/handle_block.mdx';
6768
import HandleCopy from '../common-content/ui-components/channel/props/handle_copy.mdx';
6869
import HandleDelete from '../common-content/ui-components/channel/props/handle_delete.mdx';
@@ -481,6 +482,10 @@ The max allowable is 255, which when reached displays as `255+`.
481482

482483
<GiphyVersion />
483484

485+
### `handleAttachButtonPress`
486+
487+
<HandleAttachButtonPress />
488+
484489
### `handleBlock`
485490

486491
<HandleBlock />

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ A function to open the document picker and return documents picked from it.
102102
| ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
103103
| [`react-native-document-picker`](https://github.com/rnmods/react-native-document-picker) | [`expo-document-picker`](https://docs.expo.io/versions/latest/sdk/document-picker/) |
104104

105+
### `pickImage`
106+
107+
A function to open the native image picker and return images picked from it.
108+
109+
| React Native CLI | Expo |
110+
| ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
111+
| [`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/) |
112+
105113
### `saveFile`
106114

107115
A function to save a file from a URL to local storage.

examples/ExpoMessaging/app.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,9 @@
3131
"favicon": "./assets/favicon.png",
3232
"bundler": "metro"
3333
},
34-
"experiments": {
35-
"turboModules": true
36-
},
3734
"scheme": "ExpoMessaging",
3835
"plugins": [
3936
"expo-router",
40-
[
41-
"expo-media-library",
42-
{
43-
"photosPermission": "$(PRODUCT_NAME) would like access to your photo gallery to share image in a message.",
44-
"savePhotosPermission": "$(PRODUCT_NAME) would like to save photos to your photo gallery after downloading from a message."
45-
}
46-
],
4737
[
4838
"expo-image-picker",
4939
{

examples/ExpoMessaging/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"expo-image-manipulator": "~12.0.5",
2323
"expo-image-picker": "~15.0.5",
2424
"expo-linking": "~6.3.1",
25-
"expo-media-library": "~16.0.4",
2625
"expo-router": "~3.5.16",
2726
"expo-sharing": "~12.0.1",
2827
"expo-splash-screen": "~0.27.5",

examples/ExpoMessaging/yarn.lock

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3957,11 +3957,6 @@ expo-linking@~6.3.1:
39573957
expo-constants "~16.0.0"
39583958
invariant "^2.2.4"
39593959

3960-
expo-media-library@~16.0.4:
3961-
version "16.0.4"
3962-
resolved "https://registry.yarnpkg.com/expo-media-library/-/expo-media-library-16.0.4.tgz#d6b264a201861a2eb055b8c181368d2e7f525ca4"
3963-
integrity sha512-nX9iN8+XAoERDVGPpDdUbhFwvfYdBpkgTAxwDOYL7heASYCOdxfqQtXy/jv1+QZpj0epaR6Owq/LUn1lVP3ykg==
3964-
39653960
39663961
version "1.11.1"
39673962
resolved "https://registry.yarnpkg.com/expo-modules-autolinking/-/expo-modules-autolinking-1.11.1.tgz#4a867f727d9dfde07de8dde14b333a3cbf82ce3c"
@@ -7237,10 +7232,10 @@ [email protected], stream-buffers@~2.2.0:
72377232
version "0.0.0"
72387233
uid ""
72397234

7240-
7241-
version "5.33.0"
7242-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.33.0.tgz#14f04de90cbc8db011bab8db3fa84abe2dc2eaec"
7243-
integrity sha512-V9OJA9MrHzaCw5q16ZRbEktA1HamITbXPOkVZOjpDbb0OBcmedmOnD9C2NFIprc770lhllS/1MKBDr0GdQ9NXQ==
7235+
7236+
version "5.33.1"
7237+
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.33.1.tgz#d9e7847469d3ffb6e7fd35fbb7b720f2e25d172e"
7238+
integrity sha512-TCDmChJe07cYyL3sErc6qycRFMA+HbflCKRGrFvVvpU0RdWJljaqiOo3avFSauciSnQxx9WxzTkMism8YsFHcQ==
72447239
dependencies:
72457240
"@gorhom/bottom-sheet" "4.4.8"
72467241
dayjs "1.10.5"

examples/TypeScriptMessaging/ios/Podfile.lock

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -944,12 +944,14 @@ PODS:
944944
- React-Mapbuffer (0.73.6):
945945
- glog
946946
- React-debug
947-
- react-native-cameraroll (5.6.0):
948-
- React-Core
949947
- react-native-document-picker (9.0.1):
950948
- React-Core
951949
- react-native-flipper (0.212.0):
952950
- React-Core
951+
- react-native-image-picker (7.1.2):
952+
- glog
953+
- RCT-Folly (= 2022.05.16.00)
954+
- React-Core
953955
- react-native-image-resizer (1.4.5):
954956
- React-Core
955957
- react-native-netinfo (11.3.0):
@@ -1229,9 +1231,9 @@ DEPENDENCIES:
12291231
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector-modern`)
12301232
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
12311233
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
1232-
- "react-native-cameraroll (from `../node_modules/@react-native-camera-roll/camera-roll`)"
12331234
- react-native-document-picker (from `../node_modules/react-native-document-picker`)
12341235
- react-native-flipper (from `../node_modules/react-native-flipper`)
1236+
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
12351237
- react-native-image-resizer (from `../node_modules/react-native-image-resizer`)
12361238
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
12371239
- react-native-quick-sqlite (from `../node_modules/react-native-quick-sqlite`)
@@ -1343,12 +1345,12 @@ EXTERNAL SOURCES:
13431345
:path: "../node_modules/react-native/ReactCommon/logger"
13441346
React-Mapbuffer:
13451347
:path: "../node_modules/react-native/ReactCommon"
1346-
react-native-cameraroll:
1347-
:path: "../node_modules/@react-native-camera-roll/camera-roll"
13481348
react-native-document-picker:
13491349
:path: "../node_modules/react-native-document-picker"
13501350
react-native-flipper:
13511351
:path: "../node_modules/react-native-flipper"
1352+
react-native-image-picker:
1353+
:path: "../node_modules/react-native-image-picker"
13521354
react-native-image-resizer:
13531355
:path: "../node_modules/react-native-image-resizer"
13541356
react-native-netinfo:
@@ -1464,9 +1466,9 @@ SPEC CHECKSUMS:
14641466
React-jsinspector: 85583ef014ce53d731a98c66a0e24496f7a83066
14651467
React-logger: 3eb80a977f0d9669468ef641a5e1fabbc50a09ec
14661468
React-Mapbuffer: 84ea43c6c6232049135b1550b8c60b2faac19fab
1467-
react-native-cameraroll: 755bcc628148a90a7c9cf3f817a252be3a601bc5
14681469
react-native-document-picker: 2b8f18667caee73a96708a82b284a4f40b30a156
14691470
react-native-flipper: 9c1957af24b76493ba74f46d000a5c1d485e7731
1471+
react-native-image-picker: d3db110a3ded6e48c93aef7e8e51afdde8b16ed0
14701472
react-native-image-resizer: d9fb629a867335bdc13230ac2a58702bb8c8828f
14711473
react-native-netinfo: 299dad906cdbf3b67bcc6f693c807f98bdd127cc
14721474
react-native-quick-sqlite: 2b225dadc63b670f027111e58f6f169773f6d755
@@ -1509,4 +1511,4 @@ SPEC CHECKSUMS:
15091511

15101512
PODFILE CHECKSUM: 90406e1e85c82b37484f5d746afa45c0637bb4b3
15111513

1512-
COCOAPODS: 1.14.3
1514+
COCOAPODS: 1.15.2

0 commit comments

Comments
 (0)