stream-chat-react-native 5.34.1-beta.2 → 5.34.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-chat-react-native",
|
|
3
3
|
"description": "The official React Native SDK for Stream Chat, a service for building chat applications",
|
|
4
|
-
"version": "5.34.1-beta.
|
|
4
|
+
"version": "5.34.1-beta.4",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -11,21 +11,21 @@
|
|
|
11
11
|
"types": "types/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"es6-symbol": "^3.1.3",
|
|
14
|
-
"stream-chat-react-native-core": "5.34.1-beta.
|
|
14
|
+
"stream-chat-react-native-core": "5.34.1-beta.4"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@react-native-camera-roll/camera-roll": ">=5.0.0",
|
|
18
|
-
"@react-native-community/netinfo": ">=2.0.7",
|
|
19
18
|
"@react-native-clipboard/clipboard": "^1.11.1",
|
|
19
|
+
"@react-native-community/netinfo": ">=2.0.7",
|
|
20
20
|
"@stream-io/flat-list-mvcp": "^0.10.3",
|
|
21
21
|
"react-native": ">=0.60.0",
|
|
22
|
+
"react-native-audio-recorder-player": ">=3.6.4",
|
|
22
23
|
"react-native-document-picker": ">=9.0.1",
|
|
23
24
|
"react-native-fs": ">=2.16.6",
|
|
24
25
|
"react-native-haptic-feedback": ">=1.11.0",
|
|
25
26
|
"react-native-image-crop-picker": ">=0.33.2",
|
|
26
27
|
"react-native-image-resizer": ">=1.4.2",
|
|
27
28
|
"react-native-share": ">=4.1.0",
|
|
28
|
-
"react-native-audio-recorder-player": ">=3.6.4",
|
|
29
29
|
"react-native-video": ">=6.4.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependenciesMeta": {
|
|
@@ -41,6 +41,9 @@
|
|
|
41
41
|
"react-native-haptic-feedback": {
|
|
42
42
|
"optional": true
|
|
43
43
|
},
|
|
44
|
+
"react-native-image-crop-picker": {
|
|
45
|
+
"optional": true
|
|
46
|
+
},
|
|
44
47
|
"react-native-audio-recorder-player": {
|
|
45
48
|
"optional": true
|
|
46
49
|
},
|
|
@@ -58,7 +61,6 @@
|
|
|
58
61
|
"@stream-io/flat-list-mvcp": "0.10.3",
|
|
59
62
|
"react-native": ">=0.60.0",
|
|
60
63
|
"react-native-fs": ">=2.16.6",
|
|
61
|
-
"react-native-image-crop-picker": "^0.38.0",
|
|
62
64
|
"react-native-image-resizer": ">=1.4.2"
|
|
63
65
|
}
|
|
64
66
|
}
|
package/src/handlers/index.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
oniOS14GalleryLibrarySelectionChange,
|
|
14
14
|
saveFile,
|
|
15
15
|
Sound,
|
|
16
|
-
takePhoto,
|
|
17
16
|
Video,
|
|
18
17
|
} from './handlers';
|
|
19
18
|
|
|
@@ -22,6 +21,7 @@ import {
|
|
|
22
21
|
pickDocument,
|
|
23
22
|
setClipboardString,
|
|
24
23
|
shareImage,
|
|
24
|
+
takePhoto,
|
|
25
25
|
triggerHaptic,
|
|
26
26
|
} from './optionalDependencies';
|
|
27
27
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AppState, Image, PermissionsAndroid, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
let ImagePicker;
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
ImagePicker = require('react-native-image-crop-picker').default;
|
|
7
|
+
} catch (e) {
|
|
8
|
+
console.log('react-native-image-crop-picker is not installed');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const takePhoto = ImagePicker
|
|
12
|
+
? async ({ compressImageQuality = Platform.OS === 'ios' ? 0.8 : 1 }) => {
|
|
13
|
+
if (Platform.OS === 'android') {
|
|
14
|
+
const cameraPermissions = await PermissionsAndroid.check(
|
|
15
|
+
PermissionsAndroid.PERMISSIONS.CAMERA,
|
|
16
|
+
);
|
|
17
|
+
if (!cameraPermissions) {
|
|
18
|
+
const androidPermissionStatus = await PermissionsAndroid.request(
|
|
19
|
+
PermissionsAndroid.PERMISSIONS.CAMERA,
|
|
20
|
+
);
|
|
21
|
+
if (androidPermissionStatus === PermissionsAndroid.RESULTS.DENIED) {
|
|
22
|
+
return { cancelled: true };
|
|
23
|
+
} else if (androidPermissionStatus === PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN) {
|
|
24
|
+
return { askToOpenSettings: true, cancelled: true };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const photo = await ImagePicker.openCamera({
|
|
30
|
+
compressImageQuality: Math.min(Math.max(0, compressImageQuality), 1),
|
|
31
|
+
});
|
|
32
|
+
if (photo.height && photo.width && photo.path) {
|
|
33
|
+
let size: { height?: number; width?: number } = {};
|
|
34
|
+
if (Platform.OS === 'android') {
|
|
35
|
+
// Height and width returned by ImagePicker are incorrect on Android.
|
|
36
|
+
// The issue is described in following github issue:
|
|
37
|
+
// https://github.com/ivpusic/react-native-image-crop-picker/issues/901
|
|
38
|
+
// This we can't rely on them as it is, and we need to use Image.getSize
|
|
39
|
+
// to get accurate size.
|
|
40
|
+
const getSize = (): Promise<{ height: number; width: number }> =>
|
|
41
|
+
new Promise((resolve) => {
|
|
42
|
+
Image.getSize(photo.path, (width, height) => {
|
|
43
|
+
resolve({ height, width });
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const { height, width } = await getSize();
|
|
49
|
+
size.height = height;
|
|
50
|
+
size.width = width;
|
|
51
|
+
} catch (e) {
|
|
52
|
+
// do nothing
|
|
53
|
+
console.warn('Error get image size of picture caputred from camera ', e);
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
size = {
|
|
57
|
+
height: photo.height,
|
|
58
|
+
width: photo.width,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
cancelled: false,
|
|
63
|
+
source: 'camera',
|
|
64
|
+
uri: photo.path,
|
|
65
|
+
...size,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
} catch (e: unknown) {
|
|
69
|
+
if (e instanceof Error) {
|
|
70
|
+
// on iOS: if it was in inactive state, then the user had just denied the permissions
|
|
71
|
+
if (Platform.OS === 'ios' && AppState.currentState === 'active') {
|
|
72
|
+
const cameraPermissionDeniedMsg = 'User did not grant camera permission.';
|
|
73
|
+
// Open settings when the user did not allow camera permissions
|
|
74
|
+
if (e.message === cameraPermissionDeniedMsg) {
|
|
75
|
+
return { askToOpenSettings: true, cancelled: true };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return { cancelled: true };
|
|
82
|
+
}
|
|
83
|
+
: null;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { AppState, Image, PermissionsAndroid, Platform } from 'react-native';
|
|
2
|
-
import ImagePicker from 'react-native-image-crop-picker';
|
|
3
|
-
|
|
4
|
-
export const takePhoto = async ({ compressImageQuality = Platform.OS === 'ios' ? 0.8 : 1 }) => {
|
|
5
|
-
if (Platform.OS === 'android') {
|
|
6
|
-
const cameraPermissions = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.CAMERA);
|
|
7
|
-
if (!cameraPermissions) {
|
|
8
|
-
const androidPermissionStatus = await PermissionsAndroid.request(
|
|
9
|
-
PermissionsAndroid.PERMISSIONS.CAMERA,
|
|
10
|
-
);
|
|
11
|
-
if (androidPermissionStatus === PermissionsAndroid.RESULTS.DENIED) {
|
|
12
|
-
return { cancelled: true };
|
|
13
|
-
} else if (androidPermissionStatus === PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN) {
|
|
14
|
-
return { askToOpenSettings: true, cancelled: true };
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
const photo = await ImagePicker.openCamera({
|
|
20
|
-
compressImageQuality: Math.min(Math.max(0, compressImageQuality), 1),
|
|
21
|
-
});
|
|
22
|
-
if (photo.height && photo.width && photo.path) {
|
|
23
|
-
let size: { height?: number; width?: number } = {};
|
|
24
|
-
if (Platform.OS === 'android') {
|
|
25
|
-
// Height and width returned by ImagePicker are incorrect on Android.
|
|
26
|
-
// The issue is described in following github issue:
|
|
27
|
-
// https://github.com/ivpusic/react-native-image-crop-picker/issues/901
|
|
28
|
-
// This we can't rely on them as it is, and we need to use Image.getSize
|
|
29
|
-
// to get accurate size.
|
|
30
|
-
const getSize = (): Promise<{ height: number; width: number }> =>
|
|
31
|
-
new Promise((resolve) => {
|
|
32
|
-
Image.getSize(photo.path, (width, height) => {
|
|
33
|
-
resolve({ height, width });
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
const { height, width } = await getSize();
|
|
39
|
-
size.height = height;
|
|
40
|
-
size.width = width;
|
|
41
|
-
} catch (e) {
|
|
42
|
-
// do nothing
|
|
43
|
-
console.warn('Error get image size of picture caputred from camera ', e);
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
size = {
|
|
47
|
-
height: photo.height,
|
|
48
|
-
width: photo.width,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
cancelled: false,
|
|
53
|
-
source: 'camera',
|
|
54
|
-
uri: photo.path,
|
|
55
|
-
...size,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
} catch (e: unknown) {
|
|
59
|
-
if (e instanceof Error) {
|
|
60
|
-
// on iOS: if it was in inactive state, then the user had just denied the permissions
|
|
61
|
-
if (Platform.OS === 'ios' && AppState.currentState === 'active') {
|
|
62
|
-
const cameraPermissionDeniedMsg = 'User did not grant camera permission.';
|
|
63
|
-
// Open settings when the user did not allow camera permissions
|
|
64
|
-
if (e.message === cameraPermissionDeniedMsg) {
|
|
65
|
-
return { askToOpenSettings: true, cancelled: true };
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return { cancelled: true };
|
|
72
|
-
};
|