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.
- package/lib/commonjs/screens/camera/CCCDCameraScreen.js +1 -1
- package/lib/commonjs/screens/camera/CCCDCameraScreen.js.flow +29 -26
- package/lib/commonjs/screens/camera/CCCDCameraScreen.js.map +1 -1
- package/lib/commonjs/screens/camera/index.js +1 -1
- package/lib/commonjs/screens/camera/index.js.flow +34 -48
- package/lib/commonjs/screens/camera/index.js.map +1 -1
- package/lib/commonjs/screens/home/DigitalTopupItem.js +1 -1
- package/lib/commonjs/screens/home/DigitalTopupItem.js.flow +31 -33
- package/lib/commonjs/screens/home/DigitalTopupItem.js.map +1 -1
- package/lib/commonjs/screens/home/ItemMotoBikeLoan.js +1 -1
- package/lib/commonjs/screens/home/ItemMotoBikeLoan.js.flow +44 -4
- package/lib/commonjs/screens/home/ItemMotoBikeLoan.js.map +1 -1
- package/lib/commonjs/screens/liveness/index.js +1 -1
- package/lib/commonjs/screens/liveness/index.js.flow +43 -54
- package/lib/commonjs/screens/liveness/index.js.map +1 -1
- package/lib/commonjs/screens/liveness-v2/index.js +1 -1
- package/lib/commonjs/screens/liveness-v2/index.js.flow +60 -56
- package/lib/commonjs/screens/liveness-v2/index.js.map +1 -1
- package/lib/commonjs/screens/mrz-scanner/index.js +1 -1
- package/lib/commonjs/screens/mrz-scanner/index.js.flow +25 -10
- package/lib/commonjs/screens/mrz-scanner/index.js.map +1 -1
- package/lib/commonjs/screens/toan-trinh-so/OCR.js +1 -1
- package/lib/commonjs/screens/toan-trinh-so/OCR.js.flow +48 -49
- package/lib/commonjs/screens/toan-trinh-so/OCR.js.map +1 -1
- package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js +1 -1
- package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js.flow +32 -33
- package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js.map +1 -1
- package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js +1 -1
- package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.flow +26 -37
- package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
- package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js +1 -1
- package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.flow +77 -78
- package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
- package/lib/commonjs/screens/uploadVideo/index.js +1 -1
- package/lib/commonjs/screens/uploadVideo/index.js.flow +32 -33
- package/lib/commonjs/screens/uploadVideo/index.js.map +1 -1
- package/lib/module/screens/camera/CCCDCameraScreen.js +1 -1
- package/lib/module/screens/camera/CCCDCameraScreen.js.map +1 -1
- package/lib/module/screens/camera/index.js +1 -1
- package/lib/module/screens/camera/index.js.map +1 -1
- package/lib/module/screens/home/DigitalTopupItem.js +1 -1
- package/lib/module/screens/home/DigitalTopupItem.js.map +1 -1
- package/lib/module/screens/home/ItemMotoBikeLoan.js +1 -1
- package/lib/module/screens/home/ItemMotoBikeLoan.js.map +1 -1
- package/lib/module/screens/liveness/index.js +1 -1
- package/lib/module/screens/liveness/index.js.map +1 -1
- package/lib/module/screens/liveness-v2/index.js +1 -1
- package/lib/module/screens/liveness-v2/index.js.map +1 -1
- package/lib/module/screens/mrz-scanner/index.js +1 -1
- package/lib/module/screens/mrz-scanner/index.js.map +1 -1
- package/lib/module/screens/toan-trinh-so/OCR.js +1 -1
- package/lib/module/screens/toan-trinh-so/OCR.js.map +1 -1
- package/lib/module/screens/toan-trinh-so/RegisterCamera.js +1 -1
- package/lib/module/screens/toan-trinh-so/RegisterCamera.js.map +1 -1
- package/lib/module/screens/toan-trinh-so/TTSSelfie.js +1 -1
- package/lib/module/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
- package/lib/module/screens/toan-trinh-so/VehicleCamera.js +1 -1
- package/lib/module/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
- package/lib/module/screens/uploadVideo/index.js +1 -1
- package/lib/module/screens/uploadVideo/index.js.map +1 -1
- package/lib/typescript/screens/camera/CCCDCameraScreen.d.ts.map +1 -1
- package/lib/typescript/screens/camera/index.d.ts.map +1 -1
- package/lib/typescript/screens/home/DigitalTopupItem.d.ts.map +1 -1
- package/lib/typescript/screens/home/ItemMotoBikeLoan.d.ts.map +1 -1
- package/lib/typescript/screens/liveness/index.d.ts.map +1 -1
- package/lib/typescript/screens/liveness-v2/index.d.ts.map +1 -1
- package/lib/typescript/screens/mrz-scanner/index.d.ts.map +1 -1
- package/lib/typescript/screens/toan-trinh-so/OCR.d.ts.map +1 -1
- package/lib/typescript/screens/toan-trinh-so/RegisterCamera.d.ts.map +1 -1
- package/lib/typescript/screens/toan-trinh-so/TTSSelfie.d.ts.map +1 -1
- package/lib/typescript/screens/toan-trinh-so/VehicleCamera.d.ts.map +1 -1
- package/lib/typescript/screens/uploadVideo/index.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/screens/camera/CCCDCameraScreen.tsx +29 -26
- package/src/screens/camera/index.tsx +34 -48
- package/src/screens/home/DigitalTopupItem.tsx +31 -33
- package/src/screens/home/ItemMotoBikeLoan.tsx +44 -4
- package/src/screens/liveness/index.tsx +43 -54
- package/src/screens/liveness-v2/index.tsx +60 -56
- package/src/screens/mrz-scanner/index.tsx +25 -10
- package/src/screens/toan-trinh-so/OCR.tsx +48 -49
- package/src/screens/toan-trinh-so/RegisterCamera.tsx +32 -33
- package/src/screens/toan-trinh-so/TTSSelfie.tsx +26 -37
- package/src/screens/toan-trinh-so/VehicleCamera.tsx +77 -78
- 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 {
|
|
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
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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 {
|
|
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
|
|
289
|
-
|
|
290
|
-
|
|
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
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
|
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
|
|
309
|
+
uri,
|
|
316
310
|
loan: props?.route?.params?.loan,
|
|
317
311
|
});
|
|
318
312
|
} else {
|
|
319
313
|
navigation.goBack();
|
|
320
|
-
props.route?.params?.callback(
|
|
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
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
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
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
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 {
|
|
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
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
|
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(
|
|
180
|
+
props.route?.params?.callback(uri);
|
|
176
181
|
} else {
|
|
177
182
|
navigation.push(ScreenNames.RegisterBack, {
|
|
178
|
-
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
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
|
157
|
-
|
|
158
|
-
|
|
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
|
|
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.
|
|
169
|
+
uri: 'file://' + data.path,
|
|
172
170
|
type: 'image/jpg',
|
|
173
|
-
name: '
|
|
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
|
-
|
|
250
|
-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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 {
|
|
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
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
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(
|
|
91
|
+
props.route?.params?.callback(uri);
|
|
88
92
|
} else {
|
|
89
93
|
navigation.push(ScreenNames.VehicleRegistrationBack, {
|
|
90
|
-
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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={$
|
|
322
|
+
<View style={$darkOverlaySide} />
|
|
325
323
|
</View>
|
|
326
|
-
|
|
324
|
+
<View style={$darkOverlayBottom} />
|
|
325
|
+
</View>
|
|
327
326
|
|
|
328
327
|
<View
|
|
329
328
|
style={{
|