@trustchex/react-native-sdk 1.355.1 → 1.357.0
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/README.md +2 -9
- package/TrustchexSDK.podspec +5 -4
- package/android/build.gradle +6 -4
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKPackage.kt +45 -25
- package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraManager.kt +168 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraView.kt +871 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mlkit/MLKitModule.kt +245 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidationModule.kt +785 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidator.kt +419 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/opencv/OpenCVModule.kt +818 -0
- package/ios/Camera/TrustchexCameraManager.m +37 -0
- package/ios/Camera/TrustchexCameraManager.swift +125 -0
- package/ios/Camera/TrustchexCameraView.swift +1176 -0
- package/ios/MLKit/MLKitModule.m +23 -0
- package/ios/MLKit/MLKitModule.swift +250 -0
- package/ios/MRZValidation.m +39 -0
- package/ios/MRZValidation.swift +802 -0
- package/ios/MRZValidator.swift +466 -0
- package/ios/OpenCV/OpenCVModule.h +4 -0
- package/ios/OpenCV/OpenCVModule.mm +810 -0
- package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +2 -3
- package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +1 -2
- package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +418 -193
- package/lib/module/Screens/Static/OTPVerificationScreen.js +11 -11
- package/lib/module/Screens/Static/QrCodeScanningScreen.js +5 -1
- package/lib/module/Screens/Static/ResultScreen.js +25 -2
- package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +25 -7
- package/lib/module/Shared/Components/DebugNavigationPanel.js +234 -24
- package/lib/module/Shared/Components/EIDScanner.js +99 -9
- package/lib/module/Shared/Components/FaceCamera.js +170 -179
- package/lib/module/Shared/Components/IdentityDocumentCamera.js +2151 -771
- package/lib/module/Shared/Components/QrCodeScannerCamera.js +109 -107
- package/lib/module/Shared/Components/TrustchexCamera.js +122 -0
- package/lib/module/Shared/EIDReader/tlv/tlv.helpers.js +91 -0
- package/lib/module/Shared/EIDReader/tlv/tlv.utils.js +2 -124
- package/lib/module/Shared/EIDReader/tlv/tlvInputStream.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputState.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputStream.js +4 -4
- package/lib/module/Shared/Libs/analytics.utils.js +2 -2
- package/lib/module/Shared/Libs/debug.utils.js +132 -0
- package/lib/module/Shared/Libs/deeplink.utils.js +6 -5
- package/lib/module/Shared/Libs/demo.utils.js +13 -3
- package/lib/module/Shared/Libs/mrz.utils.js +1 -175
- package/lib/module/Shared/Libs/native-device-info.utils.js +12 -6
- package/lib/module/Shared/Libs/tts.utils.js +40 -6
- package/lib/module/Shared/Services/AnalyticsService.js +9 -8
- package/lib/module/Shared/Types/mrzFields.js +1 -0
- package/lib/module/Translation/Resources/en.js +87 -88
- package/lib/module/Translation/Resources/tr.js +84 -85
- package/lib/module/Trustchex.js +9 -2
- package/lib/module/index.js +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/OTPVerificationScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/DebugNavigationPanel.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/EIDScanner.d.ts +2 -2
- package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/FaceCamera.d.ts +18 -4
- package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts +3 -4
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts +2 -1
- package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts +124 -0
- package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts +11 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts +2 -39
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/debug.utils.d.ts +42 -0
- package/lib/typescript/src/Shared/Libs/debug.utils.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/demo.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/http-client.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts +0 -4
- package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/native-device-info.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/tts.utils.d.ts +4 -3
- package/lib/typescript/src/Shared/Libs/tts.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Types/identificationInfo.d.ts +2 -2
- package/lib/typescript/src/Shared/Types/identificationInfo.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Types/mrzFields.d.ts +11 -0
- package/lib/typescript/src/Shared/Types/mrzFields.d.ts.map +1 -0
- package/lib/typescript/src/Translation/Resources/en.d.ts +4 -5
- package/lib/typescript/src/Translation/Resources/en.d.ts.map +1 -1
- package/lib/typescript/src/Translation/Resources/tr.d.ts +4 -5
- package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
- package/lib/typescript/src/Trustchex.d.ts +2 -0
- package/lib/typescript/src/Trustchex.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +4 -35
- package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +1 -1
- package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +7 -5
- package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +2 -3
- package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +498 -216
- package/src/Screens/Static/OTPVerificationScreen.tsx +37 -31
- package/src/Screens/Static/QrCodeScanningScreen.tsx +8 -1
- package/src/Screens/Static/ResultScreen.tsx +136 -88
- package/src/Screens/Static/VerificationSessionCheckScreen.tsx +46 -13
- package/src/Shared/Components/DebugNavigationPanel.tsx +290 -34
- package/src/Shared/Components/EIDScanner.tsx +94 -16
- package/src/Shared/Components/FaceCamera.tsx +236 -203
- package/src/Shared/Components/IdentityDocumentCamera.tsx +3073 -1030
- package/src/Shared/Components/QrCodeScannerCamera.tsx +133 -127
- package/src/Shared/Components/TrustchexCamera.tsx +289 -0
- package/src/Shared/Config/camera-enhancement.config.ts +2 -2
- package/src/Shared/EIDReader/tlv/tlv.helpers.ts +96 -0
- package/src/Shared/EIDReader/tlv/tlv.utils.ts +2 -125
- package/src/Shared/EIDReader/tlv/tlvInputStream.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputState.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputStream.ts +4 -4
- package/src/Shared/Libs/analytics.utils.ts +48 -20
- package/src/Shared/Libs/debug.utils.ts +149 -0
- package/src/Shared/Libs/deeplink.utils.ts +7 -5
- package/src/Shared/Libs/demo.utils.ts +4 -0
- package/src/Shared/Libs/http-client.ts +12 -8
- package/src/Shared/Libs/mrz.utils.ts +1 -163
- package/src/Shared/Libs/native-device-info.utils.ts +12 -6
- package/src/Shared/Libs/tts.utils.ts +48 -6
- package/src/Shared/Services/AnalyticsService.ts +69 -24
- package/src/Shared/Types/identificationInfo.ts +2 -2
- package/src/Shared/Types/mrzFields.ts +29 -0
- package/src/Translation/Resources/en.ts +90 -100
- package/src/Translation/Resources/tr.ts +89 -97
- package/src/Translation/index.ts +1 -1
- package/src/Trustchex.tsx +21 -4
- package/src/index.tsx +14 -0
- package/src/version.ts +1 -1
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/barcodescanner/BarcodeScannerFrameProcessorPlugin.kt +0 -301
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/BitmapUtils.kt +0 -205
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/CropperPlugin.kt +0 -72
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/FrameMetadata.kt +0 -4
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/facedetector/FaceDetectorFrameProcessorPlugin.kt +0 -303
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/textrecognition/TextRecognitionFrameProcessorPlugin.kt +0 -115
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin-Bridging-Header.h +0 -9
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.mm +0 -22
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.swift +0 -188
- package/ios/VisionCameraPlugins/Cropper/Cropper-Bridging-Header.h +0 -13
- package/ios/VisionCameraPlugins/Cropper/Cropper.h +0 -20
- package/ios/VisionCameraPlugins/Cropper/Cropper.mm +0 -22
- package/ios/VisionCameraPlugins/Cropper/Cropper.swift +0 -145
- package/ios/VisionCameraPlugins/Cropper/CropperUtils.swift +0 -49
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin-Bridging-Header.h +0 -4
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.mm +0 -22
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.swift +0 -320
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin-Bridging-Header.h +0 -4
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.mm +0 -27
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.swift +0 -144
- package/lib/module/Shared/Libs/camera.utils.js +0 -308
- package/lib/module/Shared/Libs/frame-enhancement.utils.js +0 -133
- package/lib/module/Shared/Libs/opencv.utils.js +0 -21
- package/lib/module/Shared/Libs/worklet.utils.js +0 -68
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.js +0 -46
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.js +0 -35
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/index.js +0 -19
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.js +0 -26
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/types.js +0 -3
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.js +0 -197
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.js +0 -101
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.js +0 -60
- package/lib/module/Shared/VisionCameraPlugins/Cropper/index.js +0 -47
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/Camera.js +0 -42
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/detectFaces.js +0 -35
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/index.js +0 -4
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/types.js +0 -3
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/Camera.js +0 -56
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.js +0 -20
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.js +0 -9
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/index.js +0 -6
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/scanText.js +0 -20
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/translateText.js +0 -19
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/types.js +0 -3
- package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +0 -87
- package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts +0 -25
- package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts +0 -3
- package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts +0 -9
- package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts +0 -13
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts +0 -6
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts +0 -12
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts +0 -52
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts +0 -62
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts +0 -34
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts +0 -32
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts +0 -23
- package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts +0 -9
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts +0 -79
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts +0 -6
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts +0 -5
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts +0 -67
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts.map +0 -1
- package/src/Shared/Libs/camera.utils.ts +0 -345
- package/src/Shared/Libs/frame-enhancement.utils.ts +0 -217
- package/src/Shared/Libs/opencv.utils.ts +0 -40
- package/src/Shared/Libs/worklet.utils.ts +0 -72
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.ts +0 -79
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.ts +0 -46
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts +0 -60
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts +0 -32
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/types.ts +0 -82
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.ts +0 -195
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.ts +0 -135
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.ts +0 -84
- package/src/Shared/VisionCameraPlugins/Cropper/index.ts +0 -78
- package/src/Shared/VisionCameraPlugins/FaceDetector/Camera.tsx +0 -63
- package/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.ts +0 -44
- package/src/Shared/VisionCameraPlugins/FaceDetector/index.ts +0 -3
- package/src/Shared/VisionCameraPlugins/FaceDetector/types.ts +0 -99
- package/src/Shared/VisionCameraPlugins/TextRecognition/Camera.tsx +0 -76
- package/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.ts +0 -18
- package/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.ts +0 -7
- package/src/Shared/VisionCameraPlugins/TextRecognition/index.ts +0 -7
- package/src/Shared/VisionCameraPlugins/TextRecognition/scanText.ts +0 -27
- package/src/Shared/VisionCameraPlugins/TextRecognition/translateText.ts +0 -21
- package/src/Shared/VisionCameraPlugins/TextRecognition/types.ts +0 -141
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useCallback, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
View,
|
|
4
4
|
StyleSheet,
|
|
@@ -7,152 +7,144 @@ import {
|
|
|
7
7
|
Text,
|
|
8
8
|
Linking,
|
|
9
9
|
Platform,
|
|
10
|
+
PermissionsAndroid,
|
|
11
|
+
TouchableOpacity,
|
|
12
|
+
type NativeSyntheticEvent,
|
|
10
13
|
} from 'react-native';
|
|
11
14
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
useFrameProcessor,
|
|
17
|
-
type Orientation,
|
|
18
|
-
} from 'react-native-vision-camera';
|
|
19
|
-
import { useRunOnJS, useSharedValue } from 'react-native-worklets-core';
|
|
15
|
+
TrustchexCamera,
|
|
16
|
+
type TrustchexCameraHandle,
|
|
17
|
+
type Frame,
|
|
18
|
+
} from './TrustchexCamera';
|
|
20
19
|
import { useKeepAwake } from '../Libs/native-keep-awake.utils';
|
|
21
20
|
import { useIsFocused } from '@react-navigation/native';
|
|
22
21
|
import { useTranslation } from 'react-i18next';
|
|
22
|
+
import { debugLog, logError } from '../Libs/debug.utils';
|
|
23
23
|
import LottieView from 'lottie-react-native';
|
|
24
|
-
import { type Barcode, scanCodes } from '../VisionCameraPlugins/BarcodeScanner';
|
|
25
24
|
import StyledButton from './StyledButton';
|
|
26
25
|
import { useTheme } from '../Contexts/ThemeContext';
|
|
26
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
27
27
|
|
|
28
28
|
export interface QrCodeScannerCameraProps {
|
|
29
29
|
onQrCodeScanned: (data: string) => void;
|
|
30
|
+
onClose?: () => void;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
const QrCodeScannerCamera = ({
|
|
33
|
+
const QrCodeScannerCamera = ({
|
|
34
|
+
onQrCodeScanned,
|
|
35
|
+
onClose,
|
|
36
|
+
}: QrCodeScannerCameraProps) => {
|
|
33
37
|
useKeepAwake();
|
|
34
38
|
const theme = useTheme();
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const [
|
|
39
|
+
const insets = useSafeAreaInsets();
|
|
40
|
+
const cameraRef = useRef<TrustchexCameraHandle>(null);
|
|
41
|
+
const [hasPermission, setHasPermission] = useState(false);
|
|
42
|
+
const [permissionsRequested, setPermissionsRequested] = useState(false);
|
|
43
|
+
const [isActive, setIsActive] = useState(false);
|
|
38
44
|
const isFocused = useIsFocused();
|
|
39
|
-
const device = useCameraDevice('back', {
|
|
40
|
-
physicalDevices: ['wide-angle-camera'],
|
|
41
|
-
});
|
|
42
|
-
const format = useCameraFormat(device, [
|
|
43
|
-
{
|
|
44
|
-
videoResolution: {
|
|
45
|
-
width: 1920,
|
|
46
|
-
height: 1080,
|
|
47
|
-
},
|
|
48
|
-
iso: 'max',
|
|
49
|
-
photoHdr: false,
|
|
50
|
-
videoHdr: false,
|
|
51
|
-
},
|
|
52
|
-
]);
|
|
53
|
-
const isCameraInitialized = useSharedValue(false);
|
|
54
45
|
const { t } = useTranslation();
|
|
46
|
+
const lastScanTime = useRef(0);
|
|
47
|
+
const hasScanned = useRef(false);
|
|
55
48
|
|
|
56
49
|
const isInScanningFrame = (
|
|
57
|
-
|
|
50
|
+
boundingBox: { left: number; top: number; right: number; bottom: number },
|
|
58
51
|
width: number,
|
|
59
|
-
height: number
|
|
60
|
-
orientation: Orientation
|
|
52
|
+
height: number
|
|
61
53
|
) => {
|
|
54
|
+
// Match UI scanArea: top: '35%', left: '3%', right: '3%', bottom: '35%'
|
|
55
|
+
// Add 2% margin buffer to ensure code is comfortably inside frame
|
|
56
|
+
const marginBuffer = 0.02;
|
|
62
57
|
const scanningFrame = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
left: width * (0.03 + marginBuffer),
|
|
59
|
+
top: height * (0.35 + marginBuffer),
|
|
60
|
+
right: width * (0.97 - marginBuffer),
|
|
61
|
+
bottom: height * (0.65 - marginBuffer),
|
|
67
62
|
};
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
64
|
+
console.log(
|
|
65
|
+
`[QR Frame Check] Frame: ${width}x${height}, Scanning: left=${scanningFrame.left}, top=${scanningFrame.top}, right=${scanningFrame.right}, bottom=${scanningFrame.bottom}`
|
|
66
|
+
);
|
|
67
|
+
console.log(
|
|
68
|
+
`[QR Frame Check] Code bbox: left=${boundingBox.left}, top=${boundingBox.top}, right=${boundingBox.right}, bottom=${boundingBox.bottom}`
|
|
69
|
+
);
|
|
76
70
|
|
|
77
|
-
//
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const codeY = boundingBox.origin.y;
|
|
84
|
-
const codeWidth = boundingBox.size.width;
|
|
85
|
-
const codeHeight = boundingBox.size.height;
|
|
86
|
-
const codeRight = codeX + codeWidth;
|
|
87
|
-
const codeBottom = codeY + codeHeight;
|
|
88
|
-
const frameRight = scanningFrame.x + scanningFrame.width;
|
|
89
|
-
const frameBottom = scanningFrame.y + scanningFrame.height;
|
|
71
|
+
// Check if entire bounding box is within scanning frame (with margin buffer)
|
|
72
|
+
const isInFrame =
|
|
73
|
+
boundingBox.left >= scanningFrame.left &&
|
|
74
|
+
boundingBox.top >= scanningFrame.top &&
|
|
75
|
+
boundingBox.right <= scanningFrame.right &&
|
|
76
|
+
boundingBox.bottom <= scanningFrame.bottom;
|
|
90
77
|
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
codeX >= scanningFrame.x &&
|
|
94
|
-
codeY >= scanningFrame.y &&
|
|
95
|
-
codeRight <= frameRight &&
|
|
96
|
-
codeBottom <= frameBottom
|
|
97
|
-
) {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
78
|
+
console.log(`[QR Frame Check] Is in frame: ${isInFrame}`);
|
|
100
79
|
|
|
101
|
-
return
|
|
80
|
+
return isInFrame;
|
|
102
81
|
};
|
|
103
82
|
|
|
104
|
-
const
|
|
105
|
-
(
|
|
106
|
-
|
|
107
|
-
width: number,
|
|
108
|
-
height: number,
|
|
109
|
-
orientation: Orientation
|
|
110
|
-
) => {
|
|
111
|
-
// TODO: Fix iOS coordinates - iOS coordinate system conversion may be incorrect
|
|
112
|
-
// causing frame checking to fail. Need to verify coordinate normalization
|
|
113
|
-
// between iOS Vision framework and React Native coordinate systems.
|
|
83
|
+
const handleFrame = useCallback(
|
|
84
|
+
async (event: NativeSyntheticEvent<{ frame: Frame }>) => {
|
|
85
|
+
if (hasScanned.current) return;
|
|
114
86
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
87
|
+
const now = Date.now();
|
|
88
|
+
// Throttle to ~3 FPS for QR scanning
|
|
89
|
+
if (now - lastScanTime.current < 333) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
lastScanTime.current = now;
|
|
93
|
+
|
|
94
|
+
const { frame } = event.nativeEvent;
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
// Barcodes are already detected natively — read directly from frame
|
|
98
|
+
const barcodes = frame.barcodes;
|
|
99
|
+
if (!barcodes || barcodes.length !== 1) return;
|
|
100
|
+
|
|
101
|
+
const code = barcodes[0];
|
|
102
|
+
|
|
103
|
+
// Use frame checking on both platforms for consistent behavior
|
|
104
|
+
if (
|
|
105
|
+
code.boundingBox &&
|
|
106
|
+
isInScanningFrame(code.boundingBox, frame.width, frame.height) &&
|
|
107
|
+
code.rawValue
|
|
108
|
+
) {
|
|
109
|
+
hasScanned.current = true;
|
|
110
|
+
onQrCodeScanned(code.rawValue);
|
|
124
111
|
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
logError('[QrCodeScannerCamera] Error processing frame:', error);
|
|
125
114
|
}
|
|
126
115
|
},
|
|
127
116
|
[onQrCodeScanned]
|
|
128
117
|
);
|
|
129
118
|
|
|
130
|
-
const
|
|
131
|
-
'
|
|
132
|
-
|
|
133
|
-
if (!isCameraInitialized.value) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const codes = scanCodes(frame, { barcodeTypes: ['qr'] });
|
|
138
|
-
|
|
139
|
-
if (codes && codes.length === 1) {
|
|
140
|
-
handleQrCode(codes[0], frame.width, frame.height, frame.orientation);
|
|
141
|
-
}
|
|
119
|
+
const handleCameraReady = useCallback(() => {
|
|
120
|
+
debugLog('QrCodeScannerCamera', '[QrCodeScannerCamera] Camera ready');
|
|
142
121
|
}, []);
|
|
143
122
|
|
|
123
|
+
const handleCameraError = useCallback(
|
|
124
|
+
(event: NativeSyntheticEvent<{ error: string }>) => {
|
|
125
|
+
logError('[QrCodeScannerCamera] Camera error:', event.nativeEvent.error);
|
|
126
|
+
},
|
|
127
|
+
[]
|
|
128
|
+
);
|
|
129
|
+
|
|
144
130
|
useEffect(() => {
|
|
145
131
|
const requestPermissions = async () => {
|
|
146
|
-
if (
|
|
147
|
-
await
|
|
132
|
+
if (Platform.OS === 'android') {
|
|
133
|
+
const granted = await PermissionsAndroid.request(
|
|
134
|
+
PermissionsAndroid.PERMISSIONS.CAMERA
|
|
135
|
+
);
|
|
136
|
+
setHasPermission(granted === PermissionsAndroid.RESULTS.GRANTED);
|
|
137
|
+
} else {
|
|
138
|
+
// iOS permissions handled by native camera
|
|
139
|
+
setHasPermission(true);
|
|
148
140
|
}
|
|
149
141
|
setPermissionsRequested(true);
|
|
150
142
|
};
|
|
151
143
|
requestPermissions();
|
|
152
|
-
}, [
|
|
144
|
+
}, []);
|
|
153
145
|
|
|
154
146
|
useEffect(() => {
|
|
155
|
-
if (
|
|
147
|
+
if (isFocused && hasPermission) {
|
|
156
148
|
setIsActive(true);
|
|
157
149
|
} else {
|
|
158
150
|
setIsActive(false);
|
|
@@ -161,7 +153,7 @@ const QrCodeScannerCamera = ({ onQrCodeScanned }: QrCodeScannerCameraProps) => {
|
|
|
161
153
|
return () => {
|
|
162
154
|
setIsActive(false);
|
|
163
155
|
};
|
|
164
|
-
}, [
|
|
156
|
+
}, [isFocused, hasPermission]);
|
|
165
157
|
|
|
166
158
|
if (!permissionsRequested) {
|
|
167
159
|
return (
|
|
@@ -171,8 +163,7 @@ const QrCodeScannerCamera = ({ onQrCodeScanned }: QrCodeScannerCameraProps) => {
|
|
|
171
163
|
);
|
|
172
164
|
}
|
|
173
165
|
|
|
174
|
-
if (!
|
|
175
|
-
// Camera permission denied by user - their choice, not actionable
|
|
166
|
+
if (!hasPermission) {
|
|
176
167
|
return (
|
|
177
168
|
<View style={styles.permissionContainer}>
|
|
178
169
|
<Text style={styles.permissionText}>
|
|
@@ -190,32 +181,18 @@ const QrCodeScannerCamera = ({ onQrCodeScanned }: QrCodeScannerCameraProps) => {
|
|
|
190
181
|
);
|
|
191
182
|
}
|
|
192
183
|
|
|
193
|
-
if (device == null) {
|
|
194
|
-
// No camera device - device limitation, not actionable
|
|
195
|
-
return (
|
|
196
|
-
<View style={styles.permissionContainer}>
|
|
197
|
-
<TextView style={styles.permissionText}>
|
|
198
|
-
{t('general.noCameraDetected')}
|
|
199
|
-
</TextView>
|
|
200
|
-
</View>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
184
|
return (
|
|
205
185
|
<View style={StyleSheet.absoluteFill}>
|
|
206
|
-
<
|
|
186
|
+
<TrustchexCamera
|
|
187
|
+
ref={cameraRef}
|
|
207
188
|
style={StyleSheet.absoluteFill}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
onInitialized={() => {
|
|
216
|
-
isCameraInitialized.value = true;
|
|
217
|
-
}}
|
|
218
|
-
fps={30}
|
|
189
|
+
cameraType="back"
|
|
190
|
+
enableFrameProcessing={isActive}
|
|
191
|
+
enableBarcodeScanning={isActive}
|
|
192
|
+
targetFps={30}
|
|
193
|
+
onFrameAvailable={handleFrame}
|
|
194
|
+
onCameraReady={handleCameraReady}
|
|
195
|
+
onCameraError={handleCameraError}
|
|
219
196
|
/>
|
|
220
197
|
<View style={styles.topZone}>
|
|
221
198
|
<TextView style={styles.topZoneText}>
|
|
@@ -233,6 +210,16 @@ const QrCodeScannerCamera = ({ onQrCodeScanned }: QrCodeScannerCameraProps) => {
|
|
|
233
210
|
autoPlay
|
|
234
211
|
/>
|
|
235
212
|
</View>
|
|
213
|
+
{onClose && (
|
|
214
|
+
<TouchableOpacity
|
|
215
|
+
onPress={onClose}
|
|
216
|
+
style={[styles.backButton, { top: Math.max(insets.top + 10, 50) }]}
|
|
217
|
+
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
218
|
+
activeOpacity={0.7}
|
|
219
|
+
>
|
|
220
|
+
<TextView style={styles.backButtonText}>×</TextView>
|
|
221
|
+
</TouchableOpacity>
|
|
222
|
+
)}
|
|
236
223
|
</View>
|
|
237
224
|
);
|
|
238
225
|
};
|
|
@@ -289,6 +276,25 @@ const styles = StyleSheet.create({
|
|
|
289
276
|
fontWeight: 'bold',
|
|
290
277
|
padding: 20,
|
|
291
278
|
},
|
|
279
|
+
backButton: {
|
|
280
|
+
position: 'absolute',
|
|
281
|
+
top: 20,
|
|
282
|
+
left: 20,
|
|
283
|
+
width: 40,
|
|
284
|
+
height: 40,
|
|
285
|
+
borderRadius: 20,
|
|
286
|
+
backgroundColor: 'rgba(255, 255, 255, 0.3)',
|
|
287
|
+
justifyContent: 'center',
|
|
288
|
+
alignItems: 'center',
|
|
289
|
+
zIndex: 999,
|
|
290
|
+
elevation: 5,
|
|
291
|
+
},
|
|
292
|
+
backButtonText: {
|
|
293
|
+
color: 'white',
|
|
294
|
+
fontSize: 28,
|
|
295
|
+
fontWeight: 'bold',
|
|
296
|
+
lineHeight: 28,
|
|
297
|
+
},
|
|
292
298
|
leftZone: {
|
|
293
299
|
position: 'absolute',
|
|
294
300
|
top: '35%',
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import React, { useRef, useCallback } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
requireNativeComponent,
|
|
4
|
+
type NativeSyntheticEvent,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
type ViewStyle,
|
|
7
|
+
type StyleProp,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
10
|
+
import { logError } from '../Libs/debug.utils';
|
|
11
|
+
|
|
12
|
+
// Native component interface
|
|
13
|
+
const TrustchexCameraViewNative =
|
|
14
|
+
requireNativeComponent<TrustchexCameraProps>('TrustchexCamera');
|
|
15
|
+
|
|
16
|
+
// Commands interface for Fabric
|
|
17
|
+
interface NativeCommands {
|
|
18
|
+
setFocusPoint: (
|
|
19
|
+
viewRef: React.ElementRef<typeof TrustchexCameraViewNative>,
|
|
20
|
+
x: number,
|
|
21
|
+
y: number
|
|
22
|
+
) => void;
|
|
23
|
+
setExposureOffset: (
|
|
24
|
+
viewRef: React.ElementRef<typeof TrustchexCameraViewNative>,
|
|
25
|
+
offset: number
|
|
26
|
+
) => void;
|
|
27
|
+
startRecording: (
|
|
28
|
+
viewRef: React.ElementRef<typeof TrustchexCameraViewNative>
|
|
29
|
+
) => void;
|
|
30
|
+
stopRecording: (
|
|
31
|
+
viewRef: React.ElementRef<typeof TrustchexCameraViewNative>
|
|
32
|
+
) => void;
|
|
33
|
+
cancelRecording: (
|
|
34
|
+
viewRef: React.ElementRef<typeof TrustchexCameraViewNative>
|
|
35
|
+
) => void;
|
|
36
|
+
deleteRecording: (
|
|
37
|
+
viewRef: React.ElementRef<typeof TrustchexCameraViewNative>,
|
|
38
|
+
filePath: string
|
|
39
|
+
) => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const Commands = codegenNativeCommands<NativeCommands>({
|
|
43
|
+
supportedCommands: [
|
|
44
|
+
'setFocusPoint',
|
|
45
|
+
'setExposureOffset',
|
|
46
|
+
'startRecording',
|
|
47
|
+
'stopRecording',
|
|
48
|
+
'cancelRecording',
|
|
49
|
+
'deleteRecording',
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Frame data structure — ML Kit results come pre-processed from native
|
|
54
|
+
export interface Frame {
|
|
55
|
+
width: number;
|
|
56
|
+
height: number;
|
|
57
|
+
orientation: number;
|
|
58
|
+
timestamp: number;
|
|
59
|
+
brightness?: number; // Average Y-plane luminance (0-255), computed natively
|
|
60
|
+
base64Image?: string; // JPEG base64 (only when includeBase64 or faceDetection enabled)
|
|
61
|
+
// Native ML Kit results (populated when corresponding detection mode is enabled)
|
|
62
|
+
faces?: NativeFace[];
|
|
63
|
+
textBlocks?: NativeTextBlock[];
|
|
64
|
+
resultText?: string;
|
|
65
|
+
barcodes?: NativeBarcode[];
|
|
66
|
+
mrzResult?: NativeMRZResult;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface NativeFace {
|
|
70
|
+
bounds: { x: number; y: number; width: number; height: number };
|
|
71
|
+
yawAngle: number;
|
|
72
|
+
pitchAngle: number;
|
|
73
|
+
rollAngle: number;
|
|
74
|
+
smilingProbability?: number;
|
|
75
|
+
leftEyeOpenProbability?: number;
|
|
76
|
+
rightEyeOpenProbability?: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface NativeTextBlock {
|
|
80
|
+
text: string;
|
|
81
|
+
blockFrame?: {
|
|
82
|
+
x: number;
|
|
83
|
+
y: number;
|
|
84
|
+
width: number;
|
|
85
|
+
height: number;
|
|
86
|
+
boundingCenterX: number;
|
|
87
|
+
boundingCenterY: number;
|
|
88
|
+
};
|
|
89
|
+
cornerPoints?: Array<{ x: number; y: number }>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface NativeBarcode {
|
|
93
|
+
rawValue: string;
|
|
94
|
+
displayValue: string;
|
|
95
|
+
format: number;
|
|
96
|
+
boundingBox?: { left: number; top: number; right: number; bottom: number };
|
|
97
|
+
cornerPoints?: Array<{ x: number; y: number }>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface NativeMRZResult {
|
|
101
|
+
valid: boolean;
|
|
102
|
+
format: string;
|
|
103
|
+
error?: string;
|
|
104
|
+
documentCode?: string;
|
|
105
|
+
issuingState?: string;
|
|
106
|
+
documentNumber?: string;
|
|
107
|
+
lastName?: string;
|
|
108
|
+
firstName?: string;
|
|
109
|
+
birthDate?: string;
|
|
110
|
+
sex?: string;
|
|
111
|
+
expirationDate?: string;
|
|
112
|
+
nationality?: string;
|
|
113
|
+
optional1?: string;
|
|
114
|
+
optional2?: string;
|
|
115
|
+
rawLines?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface TrustchexCameraProps {
|
|
119
|
+
style?: StyleProp<ViewStyle>;
|
|
120
|
+
cameraType?: 'front' | 'back';
|
|
121
|
+
torchEnabled?: boolean;
|
|
122
|
+
enableFrameProcessing?: boolean;
|
|
123
|
+
targetFps?: number;
|
|
124
|
+
// ML Kit detection modes — processing runs natively, results arrive in Frame
|
|
125
|
+
enableFaceDetection?: boolean;
|
|
126
|
+
enableTextRecognition?: boolean;
|
|
127
|
+
enableBarcodeScanning?: boolean;
|
|
128
|
+
enableMrzValidation?: boolean;
|
|
129
|
+
includeBase64?: boolean;
|
|
130
|
+
onFrameAvailable?: (event: NativeSyntheticEvent<{ frame: Frame }>) => void;
|
|
131
|
+
onCameraReady?: (
|
|
132
|
+
event: NativeSyntheticEvent<{
|
|
133
|
+
minExposureOffset: number;
|
|
134
|
+
maxExposureOffset: number;
|
|
135
|
+
}>
|
|
136
|
+
) => void;
|
|
137
|
+
onCameraError?: (event: NativeSyntheticEvent<{ error: string }>) => void;
|
|
138
|
+
onRecordingFinished?: (event: NativeSyntheticEvent<{ path: string }>) => void;
|
|
139
|
+
onRecordingError?: (event: NativeSyntheticEvent<{ error: string }>) => void;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface TrustchexCameraHandle {
|
|
143
|
+
setFocusPoint: (x: number, y: number) => void;
|
|
144
|
+
setExposureOffset: (offset: number) => void;
|
|
145
|
+
startRecording: (options: {
|
|
146
|
+
fileType?: string;
|
|
147
|
+
videoCodec?: string;
|
|
148
|
+
onRecordingFinished?: (video: { path: string }) => void;
|
|
149
|
+
onRecordingError?: (error: { error: string }) => void;
|
|
150
|
+
}) => void;
|
|
151
|
+
stopRecording: () => Promise<void>;
|
|
152
|
+
cancelRecording: () => Promise<void>;
|
|
153
|
+
deleteRecording: (filePath: string) => void;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export const TrustchexCamera = React.forwardRef<
|
|
157
|
+
TrustchexCameraHandle,
|
|
158
|
+
TrustchexCameraProps
|
|
159
|
+
>((props, ref) => {
|
|
160
|
+
const cameraRef = useRef(null);
|
|
161
|
+
const recordingCallbacksRef = useRef<{
|
|
162
|
+
onRecordingFinished?: (video: { path: string }) => void;
|
|
163
|
+
onRecordingError?: (error: { error: string }) => void;
|
|
164
|
+
}>({});
|
|
165
|
+
|
|
166
|
+
const handleRecordingFinished = useCallback(
|
|
167
|
+
(event: NativeSyntheticEvent<{ path: string }>) => {
|
|
168
|
+
recordingCallbacksRef.current.onRecordingFinished?.({
|
|
169
|
+
path: event.nativeEvent.path,
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
[]
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
const handleRecordingError = useCallback(
|
|
176
|
+
(event: NativeSyntheticEvent<{ error: string }>) => {
|
|
177
|
+
recordingCallbacksRef.current.onRecordingError?.({
|
|
178
|
+
error: event.nativeEvent.error,
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
[]
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const setFocusPoint = useCallback((x: number, y: number) => {
|
|
185
|
+
try {
|
|
186
|
+
if (cameraRef.current) {
|
|
187
|
+
Commands.setFocusPoint(cameraRef.current, x, y);
|
|
188
|
+
}
|
|
189
|
+
} catch (error) {
|
|
190
|
+
logError('[TrustchexCamera] setFocusPoint error:', error);
|
|
191
|
+
}
|
|
192
|
+
}, []);
|
|
193
|
+
|
|
194
|
+
const setExposureOffset = useCallback((offset: number) => {
|
|
195
|
+
try {
|
|
196
|
+
if (cameraRef.current) {
|
|
197
|
+
Commands.setExposureOffset(cameraRef.current, offset);
|
|
198
|
+
}
|
|
199
|
+
} catch (error) {
|
|
200
|
+
logError('[TrustchexCamera] setExposureOffset error:', error);
|
|
201
|
+
}
|
|
202
|
+
}, []);
|
|
203
|
+
|
|
204
|
+
const startRecording = useCallback(
|
|
205
|
+
(options: {
|
|
206
|
+
fileType?: string;
|
|
207
|
+
videoCodec?: string;
|
|
208
|
+
onRecordingFinished?: (video: { path: string }) => void;
|
|
209
|
+
onRecordingError?: (error: { error: string }) => void;
|
|
210
|
+
}) => {
|
|
211
|
+
recordingCallbacksRef.current = {
|
|
212
|
+
onRecordingFinished: options.onRecordingFinished,
|
|
213
|
+
onRecordingError: options.onRecordingError,
|
|
214
|
+
};
|
|
215
|
+
try {
|
|
216
|
+
if (cameraRef.current) {
|
|
217
|
+
Commands.startRecording(cameraRef.current);
|
|
218
|
+
}
|
|
219
|
+
} catch (error) {
|
|
220
|
+
logError('[TrustchexCamera] startRecording error:', error);
|
|
221
|
+
options.onRecordingError?.({ error: (error as Error).message });
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
[]
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
const stopRecording = useCallback(() => {
|
|
228
|
+
return new Promise<void>((resolve) => {
|
|
229
|
+
try {
|
|
230
|
+
if (cameraRef.current) {
|
|
231
|
+
Commands.stopRecording(cameraRef.current);
|
|
232
|
+
}
|
|
233
|
+
} catch (error) {
|
|
234
|
+
logError('[TrustchexCamera] stopRecording error:', error);
|
|
235
|
+
}
|
|
236
|
+
resolve();
|
|
237
|
+
});
|
|
238
|
+
}, []);
|
|
239
|
+
|
|
240
|
+
const cancelRecording = useCallback(() => {
|
|
241
|
+
return new Promise<void>((resolve) => {
|
|
242
|
+
// Clear callbacks to prevent stale onRecordingFinished from firing
|
|
243
|
+
recordingCallbacksRef.current = {};
|
|
244
|
+
try {
|
|
245
|
+
if (cameraRef.current) {
|
|
246
|
+
Commands.cancelRecording(cameraRef.current);
|
|
247
|
+
}
|
|
248
|
+
} catch (error) {
|
|
249
|
+
logError('[TrustchexCamera] cancelRecording error:', error);
|
|
250
|
+
}
|
|
251
|
+
resolve();
|
|
252
|
+
});
|
|
253
|
+
}, []);
|
|
254
|
+
|
|
255
|
+
const deleteRecording = useCallback((filePath: string) => {
|
|
256
|
+
try {
|
|
257
|
+
if (cameraRef.current) {
|
|
258
|
+
Commands.deleteRecording(cameraRef.current, filePath);
|
|
259
|
+
}
|
|
260
|
+
} catch (error) {
|
|
261
|
+
logError('[TrustchexCamera] deleteRecording error:', error);
|
|
262
|
+
}
|
|
263
|
+
}, []);
|
|
264
|
+
|
|
265
|
+
React.useImperativeHandle(ref, () => ({
|
|
266
|
+
setFocusPoint,
|
|
267
|
+
setExposureOffset,
|
|
268
|
+
startRecording,
|
|
269
|
+
stopRecording,
|
|
270
|
+
cancelRecording,
|
|
271
|
+
deleteRecording,
|
|
272
|
+
}));
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<TrustchexCameraViewNative
|
|
276
|
+
ref={cameraRef}
|
|
277
|
+
{...props}
|
|
278
|
+
onRecordingFinished={handleRecordingFinished}
|
|
279
|
+
onRecordingError={handleRecordingError}
|
|
280
|
+
style={[styles.camera, props.style]}
|
|
281
|
+
/>
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
const styles = StyleSheet.create({
|
|
286
|
+
camera: {
|
|
287
|
+
flex: 1,
|
|
288
|
+
},
|
|
289
|
+
});
|
|
@@ -17,8 +17,8 @@ export const ENHANCEMENT_CONFIG = {
|
|
|
17
17
|
mrzScanning: { low: 45, high: 130, target: 80 },
|
|
18
18
|
},
|
|
19
19
|
adaptiveStep: true,
|
|
20
|
-
maxStepSize: 2,
|
|
21
|
-
hysteresis: 5,
|
|
20
|
+
maxStepSize: 2, // Reduced from 3 for smoother transitions
|
|
21
|
+
hysteresis: 5, // Dead zone to prevent oscillation
|
|
22
22
|
},
|
|
23
23
|
|
|
24
24
|
contrast: {
|