react-native-timacare 3.3.27 → 3.3.29

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 (85) hide show
  1. package/lib/commonjs/screens/camera/CCCDCameraScreen.js +1 -1
  2. package/lib/commonjs/screens/camera/CCCDCameraScreen.js.flow +29 -26
  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/home/ItemMotoBikeLoan.js +1 -1
  11. package/lib/commonjs/screens/home/ItemMotoBikeLoan.js.flow +44 -4
  12. package/lib/commonjs/screens/home/ItemMotoBikeLoan.js.map +1 -1
  13. package/lib/commonjs/screens/liveness/index.js +1 -1
  14. package/lib/commonjs/screens/liveness/index.js.flow +43 -54
  15. package/lib/commonjs/screens/liveness/index.js.map +1 -1
  16. package/lib/commonjs/screens/liveness-v2/index.js +1 -1
  17. package/lib/commonjs/screens/liveness-v2/index.js.flow +60 -56
  18. package/lib/commonjs/screens/liveness-v2/index.js.map +1 -1
  19. package/lib/commonjs/screens/mrz-scanner/index.js +1 -1
  20. package/lib/commonjs/screens/mrz-scanner/index.js.flow +25 -10
  21. package/lib/commonjs/screens/mrz-scanner/index.js.map +1 -1
  22. package/lib/commonjs/screens/toan-trinh-so/OCR.js +1 -1
  23. package/lib/commonjs/screens/toan-trinh-so/OCR.js.flow +48 -49
  24. package/lib/commonjs/screens/toan-trinh-so/OCR.js.map +1 -1
  25. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js +1 -1
  26. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js.flow +32 -33
  27. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js.map +1 -1
  28. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js +1 -1
  29. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.flow +26 -37
  30. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
  31. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js +1 -1
  32. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.flow +77 -78
  33. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  34. package/lib/commonjs/screens/uploadVideo/index.js +1 -1
  35. package/lib/commonjs/screens/uploadVideo/index.js.flow +32 -33
  36. package/lib/commonjs/screens/uploadVideo/index.js.map +1 -1
  37. package/lib/module/screens/camera/CCCDCameraScreen.js +1 -1
  38. package/lib/module/screens/camera/CCCDCameraScreen.js.map +1 -1
  39. package/lib/module/screens/camera/index.js +1 -1
  40. package/lib/module/screens/camera/index.js.map +1 -1
  41. package/lib/module/screens/home/DigitalTopupItem.js +1 -1
  42. package/lib/module/screens/home/DigitalTopupItem.js.map +1 -1
  43. package/lib/module/screens/home/ItemMotoBikeLoan.js +1 -1
  44. package/lib/module/screens/home/ItemMotoBikeLoan.js.map +1 -1
  45. package/lib/module/screens/liveness/index.js +1 -1
  46. package/lib/module/screens/liveness/index.js.map +1 -1
  47. package/lib/module/screens/liveness-v2/index.js +1 -1
  48. package/lib/module/screens/liveness-v2/index.js.map +1 -1
  49. package/lib/module/screens/mrz-scanner/index.js +1 -1
  50. package/lib/module/screens/mrz-scanner/index.js.map +1 -1
  51. package/lib/module/screens/toan-trinh-so/OCR.js +1 -1
  52. package/lib/module/screens/toan-trinh-so/OCR.js.map +1 -1
  53. package/lib/module/screens/toan-trinh-so/RegisterCamera.js +1 -1
  54. package/lib/module/screens/toan-trinh-so/RegisterCamera.js.map +1 -1
  55. package/lib/module/screens/toan-trinh-so/TTSSelfie.js +1 -1
  56. package/lib/module/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
  57. package/lib/module/screens/toan-trinh-so/VehicleCamera.js +1 -1
  58. package/lib/module/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  59. package/lib/module/screens/uploadVideo/index.js +1 -1
  60. package/lib/module/screens/uploadVideo/index.js.map +1 -1
  61. package/lib/typescript/screens/camera/CCCDCameraScreen.d.ts.map +1 -1
  62. package/lib/typescript/screens/camera/index.d.ts.map +1 -1
  63. package/lib/typescript/screens/home/DigitalTopupItem.d.ts.map +1 -1
  64. package/lib/typescript/screens/home/ItemMotoBikeLoan.d.ts.map +1 -1
  65. package/lib/typescript/screens/liveness/index.d.ts.map +1 -1
  66. package/lib/typescript/screens/liveness-v2/index.d.ts.map +1 -1
  67. package/lib/typescript/screens/mrz-scanner/index.d.ts.map +1 -1
  68. package/lib/typescript/screens/toan-trinh-so/OCR.d.ts.map +1 -1
  69. package/lib/typescript/screens/toan-trinh-so/RegisterCamera.d.ts.map +1 -1
  70. package/lib/typescript/screens/toan-trinh-so/TTSSelfie.d.ts.map +1 -1
  71. package/lib/typescript/screens/toan-trinh-so/VehicleCamera.d.ts.map +1 -1
  72. package/lib/typescript/screens/uploadVideo/index.d.ts.map +1 -1
  73. package/package.json +1 -2
  74. package/src/screens/camera/CCCDCameraScreen.tsx +29 -26
  75. package/src/screens/camera/index.tsx +34 -48
  76. package/src/screens/home/DigitalTopupItem.tsx +31 -33
  77. package/src/screens/home/ItemMotoBikeLoan.tsx +44 -4
  78. package/src/screens/liveness/index.tsx +43 -54
  79. package/src/screens/liveness-v2/index.tsx +60 -56
  80. package/src/screens/mrz-scanner/index.tsx +25 -10
  81. package/src/screens/toan-trinh-so/OCR.tsx +48 -49
  82. package/src/screens/toan-trinh-so/RegisterCamera.tsx +32 -33
  83. package/src/screens/toan-trinh-so/TTSSelfie.tsx +26 -37
  84. package/src/screens/toan-trinh-so/VehicleCamera.tsx +77 -78
  85. package/src/screens/uploadVideo/index.tsx +32 -33
