react-native-timacare 3.3.28 → 3.3.30

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.
Files changed (78) hide show
  1. package/lib/commonjs/screens/camera/CCCDCameraScreen.js +1 -1
  2. package/lib/commonjs/screens/camera/CCCDCameraScreen.js.flow +35 -27
  3. package/lib/commonjs/screens/camera/CCCDCameraScreen.js.map +1 -1
  4. package/lib/commonjs/screens/camera/index.js +1 -1
  5. package/lib/commonjs/screens/camera/index.js.flow +34 -48
  6. package/lib/commonjs/screens/camera/index.js.map +1 -1
  7. package/lib/commonjs/screens/home/DigitalTopupItem.js +1 -1
  8. package/lib/commonjs/screens/home/DigitalTopupItem.js.flow +31 -33
  9. package/lib/commonjs/screens/home/DigitalTopupItem.js.map +1 -1
  10. package/lib/commonjs/screens/liveness/index.js +1 -1
  11. package/lib/commonjs/screens/liveness/index.js.flow +43 -54
  12. package/lib/commonjs/screens/liveness/index.js.map +1 -1
  13. package/lib/commonjs/screens/liveness-v2/index.js +1 -1
  14. package/lib/commonjs/screens/liveness-v2/index.js.flow +60 -56
  15. package/lib/commonjs/screens/liveness-v2/index.js.map +1 -1
  16. package/lib/commonjs/screens/mrz-scanner/index.js +1 -1
  17. package/lib/commonjs/screens/mrz-scanner/index.js.flow +25 -10
  18. package/lib/commonjs/screens/mrz-scanner/index.js.map +1 -1
  19. package/lib/commonjs/screens/toan-trinh-so/OCR.js +1 -1
  20. package/lib/commonjs/screens/toan-trinh-so/OCR.js.flow +57 -136
  21. package/lib/commonjs/screens/toan-trinh-so/OCR.js.map +1 -1
  22. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js +1 -1
  23. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js.flow +70 -50
  24. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js.map +1 -1
  25. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js +1 -1
  26. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.flow +26 -37
  27. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
  28. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js +1 -1
  29. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.flow +77 -78
  30. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  31. package/lib/commonjs/screens/uploadVideo/index.js +1 -1
  32. package/lib/commonjs/screens/uploadVideo/index.js.flow +32 -33
  33. package/lib/commonjs/screens/uploadVideo/index.js.map +1 -1
  34. package/lib/module/screens/camera/CCCDCameraScreen.js +1 -1
  35. package/lib/module/screens/camera/CCCDCameraScreen.js.map +1 -1
  36. package/lib/module/screens/camera/index.js +1 -1
  37. package/lib/module/screens/camera/index.js.map +1 -1
  38. package/lib/module/screens/home/DigitalTopupItem.js +1 -1
  39. package/lib/module/screens/home/DigitalTopupItem.js.map +1 -1
  40. package/lib/module/screens/liveness/index.js +1 -1
  41. package/lib/module/screens/liveness/index.js.map +1 -1
  42. package/lib/module/screens/liveness-v2/index.js +1 -1
  43. package/lib/module/screens/liveness-v2/index.js.map +1 -1
  44. package/lib/module/screens/mrz-scanner/index.js +1 -1
  45. package/lib/module/screens/mrz-scanner/index.js.map +1 -1
  46. package/lib/module/screens/toan-trinh-so/OCR.js +1 -1
  47. package/lib/module/screens/toan-trinh-so/OCR.js.map +1 -1
  48. package/lib/module/screens/toan-trinh-so/RegisterCamera.js +1 -1
  49. package/lib/module/screens/toan-trinh-so/RegisterCamera.js.map +1 -1
  50. package/lib/module/screens/toan-trinh-so/TTSSelfie.js +1 -1
  51. package/lib/module/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
  52. package/lib/module/screens/toan-trinh-so/VehicleCamera.js +1 -1
  53. package/lib/module/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  54. package/lib/module/screens/uploadVideo/index.js +1 -1
  55. package/lib/module/screens/uploadVideo/index.js.map +1 -1
  56. package/lib/typescript/screens/camera/CCCDCameraScreen.d.ts.map +1 -1
  57. package/lib/typescript/screens/camera/index.d.ts.map +1 -1
  58. package/lib/typescript/screens/home/DigitalTopupItem.d.ts.map +1 -1
  59. package/lib/typescript/screens/liveness/index.d.ts.map +1 -1
  60. package/lib/typescript/screens/liveness-v2/index.d.ts.map +1 -1
  61. package/lib/typescript/screens/mrz-scanner/index.d.ts.map +1 -1
  62. package/lib/typescript/screens/toan-trinh-so/OCR.d.ts.map +1 -1
  63. package/lib/typescript/screens/toan-trinh-so/RegisterCamera.d.ts.map +1 -1
  64. package/lib/typescript/screens/toan-trinh-so/TTSSelfie.d.ts.map +1 -1
  65. package/lib/typescript/screens/toan-trinh-so/VehicleCamera.d.ts.map +1 -1
  66. package/lib/typescript/screens/uploadVideo/index.d.ts.map +1 -1
  67. package/package.json +1 -2
  68. package/src/screens/camera/CCCDCameraScreen.tsx +35 -27
  69. package/src/screens/camera/index.tsx +34 -48
  70. package/src/screens/home/DigitalTopupItem.tsx +31 -33
  71. package/src/screens/liveness/index.tsx +43 -54
  72. package/src/screens/liveness-v2/index.tsx +60 -56
  73. package/src/screens/mrz-scanner/index.tsx +25 -10
  74. package/src/screens/toan-trinh-so/OCR.tsx +57 -136
  75. package/src/screens/toan-trinh-so/RegisterCamera.tsx +70 -50
  76. package/src/screens/toan-trinh-so/TTSSelfie.tsx +26 -37
  77. package/src/screens/toan-trinh-so/VehicleCamera.tsx +77 -78
  78. package/src/screens/uploadVideo/index.tsx +32 -33
