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
@@ -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
 
@@ -403,91 +397,7 @@ export const OCR = observer(function OCR(props: any) {
403
397
  >
404
398
  <IconBackWhite />
405
399
  </TouchableOpacity>
406
- <View
407
- style={{
408
- flexDirection: 'row',
409
- padding: 2,
410
- borderRadius: 4,
411
- alignItems: 'center',
412
- backgroundColor: 'transparent',
413
- }}
414
- >
415
- {/* <TouchableOpacity
416
- style={{}}
417
- onPress={() => {
418
- setType('passport');
419
- }}
420
- >
421
- <LinearGradient
422
- colors={
423
- type === 'passport'
424
- ? ['#FF8E4F', '#EF592E']
425
- : ['black', 'black']
426
- }
427
- style={{
428
- height: 28,
429
- paddingHorizontal: 8,
430
- borderRadius: 4,
431
- width: 100,
432
- flexDirection: 'row',
433
- alignItems: 'center',
434
- }}
435
- >
436
- <Cam2Svg />
437
- <MText
438
- style={{
439
- color: 'white',
440
- fontSize: 12,
441
- fontWeight: 'bold',
442
- marginLeft: 5,
443
- }}
444
- >
445
- Chụp 2 mặt
446
- </MText>
447
- </LinearGradient>
448
- </TouchableOpacity> */}
449
- {/* <View
450
- style={{
451
- backgroundColor: 'white',
452
- width: 1,
453
- borderRadius: 10,
454
- height: 20,
455
- marginHorizontal: 8,
456
- }}
457
- ></View> */}
458
- {/* <TouchableOpacity
459
- style={{}}
460
- onPress={() => {
461
- setType('nfc');
462
- }}
463
- >
464
- <LinearGradient
465
- colors={
466
- type === 'nfc' ? ['#FF8E4F', '#EF592E'] : ['black', 'black']
467
- }
468
- style={{
469
- height: 28,
470
- paddingHorizontal: 8,
471
- borderRadius: 4,
472
- width: 100,
473
- flexDirection: 'row',
474
- alignItems: 'center',
475
- }}
476
- >
477
- <ChipSvg />
478
- <MText
479
- style={{
480
- color: 'white',
481
- fontSize: 12,
482
- fontWeight: 'bold',
483
- marginLeft: 5,
484
- }}
485
- >
486
- NFC
487
- </MText>
488
- </LinearGradient>
489
- </TouchableOpacity> */}
490
- </View>
400
+
491
401
  <MText
492
402
  style={{
493
403
  color: 'white',
@@ -518,20 +428,20 @@ export const OCR = observer(function OCR(props: any) {
518
428
  },
519
429
  ]}
520
430
  >
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>
431
+ {device ? (
432
+ <View style={styles.passportCameraFrame}>
433
+ <VisionCamera
434
+ ref={myCamera}
435
+ style={StyleSheet.absoluteFill}
436
+ device={device}
437
+ isActive={true}
438
+ photo={true}
439
+ format={format}
440
+ />
441
+ </View>
442
+ ) : (
443
+ <ActivityIndicator />
444
+ )}
535
445
  <TouchableOpacity
536
446
  onPress={() => {
537
447
  pickImageFromGallery();
@@ -539,7 +449,6 @@ export const OCR = observer(function OCR(props: any) {
539
449
  style={{
540
450
  flexDirection: 'row',
541
451
  alignItems: 'center',
542
- gap: 8,
543
452
  marginTop: 16,
544
453
  }}
545
454
  >
@@ -548,13 +457,14 @@ export const OCR = observer(function OCR(props: any) {
548
457
  style={{
549
458
  color: 'white',
550
459
  fontSize: 12,
460
+ marginLeft: 8,
551
461
  }}
552
462
  >
553
463
  Tải ảnh từ thư viện
554
464
  </MText>
555
465
  </TouchableOpacity>
556
466
 
557
- <View style={styles.buttonContainer}>
467
+ <View style={[styles.buttonContainer, { bottom: insets.bottom }]}>
558
468
  <MText
559
469
  style={{
560
470
  color: 'white',
@@ -577,12 +487,16 @@ export const OCR = observer(function OCR(props: any) {
577
487
  </View>
578
488
  ) : passPermission && type === 'nfc' && shouldRenderCamera ? (
579
489
  <>
580
- <RNCamera
581
- ref={myCamera}
582
- style={styles.camera}
583
- type={RNCamera.Constants.Type.back}
584
- captureAudio={false}
585
- ></RNCamera>
490
+ {device ? (
491
+ <VisionCamera
492
+ ref={myCamera}
493
+ style={styles.camera}
494
+ device={device}
495
+ isActive={true}
496
+ photo={true}
497
+ format={format}
498
+ />
499
+ ) : null}
586
500
  <View style={styles.overlay}>
587
501
  <View style={styles.overlayTop} />
588
502
  <View style={styles.overlayCenter}>
@@ -592,7 +506,9 @@ export const OCR = observer(function OCR(props: any) {
592
506
  </View>
593
507
  <View style={styles.overlayBottom} />
594
508
  </View>
595
- <View style={styles.buttonContainer}>
509
+ <View
510
+ style={[styles.buttonContainer, { bottom: insets.bottom + 24 }]}
511
+ >
596
512
  <MText
597
513
  style={{
598
514
  color: 'white',
@@ -881,13 +797,18 @@ const styles = StyleSheet.create({
881
797
  camera: {
882
798
  flex: 1,
883
799
  },
800
+ passportCameraFrame: {
801
+ width: Dimensions.get('window').width,
802
+ height: 260,
803
+ overflow: 'hidden',
804
+ backgroundColor: 'black',
805
+ },
884
806
  buttonContainer: {
885
807
  flex: 0,
886
808
  flexDirection: 'column',
887
809
  justifyContent: 'center',
888
810
  alignItems: 'center',
889
811
  position: 'absolute',
890
- bottom: 40,
891
812
  left: 0,
892
813
  right: 0,
893
814
  zIndex: 1000,
@@ -2,15 +2,16 @@
2
2
  import React, { useEffect, useRef, useState } from 'react';
3
3
  import {
4
4
  ActivityIndicator,
5
- Dimensions,
6
5
  Image,
7
6
  ImageStyle,
8
7
  Platform,
8
+ StyleSheet,
9
9
  TextStyle,
10
10
  TouchableOpacity,
11
11
  View,
12
12
  ViewStyle,
13
13
  Alert,
14
+ useWindowDimensions,
14
15
  } from 'react-native';
15
16
  import { useNavigation, useIsFocused } from '@react-navigation/native';
16
17
  import {
@@ -19,7 +20,11 @@ import {
19
20
  RESULTS,
20
21
  openSettings,
21
22
  } from 'react-native-permissions';
22
- import { RNCamera } from 'react-native-camera';
23
+ import {
24
+ Camera as VisionCamera,
25
+ useCameraDevice,
26
+ useCameraFormat,
27
+ } from 'react-native-vision-camera';
23
28
  import Modal from 'react-native-modal';
24
29
  import { MText } from '../../components/MText';
25
30
  import LinearGradient from 'react-native-linear-gradient';
@@ -37,6 +42,8 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
37
42
  export default function RegisterCamera(props: any) {
38
43
  const insets = useSafeAreaInsets();
39
44
  const isFocused = useIsFocused();
45
+ const { width: screenWidth, height: screenHeight } = useWindowDimensions();
46
+ const cameraHeight = (screenWidth * 4) / 3.1;
40
47
  const [shouldRenderCamera, setShouldRenderCamera] = useState(false);
41
48
  const navigation = useNavigation();
42
49
  const [showModal, setShowModal] = useState(false);
@@ -44,6 +51,10 @@ export default function RegisterCamera(props: any) {
44
51
  const [passPermission, setPassPermission] = useState(false);
45
52
 
46
53
  const myCamera = useRef(null);
54
+ const device = useCameraDevice('back');
55
+ const format = useCameraFormat(device, [
56
+ { photoResolution: { width: 1280, height: 720 } },
57
+ ]);
47
58
 
48
59
  const requestPermissions = () => {
49
60
  request(
@@ -155,27 +166,24 @@ export default function RegisterCamera(props: any) {
155
166
  }, [isFocused]);
156
167
 
157
168
  const takePhoto = async () => {
169
+ if (myCamera.current == null || taking) return;
158
170
  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);
171
+ const data = await myCamera.current.takePhoto({
172
+ qualityPrioritization: 'quality',
173
+ });
174
+ const uri = 'file://' + data.path;
167
175
  setTaking(false);
168
176
  if (props?.route?.params?.front) {
169
177
  navigation.push(ScreenNames.VehicleRegistration, {
170
- uri: data?.uri,
178
+ uri,
171
179
  loan: props?.route?.params?.loan,
172
180
  });
173
181
  } else if (props.route?.params?.callback) {
174
182
  navigation.goBack();
175
- props.route?.params?.callback(data?.uri);
183
+ props.route?.params?.callback(uri);
176
184
  } else {
177
185
  navigation.push(ScreenNames.RegisterBack, {
178
- uri: data?.uri,
186
+ uri,
179
187
  loan: props?.route?.params?.loan,
180
188
  });
181
189
  }
@@ -235,28 +243,18 @@ export default function RegisterCamera(props: any) {
235
243
  style={[
236
244
  commonStyles.fill,
237
245
  {
238
- width: Dimensions.get('window').width,
239
- height: Dimensions.get('window').height,
240
- // alignItems: 'center',
246
+ width: screenWidth,
247
+ height: screenHeight,
241
248
  zIndex: 1000,
242
249
  },
243
250
  ]}
244
251
  >
245
- <View
246
- style={{
247
- marginVertical: 16,
248
- marginTop: insets.top + 16,
249
- }}
250
- >
252
+ <View style={[styles.header, { paddingTop: insets.top + 16 }]}>
251
253
  <TouchableOpacity
252
254
  onPress={() => {
253
255
  navigation.goBack();
254
256
  }}
255
- style={{
256
- position: 'absolute',
257
- left: 16,
258
- zIndex: 100000,
259
- }}
257
+ style={[styles.backButton, { top: insets.top + 16 }]}
260
258
  >
261
259
  <MText
262
260
  style={{
@@ -278,27 +276,29 @@ export default function RegisterCamera(props: any) {
278
276
  : 'Mặt trước Đăng kiểm xe'}
279
277
  </MText>
280
278
  </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>
279
+ {device ? (
280
+ <View
281
+ style={[
282
+ styles.cameraFrame,
283
+ {
284
+ width: screenWidth,
285
+ height: cameraHeight,
286
+ marginTop: insets.top + 64,
287
+ },
288
+ ]}
289
+ >
290
+ <VisionCamera
291
+ ref={myCamera}
292
+ style={StyleSheet.absoluteFill}
293
+ device={device}
294
+ isActive={true}
295
+ photo={true}
296
+ format={format}
297
+ />
298
+ </View>
299
+ ) : (
300
+ <ActivityIndicator />
301
+ )}
302
302
  <View
303
303
  style={{
304
304
  position: 'absolute',
@@ -317,7 +317,6 @@ export default function RegisterCamera(props: any) {
317
317
  style={{
318
318
  flexDirection: 'row',
319
319
  alignItems: 'center',
320
- gap: 8,
321
320
  }}
322
321
  >
323
322
  <IconUpload />
@@ -325,6 +324,7 @@ export default function RegisterCamera(props: any) {
325
324
  style={{
326
325
  color: 'white',
327
326
  fontSize: 12,
327
+ marginLeft: 8,
328
328
  }}
329
329
  >
330
330
  Tải ảnh từ thư viện
@@ -344,7 +344,7 @@ export default function RegisterCamera(props: any) {
344
344
  <View
345
345
  style={{
346
346
  alignItems: 'center',
347
- marginVertical: DeviceInfo.hasNotch() ? 24 : 16,
347
+ marginTop: 16,
348
348
  }}
349
349
  >
350
350
  <MButton
@@ -552,3 +552,23 @@ const $container: ViewStyle = {
552
552
  borderTopRightRadius: 26,
553
553
  borderTopLeftRadius: 26,
554
554
  };
555
+
556
+ const styles = StyleSheet.create({
557
+ header: {
558
+ position: 'absolute',
559
+ top: 0,
560
+ left: 0,
561
+ right: 0,
562
+ zIndex: 10,
563
+ paddingBottom: 16,
564
+ },
565
+ backButton: {
566
+ position: 'absolute',
567
+ left: 16,
568
+ zIndex: 100000,
569
+ },
570
+ cameraFrame: {
571
+ overflow: 'hidden',
572
+ backgroundColor: 'black',
573
+ },
574
+ });
@@ -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={{