@@ -12,7 +12,11 @@ import {
12
12
  NativeModules,
13
13
  } from 'react-native';
14
14
  import { StackActions, useNavigation } from '@react-navigation/native';
15
- import { RNCamera } from 'react-native-camera';
15
+ import {
16
+ Camera as VisionCamera,
17
+ useCameraDevice,
18
+ useCameraFormat,
19
+ } from 'react-native-vision-camera';
16
20
  import TextRecognition from '@react-native-ml-kit/text-recognition';
17
21
  import {
18
22
  openSettings,
@@ -39,6 +43,10 @@ const MRZScanner = (props: any) => {
39
43
  const [mrzData, setMrzData] = useState('');
40
44
  const [passPermission, setPassPermission] = useState(false);
41
45
  const cameraRef = useRef(null);
46
+ const device = useCameraDevice('back');
47
+ const format = useCameraFormat(device, [
48
+ { photoResolution: { width: 1280, height: 720 } },
49
+ ]);
42
50
 
43
51
  const requestPermissions = () => {
44
52
  request(
@@ -224,20 +232,27 @@ const MRZScanner = (props: any) => {
224
232
 
225
233
  const takePicture = async () => {
226
234
  if (cameraRef.current) {
227
- const options = { quality: 0.8, base64: true };
228
- const data = await cameraRef.current.takePictureAsync(options);
229
- await handleTextRecognition(data.uri);
235
+ const data = await cameraRef.current.takePhoto({
236
+ qualityPrioritization: 'speed',
237
+ });
238
+ await handleTextRecognition('file://' + data.path);
230
239
  }
231
240
  };
232
241
 
233
242
  return (
234
243
  <View style={styles.container}>
235
- <RNCamera
236
- ref={cameraRef}
237
- style={styles.camera}
238
- type={RNCamera.Constants.Type.back}
239
- captureAudio={false}
240
- ></RNCamera>
244
+ {passPermission && device ? (
245
+ <VisionCamera
246
+ ref={cameraRef}
247
+ style={styles.camera}
248
+ device={device}
249
+ isActive={true}
250
+ photo={true}
251
+ format={format}
252
+ />
253
+ ) : (
254
+ <View style={styles.camera} />
255
+ )}
241
256
  <View style={styles.overlay}>
242
257
  <View style={styles.overlayTop} />
243
258
  <View style={styles.overlayCenter}>
@@ -24,7 +24,11 @@ import {
24
24
  RESULTS,
25
25
  openSettings,
26
26
  } from 'react-native-permissions';
27
- import { RNCamera } from 'react-native-camera';
27
+ import {
28
+ Camera as VisionCamera,
29
+ useCameraDevice,
30
+ useCameraFormat,
31
+ } from 'react-native-vision-camera';
28
32
  import Modal from 'react-native-modal';
29
33
  import LinearGradient from 'react-native-linear-gradient';
30
34
  import {
@@ -65,6 +69,10 @@ export const OCR = observer(function OCR(props: any) {
65
69
  const [passPermission, setPassPermission] = useState(false);
66
70
  const [shouldRenderCamera, setShouldRenderCamera] = useState(false);
67
71
  const myCamera = useRef(null);
72
+ const device = useCameraDevice('back');
73
+ const format = useCameraFormat(device, [
74
+ { photoResolution: { width: 1280, height: 720 } },
75
+ ]);
68
76
 
69
77
  const requestPermissions = () => {
70
78
  request(
@@ -176,15 +184,6 @@ export const OCR = observer(function OCR(props: any) {
176
184
  loadIntro();
177
185
  }, []);
178
186
 
179
- useEffect(() => {
180
- const unsubscribe = navigation.addListener('blur', () => {
181
- // khi màn hình mất focus (chuyển sang màn hình khác)
182
- myCamera.current?.pausePreview(); // hoặc stopRecording nếu đang quay
183
- });
184
-
185
- return unsubscribe;
186
- }, [navigation]);
187
-
188
187
  const saveDataNfc = async (body) => {
189
188
  try {
190
189
  const response = await Api.getInstance().saveNfcInfo({
@@ -285,39 +284,34 @@ export const OCR = observer(function OCR(props: any) {
285
284
 
286
285
  const scanNfc = async () => {
287
286
  if (myCamera.current) {
288
- const options = { quality: 0.8, base64: true };
289
- const data = await myCamera.current.takePictureAsync(options);
290
- await handleTextRecognition(data.uri);
287
+ const data = await myCamera.current.takePhoto({
288
+ qualityPrioritization: 'speed',
289
+ });
290
+ await handleTextRecognition('file://' + data.path);
291
291
  }
292
292
  };
293
293
 
294
294
  const takePhoto = async () => {
295
+ if (myCamera.current == null || taking) return;
295
296
  setTaking(true);
296
- const options = {
297
- // width: 720,
298
- base64: true,
299
- pauseAfterCapture: true,
300
- fixOrientation: false,
301
- forceUpOrientation: false,
302
- orientation: RNCamera.Constants.Orientation.portrait,
303
- quality: 0.9,
304
- pictureSize: '1280x720',
305
- };
306
- const data = await myCamera.current.takePictureAsync(options);
297
+ const data = await myCamera.current.takePhoto({
298
+ qualityPrioritization: 'quality',
299
+ });
300
+ const uri = 'file://' + data.path;
307
301
  setTaking(false);
308
302
  if (props?.route?.params?.front && !props.route?.params?.callback) {
309
303
  navigation.push(ScreenNames.TTSNationalIDFront, {
310
- uri: data?.uri,
304
+ uri,
311
305
  loan: props?.route?.params?.loan,
312
306
  });
313
307
  } else if (!props?.route?.params?.front && !props.route?.params?.callback) {
314
308
  navigation.push(ScreenNames.TTSNationalIDBack, {
315
- uri: data?.uri,
309
+ uri,
316
310
  loan: props?.route?.params?.loan,
317
311
  });
318
312
  } else {
319
313
  navigation.goBack();
320
- props.route?.params?.callback(data?.uri);
314
+ props.route?.params?.callback(uri);
321
315
  }
322
316
  };
323
317
 
@@ -518,20 +512,22 @@ export const OCR = observer(function OCR(props: any) {
518
512
  },
519
513
  ]}
520
514
  >
521
- <RNCamera
522
- ref={myCamera}
523
- defaultVideoQuality={RNCamera.Constants.VideoQuality['720p']}
524
- style={{
525
- width: Dimensions.get('window').width,
526
- height: 260,
527
- overflow: 'hidden',
528
- }}
529
- maxZoom={1}
530
- >
531
- {({ camera, status, recordAudioPermissionStatus }) => {
532
- if (status !== 'READY') return <ActivityIndicator />;
533
- }}
534
- </RNCamera>
515
+ {device ? (
516
+ <VisionCamera
517
+ ref={myCamera}
518
+ style={{
519
+ width: Dimensions.get('window').width,
520
+ height: 260,
521
+ overflow: 'hidden',
522
+ }}
523
+ device={device}
524
+ isActive={true}
525
+ photo={true}
526
+ format={format}
527
+ />
528
+ ) : (
529
+ <ActivityIndicator />
530
+ )}
535
531
  <TouchableOpacity
536
532
  onPress={() => {
537
533
  pickImageFromGallery();
@@ -554,7 +550,7 @@ export const OCR = observer(function OCR(props: any) {
554
550
  </MText>
555
551
  </TouchableOpacity>
556
552
 
557
- <View style={styles.buttonContainer}>
553
+ <View style={[styles.buttonContainer, { bottom: insets.bottom }]}>
558
554
  <MText
559
555
  style={{
560
556
  color: 'white',
@@ -577,12 +573,16 @@ export const OCR = observer(function OCR(props: any) {
577
573
  </View>
578
574
  ) : passPermission && type === 'nfc' && shouldRenderCamera ? (
579
575
  <>
580
- <RNCamera
581
- ref={myCamera}
582
- style={styles.camera}
583
- type={RNCamera.Constants.Type.back}
584
- captureAudio={false}
585
- ></RNCamera>
576
+ {device ? (
577
+ <VisionCamera
578
+ ref={myCamera}
579
+ style={styles.camera}
580
+ device={device}
581
+ isActive={true}
582
+ photo={true}
583
+ format={format}
584
+ />
585
+ ) : null}
586
586
  <View style={styles.overlay}>
587
587
  <View style={styles.overlayTop} />
588
588
  <View style={styles.overlayCenter}>
@@ -887,7 +887,6 @@ const styles = StyleSheet.create({
887
887
  justifyContent: 'center',
888
888
  alignItems: 'center',
889
889
  position: 'absolute',
890
- bottom: 40,
891
890
  left: 0,
892
891
  right: 0,
893
892
  zIndex: 1000,
@@ -19,7 +19,11 @@ import {
19
19
  RESULTS,
20
20
  openSettings,
21
21
  } from 'react-native-permissions';
22
- import { RNCamera } from 'react-native-camera';
22
+ import {
23
+ Camera as VisionCamera,
24
+ useCameraDevice,
25
+ useCameraFormat,
26
+ } from 'react-native-vision-camera';
23
27
  import Modal from 'react-native-modal';
24
28
  import { MText } from '../../components/MText';
25
29
  import LinearGradient from 'react-native-linear-gradient';
@@ -44,6 +48,10 @@ export default function RegisterCamera(props: any) {
44
48
  const [passPermission, setPassPermission] = useState(false);
45
49
 
46
50
  const myCamera = useRef(null);
51
+ const device = useCameraDevice('back');
52
+ const format = useCameraFormat(device, [
53
+ { photoResolution: { width: 1280, height: 720 } },
54
+ ]);
47
55
 
48
56
  const requestPermissions = () => {
49
57
  request(
@@ -155,27 +163,24 @@ export default function RegisterCamera(props: any) {
155
163
  }, [isFocused]);
156
164
 
157
165
  const takePhoto = async () => {
166
+ if (myCamera.current == null || taking) return;
158
167
  setTaking(true);
159
- const options = {
160
- // width: 720,
161
- pauseAfterCapture: true,
162
- fixOrientation: false,
163
- forceUpOrientation: false,
164
- orientation: RNCamera.Constants.Orientation.portrait,
165
- };
166
- const data = await myCamera.current.takePictureAsync(options);
168
+ const data = await myCamera.current.takePhoto({
169
+ qualityPrioritization: 'quality',
170
+ });
171
+ const uri = 'file://' + data.path;
167
172
  setTaking(false);
168
173
  if (props?.route?.params?.front) {
169
174
  navigation.push(ScreenNames.VehicleRegistration, {
170
- uri: data?.uri,
175
+ uri,
171
176
  loan: props?.route?.params?.loan,
172
177
  });
173
178
  } else if (props.route?.params?.callback) {
174
179
  navigation.goBack();
175
- props.route?.params?.callback(data?.uri);
180
+ props.route?.params?.callback(uri);
176
181
  } else {
177
182
  navigation.push(ScreenNames.RegisterBack, {
178
- uri: data?.uri,
183
+ uri,
179
184
  loan: props?.route?.params?.loan,
180
185
  });
181
186
  }
@@ -278,27 +283,21 @@ export default function RegisterCamera(props: any) {
278
283
  : 'Mặt trước Đăng kiểm xe'}
279
284
  </MText>
280
285
  </View>
281
- <RNCamera
282
- ref={myCamera}
283
- defaultVideoQuality={RNCamera.Constants.VideoQuality['720p']}
284
- style={{
285
- width: Dimensions.get('window').width,
286
- height: (Dimensions.get('window').width * 4) / 3.1,
287
- }}
288
- maxZoom={1}
289
- androidCameraPermissionOptions={{
290
- title: 'Permission to use camera',
291
- message: 'We need your permission to use your camera',
292
- buttonPositive: 'Ok',
293
- buttonNegative: 'Cancel',
294
- }}
295
- quality={0.8}
296
- pictureSize="1280x720"
297
- >
298
- {({ camera, status, recordAudioPermissionStatus }) => {
299
- if (status !== 'READY') return <ActivityIndicator />;
300
- }}
301
- </RNCamera>
286
+ {device ? (
287
+ <VisionCamera
288
+ ref={myCamera}
289
+ style={{
290
+ width: Dimensions.get('window').width,
291
+ height: (Dimensions.get('window').width * 4) / 3.1,
292
+ }}
293
+ device={device}
294
+ isActive={true}
295
+ photo={true}
296
+ format={format}
297
+ />
298
+ ) : (
299
+ <ActivityIndicator />
300
+ )}
302
301
  <View
303
302
  style={{
304
303
  position: 'absolute',
@@ -1,12 +1,6 @@
1
1
  // @ts-nocheck
2
2
  import React, { useEffect, useRef, useState } from 'react';
3
- import {
4
- ActivityIndicator,
5
- Alert,
6
- Dimensions,
7
- Platform,
8
- View,
9
- } from 'react-native';
3
+ import { Alert, Dimensions, Platform, View } from 'react-native';
10
4
  import { useNavigation, useIsFocused } from '@react-navigation/native';
11
5
  import {
12
6
  request,
@@ -14,7 +8,6 @@ import {
14
8
  RESULTS,
15
9
  openSettings,
16
10
  } from 'react-native-permissions';
17
- import { RNCamera } from 'react-native-camera';
18
11
  import { MText } from '../../components/MText';
19
12
  import MButton from '../../components/MButton';
20
13
  import { commonStyles } from '../CommonStyles';
@@ -25,6 +18,11 @@ import { ScreenNames } from '../../navigation';
25
18
  import appStore from '../../AppStore';
26
19
  import { logEvent, logEventFb } from '../../utils';
27
20
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
21
+ import {
22
+ Camera,
23
+ useCameraDevice,
24
+ useCameraFormat,
25
+ } from 'react-native-vision-camera';
28
26
 
29
27
  export default function TTSSelfie(props: any) {
30
28
  const insets = useSafeAreaInsets();
@@ -34,9 +32,13 @@ export default function TTSSelfie(props: any) {
34
32
  const [taking, setTaking] = useState(false);
35
33
  const [isLoading, setIsLoading] = useState(false);
36
34
  const [passPermission, setPassPermission] = useState(false);
37
-
35
+ const device = useCameraDevice('front');
38
36
  const myCamera = useRef(null);
39
37
 
38
+ const format = useCameraFormat(device, [
39
+ { photoResolution: { width: 1280, height: 1280 } },
40
+ ]);
41
+
40
42
  const requestPermissions = () => {
41
43
  request(
42
44
  Platform.OS === 'ios'
@@ -152,25 +154,21 @@ export default function TTSSelfie(props: any) {
152
154
  }, [isFocused]);
153
155
 
154
156
  const takePhoto = async () => {
157
+ if (myCamera.current == null || taking) return;
155
158
  setTaking(true);
156
- const options = {
157
- width: 720,
158
- pauseAfterCapture: true,
159
- fixOrientation: false,
160
- forceUpOrientation: false,
161
- orientation: RNCamera.Constants.Orientation.portrait,
162
- };
163
- const data = await myCamera.current.takePictureAsync(options);
159
+ const data = await myCamera.current.takePhoto({
160
+ qualityPrioritization: 'speed',
161
+ });
164
162
  setTaking(false);
165
- if (data.uri) {
163
+ if (data) {
166
164
  setIsLoading(true);
167
165
  const formData = new FormData();
168
166
  formData.append('LoanBriefId', props?.route?.params?.loan?.id);
169
167
  formData.append('TypeDocumentId', 125); // Anh selfie
170
168
  formData.append('image', {
171
- uri: data.uri,
169
+ uri: 'file://' + data.path,
172
170
  type: 'image/jpg',
173
- name: 'image.jpg',
171
+ name: 'selfie.jpg',
174
172
  });
175
173
  const response = await Api.getInstance().uploadImageAutoDE(formData);
176
174
  setIsLoading(false);
@@ -246,27 +244,18 @@ export default function TTSSelfie(props: any) {
246
244
  Xác thực khuôn mặt
247
245
  </MText>
248
246
  </View>
249
- <RNCamera
250
- ref={myCamera}
251
- defaultVideoQuality={RNCamera.Constants.VideoQuality['720p']}
247
+
248
+ <Camera
252
249
  style={{
253
250
  width: Dimensions.get('window').width,
254
251
  height: (Dimensions.get('window').width * 4) / 3.1,
255
252
  }}
256
- type={RNCamera.Constants.Type.front}
257
- maxZoom={1}
258
- captureAudio={false}
259
- androidCameraPermissionOptions={{
260
- title: 'Permission to use camera',
261
- message: 'We need your permission to use your camera',
262
- buttonPositive: 'Ok',
263
- buttonNegative: 'Cancel',
264
- }}
265
- >
266
- {({ camera, status, recordAudioPermissionStatus }) => {
267
- if (status !== 'READY') return <ActivityIndicator />;
268
- }}
269
- </RNCamera>
253
+ ref={myCamera}
254
+ device={device}
255
+ isActive={true}
256
+ photo={true}
257
+ format={format}
258
+ />
270
259
 
271
260
  <View
272
261
  style={{
@@ -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={{