@@ -29,7 +29,11 @@ import {
29
29
  RESULTS,
30
30
  openSettings,
31
31
  } from 'react-native-permissions';
32
- import { RNCamera } from 'react-native-camera';
32
+ import {
33
+ Camera as VisionCamera,
34
+ useCameraDevice,
35
+ useCameraFormat,
36
+ } from 'react-native-vision-camera';
33
37
  import { commonStyles } from '../CommonStyles';
34
38
  import { ScreenNames } from '../../navigation';
35
39
  import { load, OCR_V2, save } from '../../utils/storage';
@@ -64,30 +68,30 @@ export default function VehicleCamera(props: any) {
64
68
  const [passPermission, setPassPermission] = useState(false);
65
69
 
66
70
  const myCamera = useRef(null);
71
+ const device = useCameraDevice('back');
72
+ const format = useCameraFormat(device, [
73
+ { photoResolution: { width: 1280, height: 720 } },
74
+ ]);
67
75
 
68
76
  const takePhoto = async () => {
77
+ if (myCamera.current == null || taking) return;
69
78
  setTaking(true);
70
- const options = {
71
- // width: 720,
72
- base64: true,
73
- pauseAfterCapture: true,
74
- fixOrientation: false,
75
- forceUpOrientation: false,
76
- orientation: RNCamera.Constants.Orientation.portrait,
77
- };
78
- const data = await myCamera.current.takePictureAsync(options);
79
+ const data = await myCamera.current.takePhoto({
80
+ qualityPrioritization: 'quality',
81
+ });
82
+ const uri = 'file://' + data.path;
79
83
  setTaking(false);
80
84
  if (props?.route?.params?.front) {
81
85
  navigation.push(ScreenNames.VehicleRegistrationFront, {
82
- uri: data?.uri,
86
+ uri,
83
87
  loan: props?.route?.params?.loan,
84
88
  });
85
89
  } else if (props.route?.params?.callback) {
86
90
  navigation.goBack();
87
- props.route?.params?.callback(data?.uri);
91
+ props.route?.params?.callback(uri);
88
92
  } else {
89
93
  navigation.push(ScreenNames.VehicleRegistrationBack, {
90
- uri: data?.uri,
94
+ uri,
91
95
  loan: props?.route?.params?.loan,
92
96
  });
93
97
  }
@@ -257,73 +261,68 @@ export default function VehicleCamera(props: any) {
257
261
  >
258
262
  {passPermission && shouldRenderCamera ? (
259
263
  <View style={{ flex: 1 }}>
260
- <RNCamera
261
- key={cameraKey}
262
- ref={myCamera}
263
- defaultVideoQuality={RNCamera.Constants.VideoQuality['720p']}
264
- style={{
265
- flex: 1,
266
- }}
267
- maxZoom={1}
268
- androidCameraPermissionOptions={{
269
- title: 'Permission to use camera',
270
- message: 'We need your permission to use your camera',
271
- buttonPositive: 'Ok',
272
- buttonNegative: 'Cancel',
273
- }}
274
- quality={0.9}
275
- pictureSize="1280x720"
276
- >
277
- <View style={$overlay}>
278
- <View style={$darkOverlayTop} />
279
- <View style={$overlayRow}>
280
- <View style={$darkOverlaySide} />
281
- <View style={$frameBorder}>
282
- <Corner
283
- style={{
284
- top: 0,
285
- left: 0,
286
- borderTopWidth: CORNER_WIDTH,
287
- borderLeftWidth: CORNER_WIDTH,
288
- borderColor: BORDER_COLOR,
289
- }}
290
- />
291
-
292
- <Corner
293
- style={{
294
- top: 0,
295
- right: 0,
296
- borderTopWidth: CORNER_WIDTH,
297
- borderRightWidth: CORNER_WIDTH,
298
- borderColor: BORDER_COLOR,
299
- }}
300
- />
301
-
302
- <Corner
303
- style={{
304
- bottom: 0,
305
- left: 0,
306
- borderBottomWidth: CORNER_WIDTH,
307
- borderLeftWidth: CORNER_WIDTH,
308
- borderColor: BORDER_COLOR,
309
- }}
310
- />
311
-
312
- <Corner
313
- style={{
314
- bottom: 0,
315
- right: 0,
316
- borderBottomWidth: CORNER_WIDTH,
317
- borderRightWidth: CORNER_WIDTH,
318
- borderColor: BORDER_COLOR,
319
- }}
320
- />
321
- </View>
322
- <View style={$darkOverlaySide} />
264
+ {device ? (
265
+ <VisionCamera
266
+ key={cameraKey}
267
+ ref={myCamera}
268
+ style={{
269
+ flex: 1,
270
+ }}
271
+ device={device}
272
+ isActive={true}
273
+ photo={true}
274
+ format={format}
275
+ />
276
+ ) : null}
277
+ <View style={$overlay}>
278
+ <View style={$darkOverlayTop} />
279
+ <View style={$overlayRow}>
280
+ <View style={$darkOverlaySide} />
281
+ <View style={$frameBorder}>
282
+ <Corner
283
+ style={{
284
+ top: 0,
285
+ left: 0,
286
+ borderTopWidth: CORNER_WIDTH,
287
+ borderLeftWidth: CORNER_WIDTH,
288
+ borderColor: BORDER_COLOR,
289
+ }}
290
+ />
291
+
292
+ <Corner
293
+ style={{
294
+ top: 0,
295
+ right: 0,
296
+ borderTopWidth: CORNER_WIDTH,
297
+ borderRightWidth: CORNER_WIDTH,
298
+ borderColor: BORDER_COLOR,
299
+ }}
300
+ />
301
+
302
+ <Corner
303
+ style={{
304
+ bottom: 0,
305
+ left: 0,
306
+ borderBottomWidth: CORNER_WIDTH,
307
+ borderLeftWidth: CORNER_WIDTH,
308
+ borderColor: BORDER_COLOR,
309
+ }}
310
+ />
311
+
312
+ <Corner
313
+ style={{
314
+ bottom: 0,
315
+ right: 0,
316
+ borderBottomWidth: CORNER_WIDTH,
317
+ borderRightWidth: CORNER_WIDTH,
318
+ borderColor: BORDER_COLOR,
319
+ }}
320
+ />
323
321
  </View>
324
- <View style={$darkOverlayBottom} />
322
+ <View style={$darkOverlaySide} />
325
323
  </View>
326
- </RNCamera>
324
+ <View style={$darkOverlayBottom} />
325
+ </View>
327
326
 
328
327
  <View
329
328
  style={{
@@ -10,7 +10,10 @@ import {
10
10
  View,
11
11
  } from 'react-native';
12
12
  import { formatDDMMYYY, formatMoney } from '../../utils';
13
- import { RNCamera } from 'react-native-camera';
13
+ import {
14
+ Camera as VisionCamera,
15
+ useCameraDevice,
16
+ } from 'react-native-vision-camera';
14
17
  import MButton from '../../components/MButton';
15
18
  import { IconPause, IconPlay } from '../../assets/icons';
16
19
  import { MText } from '../../components/MText';
@@ -39,6 +42,8 @@ export const Video = observer(function Video(props: any) {
39
42
  const [count, setCount] = useState(COUNTDOWN_SECONDS);
40
43
  const [isRecording, setIsRecording] = useState(false);
41
44
  const [isLoading, setIsLoading] = useState(false);
45
+ const [passPermission, setPassPermission] = useState(false);
46
+ const device = useCameraDevice('front');
42
47
 
43
48
  const loan = props?.route?.params?.loan;
44
49
  const content = useMemo(() => {
@@ -56,7 +61,10 @@ export const Video = observer(function Video(props: any) {
56
61
  (permission) => statuses[permission] !== RESULTS.GRANTED
57
62
  );
58
63
 
59
- if (toRequest.length === 0) return true;
64
+ if (toRequest.length === 0) {
65
+ setPassPermission(true);
66
+ return true;
67
+ }
60
68
 
61
69
  const requested = await requestMultiple(toRequest);
62
70
  const values = Object.values(requested);
@@ -64,6 +72,7 @@ export const Video = observer(function Video(props: any) {
64
72
  const anyBlocked = values.some((status) => status === RESULTS.BLOCKED);
65
73
 
66
74
  if (!allGranted) {
75
+ setPassPermission(false);
67
76
  Alert.alert(
68
77
  'Thông báo',
69
78
  anyBlocked
@@ -81,6 +90,7 @@ export const Video = observer(function Video(props: any) {
81
90
  );
82
91
  }
83
92
 
93
+ setPassPermission(allGranted);
84
94
  return allGranted;
85
95
  };
86
96
 
@@ -114,19 +124,20 @@ export const Video = observer(function Video(props: any) {
114
124
 
115
125
  setIsRecording(true);
116
126
  try {
117
- const data = await camera.current.recordAsync({
118
- quality: RNCamera.Constants.VideoQuality['480p'],
119
- videoBitrate: 1500000,
120
- ...(Platform.OS === 'ios'
121
- ? { codec: RNCamera.Constants.VideoCodec.H264 }
122
- : {}),
127
+ const data = await new Promise((resolve, reject) => {
128
+ camera.current.startRecording({
129
+ videoCodec: Platform.OS === 'ios' ? 'h264' : undefined,
130
+ onRecordingFinished: resolve,
131
+ onRecordingError: reject,
132
+ });
123
133
  });
124
134
 
125
135
  setIsLoading(true);
136
+ const uri = 'file://' + data.path;
126
137
  const formData = new FormData();
127
138
  formData.append('video', {
128
- name: data.uri.split(/[\\/]/).pop(),
129
- uri: data.uri,
139
+ name: data.path.split(/[\\/]/).pop(),
140
+ uri,
130
141
  type: 'video/*',
131
142
  });
132
143
 
@@ -188,27 +199,16 @@ export const Video = observer(function Video(props: any) {
188
199
  </MText>
189
200
  </View>
190
201
  )}
191
- <RNCamera
192
- ref={camera}
193
- style={styles.preview}
194
- type={RNCamera.Constants.Type.front}
195
- permissionDialogTitle={'Permission to use camera'}
196
- permissionDialogMessage={
197
- 'We need your permission to use your camera phone'
198
- }
199
- androidCameraPermissionOptions={{
200
- title: 'Permission to use camera',
201
- message: 'We need your permission to use your camera',
202
- buttonPositive: 'Ok',
203
- buttonNegative: 'Cancel',
204
- }}
205
- androidRecordAudioPermissionOptions={{
206
- title: 'Permission to use audio recording',
207
- message: 'We need your permission to use your audio',
208
- buttonPositive: 'Ok',
209
- buttonNegative: 'Cancel',
210
- }}
211
- />
202
+ {passPermission && device ? (
203
+ <VisionCamera
204
+ ref={camera}
205
+ style={styles.preview}
206
+ device={device}
207
+ isActive={true}
208
+ video={true}
209
+ audio={true}
210
+ />
211
+ ) : null}
212
212
  <View
213
213
  style={{
214
214
  backgroundColor: '#00000080',
@@ -217,6 +217,7 @@ export const Video = observer(function Video(props: any) {
217
217
  bottom: 0,
218
218
  left: 0,
219
219
  right: 0,
220
+ paddingVertical: 16,
220
221
  }}
221
222
  >
222
223
  {isRecording ? (
@@ -224,7 +225,6 @@ export const Video = observer(function Video(props: any) {
224
225
  style={{
225
226
  justifyContent: 'center',
226
227
  alignItems: 'center',
227
- marginBottom: 20,
228
228
  }}
229
229
  onPress={() => {
230
230
  stopRecording();
@@ -237,7 +237,6 @@ export const Video = observer(function Video(props: any) {
237
237
  style={{
238
238
  justifyContent: 'center',
239
239
  alignItems: 'center',
240
- marginBottom: 20,
241
240
  }}
242
241
  disabled={videoStore.isLoading}
243
242
  onPress={() => {