@ha_tecno/live-id-sdk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +323 -0
  3. package/android/build.gradle +94 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/liveidsdk/LiveIdSdkModule.kt +25 -0
  8. package/android/src/main/java/com/liveidsdk/LiveIdSdkPackage.kt +17 -0
  9. package/ios/LiveIdSdk-Bridging-Header.h +2 -0
  10. package/ios/LiveIdSdk.mm +14 -0
  11. package/ios/LiveIdSdk.swift +8 -0
  12. package/lib/commonjs/assets/arrow.png +0 -0
  13. package/lib/commonjs/assets/exampleInstructionWithBorder.jpeg +0 -0
  14. package/lib/commonjs/assets/exampleInstructionWithoutFinger.jpeg +0 -0
  15. package/lib/commonjs/assets/ic_redness_capture_tip.png +0 -0
  16. package/lib/commonjs/assets/logo.png +0 -0
  17. package/lib/commonjs/components/CameraConfigInfos/index.js +21 -0
  18. package/lib/commonjs/components/CameraConfigInfos/index.js.map +1 -0
  19. package/lib/commonjs/components/CameraConfigInfos/styles.js +19 -0
  20. package/lib/commonjs/components/CameraConfigInfos/styles.js.map +1 -0
  21. package/lib/commonjs/components/DeviceNullDisplay/index.js +59 -0
  22. package/lib/commonjs/components/DeviceNullDisplay/index.js.map +1 -0
  23. package/lib/commonjs/components/ErrorDisplay/index.js +59 -0
  24. package/lib/commonjs/components/ErrorDisplay/index.js.map +1 -0
  25. package/lib/commonjs/components/Gabarito/index.js +19 -0
  26. package/lib/commonjs/components/Gabarito/index.js.map +1 -0
  27. package/lib/commonjs/components/Gabarito/styles.js +30 -0
  28. package/lib/commonjs/components/Gabarito/styles.js.map +1 -0
  29. package/lib/commonjs/components/Toast/Toast.js +66 -0
  30. package/lib/commonjs/components/Toast/Toast.js.map +1 -0
  31. package/lib/commonjs/components/WaitingForResult/index.js +24 -0
  32. package/lib/commonjs/components/WaitingForResult/index.js.map +1 -0
  33. package/lib/commonjs/components/WaitingForResult/styles.js +32 -0
  34. package/lib/commonjs/components/WaitingForResult/styles.js.map +1 -0
  35. package/lib/commonjs/index.js +34 -0
  36. package/lib/commonjs/index.js.map +1 -0
  37. package/lib/commonjs/screens/CadastroFinger/components/AjudaCadastro/index.js +49 -0
  38. package/lib/commonjs/screens/CadastroFinger/components/AjudaCadastro/index.js.map +1 -0
  39. package/lib/commonjs/screens/CadastroFinger/components/AjudaCadastro/styles.js +62 -0
  40. package/lib/commonjs/screens/CadastroFinger/components/AjudaCadastro/styles.js.map +1 -0
  41. package/lib/commonjs/screens/CadastroFinger/components/CameraCadastro/index.js +298 -0
  42. package/lib/commonjs/screens/CadastroFinger/components/CameraCadastro/index.js.map +1 -0
  43. package/lib/commonjs/screens/CadastroFinger/components/CameraCadastro/styles.js +54 -0
  44. package/lib/commonjs/screens/CadastroFinger/components/CameraCadastro/styles.js.map +1 -0
  45. package/lib/commonjs/screens/CadastroFinger/components/ImageDisplayScreen/index.js +44 -0
  46. package/lib/commonjs/screens/CadastroFinger/components/ImageDisplayScreen/index.js.map +1 -0
  47. package/lib/commonjs/screens/CadastroFinger/components/ImageDisplayScreen/styles.js +65 -0
  48. package/lib/commonjs/screens/CadastroFinger/components/ImageDisplayScreen/styles.js.map +1 -0
  49. package/lib/commonjs/screens/CadastroFinger/index.js +50 -0
  50. package/lib/commonjs/screens/CadastroFinger/index.js.map +1 -0
  51. package/lib/commonjs/screens/CadastroScreen/CadastroScreen.js +186 -0
  52. package/lib/commonjs/screens/CadastroScreen/CadastroScreen.js.map +1 -0
  53. package/lib/commonjs/screens/ProvaVidas/index.js +246 -0
  54. package/lib/commonjs/screens/ProvaVidas/index.js.map +1 -0
  55. package/lib/commonjs/screens/ProvaVidas/styles.js +93 -0
  56. package/lib/commonjs/screens/ProvaVidas/styles.js.map +1 -0
  57. package/lib/commonjs/screens/ValidadeFinger/index.js +216 -0
  58. package/lib/commonjs/screens/ValidadeFinger/index.js.map +1 -0
  59. package/lib/commonjs/screens/ValidadeFinger/styles.js +54 -0
  60. package/lib/commonjs/screens/ValidadeFinger/styles.js.map +1 -0
  61. package/lib/commonjs/services/index.js +145 -0
  62. package/lib/commonjs/services/index.js.map +1 -0
  63. package/lib/commonjs/types/screen.js +2 -0
  64. package/lib/commonjs/types/screen.js.map +1 -0
  65. package/lib/commonjs/utils/file.js +38 -0
  66. package/lib/commonjs/utils/file.js.map +1 -0
  67. package/lib/commonjs/utils/getConfigCamera.js +25 -0
  68. package/lib/commonjs/utils/getConfigCamera.js.map +1 -0
  69. package/lib/commonjs/utils/index.js +14 -0
  70. package/lib/commonjs/utils/index.js.map +1 -0
  71. package/lib/module/assets/arrow.png +0 -0
  72. package/lib/module/assets/exampleInstructionWithBorder.jpeg +0 -0
  73. package/lib/module/assets/exampleInstructionWithoutFinger.jpeg +0 -0
  74. package/lib/module/assets/ic_redness_capture_tip.png +0 -0
  75. package/lib/module/assets/logo.png +0 -0
  76. package/lib/module/components/CameraConfigInfos/index.js +13 -0
  77. package/lib/module/components/CameraConfigInfos/index.js.map +1 -0
  78. package/lib/module/components/CameraConfigInfos/styles.js +13 -0
  79. package/lib/module/components/CameraConfigInfos/styles.js.map +1 -0
  80. package/lib/module/components/DeviceNullDisplay/index.js +51 -0
  81. package/lib/module/components/DeviceNullDisplay/index.js.map +1 -0
  82. package/lib/module/components/ErrorDisplay/index.js +51 -0
  83. package/lib/module/components/ErrorDisplay/index.js.map +1 -0
  84. package/lib/module/components/Gabarito/index.js +11 -0
  85. package/lib/module/components/Gabarito/index.js.map +1 -0
  86. package/lib/module/components/Gabarito/styles.js +24 -0
  87. package/lib/module/components/Gabarito/styles.js.map +1 -0
  88. package/lib/module/components/Toast/Toast.js +58 -0
  89. package/lib/module/components/Toast/Toast.js.map +1 -0
  90. package/lib/module/components/WaitingForResult/index.js +17 -0
  91. package/lib/module/components/WaitingForResult/index.js.map +1 -0
  92. package/lib/module/components/WaitingForResult/styles.js +26 -0
  93. package/lib/module/components/WaitingForResult/styles.js.map +1 -0
  94. package/lib/module/index.js +7 -0
  95. package/lib/module/index.js.map +1 -0
  96. package/lib/module/screens/CadastroFinger/components/AjudaCadastro/index.js +41 -0
  97. package/lib/module/screens/CadastroFinger/components/AjudaCadastro/index.js.map +1 -0
  98. package/lib/module/screens/CadastroFinger/components/AjudaCadastro/styles.js +56 -0
  99. package/lib/module/screens/CadastroFinger/components/AjudaCadastro/styles.js.map +1 -0
  100. package/lib/module/screens/CadastroFinger/components/CameraCadastro/index.js +288 -0
  101. package/lib/module/screens/CadastroFinger/components/CameraCadastro/index.js.map +1 -0
  102. package/lib/module/screens/CadastroFinger/components/CameraCadastro/styles.js +48 -0
  103. package/lib/module/screens/CadastroFinger/components/CameraCadastro/styles.js.map +1 -0
  104. package/lib/module/screens/CadastroFinger/components/ImageDisplayScreen/index.js +36 -0
  105. package/lib/module/screens/CadastroFinger/components/ImageDisplayScreen/index.js.map +1 -0
  106. package/lib/module/screens/CadastroFinger/components/ImageDisplayScreen/styles.js +59 -0
  107. package/lib/module/screens/CadastroFinger/components/ImageDisplayScreen/styles.js.map +1 -0
  108. package/lib/module/screens/CadastroFinger/index.js +42 -0
  109. package/lib/module/screens/CadastroFinger/index.js.map +1 -0
  110. package/lib/module/screens/CadastroScreen/CadastroScreen.js +177 -0
  111. package/lib/module/screens/CadastroScreen/CadastroScreen.js.map +1 -0
  112. package/lib/module/screens/ProvaVidas/index.js +239 -0
  113. package/lib/module/screens/ProvaVidas/index.js.map +1 -0
  114. package/lib/module/screens/ProvaVidas/styles.js +87 -0
  115. package/lib/module/screens/ProvaVidas/styles.js.map +1 -0
  116. package/lib/module/screens/ValidadeFinger/index.js +206 -0
  117. package/lib/module/screens/ValidadeFinger/index.js.map +1 -0
  118. package/lib/module/screens/ValidadeFinger/styles.js +48 -0
  119. package/lib/module/screens/ValidadeFinger/styles.js.map +1 -0
  120. package/lib/module/services/index.js +131 -0
  121. package/lib/module/services/index.js.map +1 -0
  122. package/lib/module/types/screen.js +2 -0
  123. package/lib/module/types/screen.js.map +1 -0
  124. package/lib/module/utils/file.js +29 -0
  125. package/lib/module/utils/file.js.map +1 -0
  126. package/lib/module/utils/getConfigCamera.js +19 -0
  127. package/lib/module/utils/getConfigCamera.js.map +1 -0
  128. package/lib/module/utils/index.js +3 -0
  129. package/lib/module/utils/index.js.map +1 -0
  130. package/lib/typescript/src/components/CameraConfigInfos/index.d.ts +9 -0
  131. package/lib/typescript/src/components/CameraConfigInfos/index.d.ts.map +1 -0
  132. package/lib/typescript/src/components/CameraConfigInfos/styles.d.ts +11 -0
  133. package/lib/typescript/src/components/CameraConfigInfos/styles.d.ts.map +1 -0
  134. package/lib/typescript/src/components/DeviceNullDisplay/index.d.ts +11 -0
  135. package/lib/typescript/src/components/DeviceNullDisplay/index.d.ts.map +1 -0
  136. package/lib/typescript/src/components/ErrorDisplay/index.d.ts +11 -0
  137. package/lib/typescript/src/components/ErrorDisplay/index.d.ts.map +1 -0
  138. package/lib/typescript/src/components/Gabarito/index.d.ts +3 -0
  139. package/lib/typescript/src/components/Gabarito/index.d.ts.map +1 -0
  140. package/lib/typescript/src/components/Gabarito/styles.d.ts +21 -0
  141. package/lib/typescript/src/components/Gabarito/styles.d.ts.map +1 -0
  142. package/lib/typescript/src/components/Toast/Toast.d.ts +42 -0
  143. package/lib/typescript/src/components/Toast/Toast.d.ts.map +1 -0
  144. package/lib/typescript/src/components/WaitingForResult/index.d.ts +7 -0
  145. package/lib/typescript/src/components/WaitingForResult/index.d.ts.map +1 -0
  146. package/lib/typescript/src/components/WaitingForResult/styles.d.ts +24 -0
  147. package/lib/typescript/src/components/WaitingForResult/styles.d.ts.map +1 -0
  148. package/lib/typescript/src/index.d.ts +5 -0
  149. package/lib/typescript/src/index.d.ts.map +1 -0
  150. package/lib/typescript/src/screens/CadastroFinger/components/AjudaCadastro/index.d.ts +7 -0
  151. package/lib/typescript/src/screens/CadastroFinger/components/AjudaCadastro/index.d.ts.map +1 -0
  152. package/lib/typescript/src/screens/CadastroFinger/components/AjudaCadastro/styles.d.ts +55 -0
  153. package/lib/typescript/src/screens/CadastroFinger/components/AjudaCadastro/styles.d.ts.map +1 -0
  154. package/lib/typescript/src/screens/CadastroFinger/components/CameraCadastro/index.d.ts +16 -0
  155. package/lib/typescript/src/screens/CadastroFinger/components/CameraCadastro/index.d.ts.map +1 -0
  156. package/lib/typescript/src/screens/CadastroFinger/components/CameraCadastro/styles.d.ts +44 -0
  157. package/lib/typescript/src/screens/CadastroFinger/components/CameraCadastro/styles.d.ts.map +1 -0
  158. package/lib/typescript/src/screens/CadastroFinger/components/ImageDisplayScreen/index.d.ts +12 -0
  159. package/lib/typescript/src/screens/CadastroFinger/components/ImageDisplayScreen/index.d.ts.map +1 -0
  160. package/lib/typescript/src/screens/CadastroFinger/components/ImageDisplayScreen/styles.d.ts +54 -0
  161. package/lib/typescript/src/screens/CadastroFinger/components/ImageDisplayScreen/styles.d.ts.map +1 -0
  162. package/lib/typescript/src/screens/CadastroFinger/index.d.ts +16 -0
  163. package/lib/typescript/src/screens/CadastroFinger/index.d.ts.map +1 -0
  164. package/lib/typescript/src/screens/CadastroScreen/CadastroScreen.d.ts +14 -0
  165. package/lib/typescript/src/screens/CadastroScreen/CadastroScreen.d.ts.map +1 -0
  166. package/lib/typescript/src/screens/ProvaVidas/index.d.ts +14 -0
  167. package/lib/typescript/src/screens/ProvaVidas/index.d.ts.map +1 -0
  168. package/lib/typescript/src/screens/ProvaVidas/styles.d.ts +85 -0
  169. package/lib/typescript/src/screens/ProvaVidas/styles.d.ts.map +1 -0
  170. package/lib/typescript/src/screens/ValidadeFinger/index.d.ts +14 -0
  171. package/lib/typescript/src/screens/ValidadeFinger/index.d.ts.map +1 -0
  172. package/lib/typescript/src/screens/ValidadeFinger/styles.d.ts +44 -0
  173. package/lib/typescript/src/screens/ValidadeFinger/styles.d.ts.map +1 -0
  174. package/lib/typescript/src/services/index.d.ts +21 -0
  175. package/lib/typescript/src/services/index.d.ts.map +1 -0
  176. package/lib/typescript/src/types/screen.d.ts +6 -0
  177. package/lib/typescript/src/types/screen.d.ts.map +1 -0
  178. package/lib/typescript/src/utils/file.d.ts +3 -0
  179. package/lib/typescript/src/utils/file.d.ts.map +1 -0
  180. package/lib/typescript/src/utils/getConfigCamera.d.ts +14 -0
  181. package/lib/typescript/src/utils/getConfigCamera.d.ts.map +1 -0
  182. package/lib/typescript/src/utils/index.d.ts +3 -0
  183. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  184. package/live-id-sdk.podspec +41 -0
  185. package/package.json +184 -0
  186. package/src/assets/arrow.png +0 -0
  187. package/src/assets/exampleInstructionWithBorder.jpeg +0 -0
  188. package/src/assets/exampleInstructionWithoutFinger.jpeg +0 -0
  189. package/src/assets/ic_redness_capture_tip.png +0 -0
  190. package/src/assets/logo.png +0 -0
  191. package/src/components/CameraConfigInfos/index.tsx +25 -0
  192. package/src/components/CameraConfigInfos/styles.ts +13 -0
  193. package/src/components/DeviceNullDisplay/index.tsx +59 -0
  194. package/src/components/ErrorDisplay/index.tsx +60 -0
  195. package/src/components/Gabarito/index.tsx +11 -0
  196. package/src/components/Gabarito/styles.ts +23 -0
  197. package/src/components/Toast/Toast.tsx +61 -0
  198. package/src/components/WaitingForResult/index.tsx +22 -0
  199. package/src/components/WaitingForResult/styles.ts +27 -0
  200. package/src/index.tsx +6 -0
  201. package/src/screens/CadastroFinger/components/AjudaCadastro/index.tsx +49 -0
  202. package/src/screens/CadastroFinger/components/AjudaCadastro/styles.ts +56 -0
  203. package/src/screens/CadastroFinger/components/CameraCadastro/index.tsx +356 -0
  204. package/src/screens/CadastroFinger/components/CameraCadastro/styles.ts +47 -0
  205. package/src/screens/CadastroFinger/components/ImageDisplayScreen/index.tsx +45 -0
  206. package/src/screens/CadastroFinger/components/ImageDisplayScreen/styles.ts +55 -0
  207. package/src/screens/CadastroFinger/index.tsx +56 -0
  208. package/src/screens/CadastroScreen/CadastroScreen.tsx +212 -0
  209. package/src/screens/ProvaVidas/index.tsx +308 -0
  210. package/src/screens/ProvaVidas/styles.ts +99 -0
  211. package/src/screens/ValidadeFinger/index.tsx +263 -0
  212. package/src/screens/ValidadeFinger/styles.ts +47 -0
  213. package/src/services/index.ts +143 -0
  214. package/src/types/screen.ts +5 -0
  215. package/src/utils/file.ts +30 -0
  216. package/src/utils/getConfigCamera.ts +45 -0
  217. package/src/utils/index.ts +3 -0
@@ -0,0 +1,356 @@
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { Alert, Text, View, TouchableOpacity, Button } from 'react-native';
3
+ import {
4
+ Camera,
5
+ useCameraFormat,
6
+ type Point,
7
+ useCameraDevice,
8
+ } from 'react-native-vision-camera';
9
+ import Modal, { type ModalProps } from 'react-native-modal';
10
+ import Orientation from 'react-native-orientation-locker';
11
+ import {
12
+ Gesture,
13
+ GestureDetector,
14
+ GestureHandlerRootView,
15
+ } from 'react-native-gesture-handler';
16
+ import { runOnJS } from 'react-native-reanimated';
17
+
18
+ import { AjudaCadastro } from '../AjudaCadastro';
19
+ import { ImageDisplayScreen } from '../ImageDisplayScreen';
20
+ import { sendImages } from '../../../../services';
21
+ import { getConfigCamera } from '../../../../utils';
22
+ import { encodeImageToBase64, validarBase64 } from '../../../../utils/file';
23
+ import type { ScreenProps } from '../../../../types/screen';
24
+ import { CameraConfigInfos } from '../../../../components/CameraConfigInfos';
25
+ import { DeviceNullDisplay } from '../../../../components/DeviceNullDisplay';
26
+ import { ErrorDisplay } from '../../../../components/ErrorDisplay';
27
+ import { Gabarito } from '../../../../components/Gabarito';
28
+ import { WaitingForResult } from '../../../../components/WaitingForResult';
29
+ import { styles } from './styles';
30
+
31
+ let vezesQualidadeDigitalCount = 0;
32
+
33
+ interface CameraCadastroProps {
34
+ isVisible?: boolean;
35
+ onCloseModal?: () => void;
36
+ onError?: (response?: any) => void;
37
+ onSuccess?: (response?: any) => void;
38
+ screenProps?: ScreenProps;
39
+ onMaxAttempts?: () => void;
40
+ maxAttempts?: number;
41
+ ModalParams?: ModalProps;
42
+ }
43
+
44
+ type GetConfigApi = {
45
+ id: number;
46
+ deviceModels: string[];
47
+ deviceType: string;
48
+ fps: number;
49
+ exposure: number;
50
+ zoom: number;
51
+ serviceType: string;
52
+ showButtonInfo: boolean;
53
+ };
54
+
55
+ export const CameraCadastro: React.FC<CameraCadastroProps> = ({
56
+ isVisible = false,
57
+ onCloseModal,
58
+ onError,
59
+ onSuccess,
60
+ screenProps,
61
+ onMaxAttempts,
62
+ maxAttempts = 3,
63
+ ModalParams,
64
+ }) => {
65
+ const id = screenProps?.id;
66
+ const camera = useRef<Camera>(null);
67
+ let base64Image: string[] = [];
68
+
69
+ const [showCamera, setShowCamera] = useState(false);
70
+ const [showOverlay, setShowOverlay] = useState(false);
71
+
72
+ const [arrayImages, setArrayImages] = useState<any[]>([]);
73
+ const [load, setLoad] = useState(false);
74
+ const [fingerErro, setFingerErro] = useState(false);
75
+ const [badImageModal, setBadImageModal] = useState(false);
76
+ const [cameraConfigs, setCameraConfigs] = useState<GetConfigApi>();
77
+
78
+ // mantem a tela em modo portrait
79
+ useEffect(() => {
80
+ Orientation.lockToPortrait();
81
+ return () => {
82
+ Orientation.unlockAllOrientations();
83
+ };
84
+ }, []);
85
+
86
+ // Pega a permissão da camera do dispositivo
87
+ const requestCameraPermission = useCallback(async () => {
88
+ try {
89
+ await Camera.requestCameraPermission();
90
+ } catch (error) {}
91
+ }, []);
92
+
93
+ // pra garantir que a permissão da camera seja solicitada
94
+ useEffect(() => {
95
+ requestCameraPermission();
96
+ }, [requestCameraPermission]);
97
+
98
+ useEffect(() => {
99
+ getConfigCamera('finger')
100
+ .then((config) => {
101
+ setCameraConfigs(config);
102
+ })
103
+ .catch((error) => {
104
+ console.error(error);
105
+ });
106
+ }, []);
107
+
108
+ const device = useCameraDevice('back', {
109
+ physicalDevices: ['wide-angle-camera'],
110
+ });
111
+
112
+ const cameraFormat = useCameraFormat(device, [
113
+ {
114
+ photoResolution: {
115
+ height: 1280,
116
+ width: 720,
117
+ },
118
+ },
119
+ ]);
120
+
121
+ useEffect(() => {
122
+ if (fingerErro) {
123
+ Alert.alert('Erro', 'Tentavias excedidas !');
124
+ onMaxAttempts && onMaxAttempts();
125
+ }
126
+ }, [fingerErro, onMaxAttempts]);
127
+
128
+ const handleProximaTela = () => {
129
+ setShowCamera(true);
130
+ };
131
+
132
+ useEffect(() => {
133
+ return () => {
134
+ // clean up
135
+ if (vezesQualidadeDigitalCount >= 3) {
136
+ vezesQualidadeDigitalCount = 0;
137
+ }
138
+ setLoad(false);
139
+ setArrayImages([]);
140
+ setFingerErro(false);
141
+ setBadImageModal(false);
142
+ setShowCamera(false);
143
+ };
144
+ }, []);
145
+
146
+ // captura a foto da camera
147
+ useEffect(() => {
148
+ requestCameraPermission();
149
+ }, [requestCameraPermission]);
150
+
151
+ const capturedPhoto = async () => {
152
+ const photo = await camera.current?.takePhoto({
153
+ qualityPrioritization: 'speed',
154
+ flash: 'off',
155
+ });
156
+ if (photo == null) return;
157
+ const base64 = await encodeImageToBase64(photo.path);
158
+ base64Image.push(base64 ?? '');
159
+ setArrayImages((prevArray) => [...prevArray, ...base64Image]);
160
+ };
161
+
162
+ // Fecha o modal
163
+ const onCloseModalHandler = useCallback(() => {
164
+ ResetScreenAndStates();
165
+ onCloseModal && onCloseModal();
166
+ }, [onCloseModal]);
167
+
168
+ // Envia a imagem para a validação da digital
169
+ const sendFile = useCallback(async () => {
170
+ try {
171
+ let UID = id;
172
+ let finger = 'DI';
173
+ let images = arrayImages;
174
+
175
+ if (validarBase64(images) === false) return;
176
+
177
+ let req =
178
+ images.length === 3 ? await sendImages(UID, finger, images) : null;
179
+
180
+ if (req.code === 0) {
181
+ Alert.alert('Sucesso !');
182
+ onSuccess && onSuccess(req);
183
+ setLoad(false);
184
+ setArrayImages([]);
185
+ onCloseModalHandler();
186
+ setShowOverlay(false);
187
+ } else if (req.code === 1) {
188
+ Alert.alert('Já cadastrada !');
189
+ onCloseModalHandler();
190
+ setShowOverlay(false);
191
+ } else {
192
+ //alert("Erro, por favor, verifique e tente novamente !")
193
+ vezesQualidadeDigitalCount += 1; // Incrementa a contagem
194
+ if (arrayImages.length > 0) {
195
+ setBadImageModal(true);
196
+ }
197
+ setLoad(false);
198
+ setShowOverlay(false);
199
+ setArrayImages([]);
200
+ }
201
+ setLoad(false);
202
+ setShowOverlay(false);
203
+ } catch (error) {
204
+ console.log('Erro ao enviar imagens: ' + error);
205
+ setLoad(false);
206
+ setArrayImages([]);
207
+ onError && onError();
208
+ Alert.alert('Erro ao enviar imagem !');
209
+ vezesQualidadeDigitalCount += 1;
210
+ setShowOverlay(false);
211
+ }
212
+ }, [arrayImages, id, onError, onSuccess, onCloseModalHandler]);
213
+
214
+ // Envia a imagem para a validação da digital
215
+ useEffect(() => {
216
+ if (arrayImages.length === 3) {
217
+ setLoad(true);
218
+ setShowOverlay(true);
219
+ sendFile();
220
+ }
221
+ if (vezesQualidadeDigitalCount >= maxAttempts) {
222
+ setFingerErro(true); // Define fingerErro como true após 2 acessos
223
+ vezesQualidadeDigitalCount = 0;
224
+ }
225
+ }, [arrayImages, id, maxAttempts, sendFile]);
226
+
227
+ // Função para resetar os estados da tela
228
+ const ResetScreenAndStates = () => {
229
+ setLoad(false);
230
+ setArrayImages([]);
231
+ setFingerErro(false);
232
+ setBadImageModal(false);
233
+ setShowCamera(false);
234
+ };
235
+
236
+ // Função para focar a camera
237
+ const focus = useCallback((point: Point) => {
238
+ const c = camera.current;
239
+ if (c == null) return;
240
+ c.focus(point);
241
+ }, []);
242
+
243
+ // Função para focar a camera
244
+ const gesture = Gesture.Tap().onBegin(({ x, y }) => {
245
+ runOnJS(focus)({ x, y });
246
+ });
247
+
248
+ if (!showCamera) {
249
+ return <AjudaCadastro handleProximaTela={handleProximaTela} />;
250
+ }
251
+
252
+ if (!screenProps && isVisible) {
253
+ return (
254
+ <ErrorDisplay
255
+ isVisible={isVisible}
256
+ onCloseModalHandler={onCloseModalHandler}
257
+ requestCameraPermission={requestCameraPermission}
258
+ />
259
+ );
260
+ }
261
+
262
+ if (device == null) {
263
+ return (
264
+ <DeviceNullDisplay
265
+ isVisible={isVisible}
266
+ onCloseModalHandler={onCloseModalHandler}
267
+ requestCameraPermission={requestCameraPermission}
268
+ />
269
+ );
270
+ }
271
+
272
+ if (showCamera && screenProps && cameraConfigs !== null) {
273
+ return (
274
+ <Modal
275
+ style={styles.modal}
276
+ isVisible={isVisible}
277
+ swipeDirection="down"
278
+ propagateSwipe={true}
279
+ onSwipeComplete={onCloseModalHandler}
280
+ {...ModalParams}
281
+ >
282
+ <GestureHandlerRootView style={styles.root}>
283
+ <View style={styles.container}>
284
+ {showOverlay && (
285
+ <WaitingForResult
286
+ onPress={() => {
287
+ setShowOverlay(false);
288
+ }}
289
+ />
290
+ )}
291
+ {!badImageModal ? (
292
+ <>
293
+ <GestureDetector gesture={gesture}>
294
+ <View style={styles.cameraContainer}>
295
+ <Camera
296
+ ref={camera}
297
+ style={styles.camera}
298
+ isActive={true}
299
+ device={device}
300
+ format={cameraFormat}
301
+ torch={'on'}
302
+ focusable={true}
303
+ exposure={cameraConfigs?.exposure}
304
+ zoom={cameraConfigs?.zoom}
305
+ photo={true}
306
+ enableHighQualityPhotos={true}
307
+ />
308
+ {!showOverlay && <Gabarito />}
309
+ </View>
310
+ </GestureDetector>
311
+ <View style={styles.containerCapture}>
312
+ <TouchableOpacity disabled={load} onPress={capturedPhoto}>
313
+ <View style={styles.containerButton}>
314
+ {!load ? (
315
+ <Text style={styles.textButton}>
316
+ Tirar Foto ({arrayImages?.length}/3)
317
+ </Text>
318
+ ) : (
319
+ <Text style={styles.textButton}>
320
+ Verificando Digital...
321
+ </Text>
322
+ )}
323
+ </View>
324
+ </TouchableOpacity>
325
+ </View>
326
+ <View style={styles.containerButtonClose}>
327
+ <Button
328
+ disabled={load}
329
+ title="Fechar Camera"
330
+ onPress={onCloseModalHandler}
331
+ />
332
+ </View>
333
+ <View style={styles.cameraConfigs}>
334
+ <CameraConfigInfos
335
+ exposure={cameraConfigs?.exposure}
336
+ zoom={cameraConfigs?.zoom}
337
+ showButtonInfo={cameraConfigs?.showButtonInfo}
338
+ />
339
+ </View>
340
+ </>
341
+ ) : (
342
+ <ImageDisplayScreen
343
+ onCloseModal={() => {
344
+ setBadImageModal(false);
345
+ setArrayImages([]);
346
+ }}
347
+ screenProps={{ base64Image: arrayImages[0] }}
348
+ />
349
+ )}
350
+ </View>
351
+ </GestureHandlerRootView>
352
+ </Modal>
353
+ );
354
+ }
355
+ return null;
356
+ };
@@ -0,0 +1,47 @@
1
+ import { StyleSheet, Dimensions, Platform } from 'react-native';
2
+
3
+ const { height } = Dimensions.get('window');
4
+
5
+ export const styles = StyleSheet.create({
6
+ container: {
7
+ flex: 1,
8
+ },
9
+ root: {
10
+ flex: 1,
11
+ },
12
+ cameraContainer: {
13
+ flex: 1,
14
+ },
15
+ camera: {
16
+ flex: 1,
17
+ justifyContent: 'flex-end',
18
+ paddingBottom: height * 0.2,
19
+ },
20
+ containerCapture: {
21
+ height: height * 0.2,
22
+ alignItems: 'center',
23
+ justifyContent: 'center',
24
+ },
25
+ modal: {
26
+ margin: 0,
27
+ },
28
+ containerButton: {
29
+ width: 350,
30
+ height: 100,
31
+ borderRadius: 80,
32
+ backgroundColor: 'blue',
33
+ alignItems: 'center',
34
+ justifyContent: 'center',
35
+ },
36
+ textButton: {
37
+ fontSize: 18,
38
+ fontWeight: '500',
39
+ color: '#fff',
40
+ },
41
+ containerButtonClose: {
42
+ marginBottom: Platform.OS === 'ios' ? 48 : 0,
43
+ },
44
+ cameraConfigs: {
45
+ alignItems: 'center',
46
+ },
47
+ });
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { View, Image, Text, Button, ScrollView } from 'react-native';
3
+ import { styles } from './styles';
4
+ import type { ScreenProps } from '../../../../types/screen';
5
+
6
+ interface ImageDisplayScreenProps {
7
+ isVisible?: boolean;
8
+ onCloseModal?: () => void;
9
+ onError?: (response?: any) => void;
10
+ onSuccess?: (response?: any) => void;
11
+ screenProps?: ScreenProps;
12
+ }
13
+
14
+ export const ImageDisplayScreen: React.FC<ImageDisplayScreenProps> = ({
15
+ onCloseModal,
16
+ screenProps,
17
+ }) => {
18
+ const base64Image = screenProps?.base64Image;
19
+
20
+ const onCloseModalHandler = () => {
21
+ onCloseModal && onCloseModal();
22
+ };
23
+
24
+ return (
25
+ <ScrollView contentContainerStyle={styles.container}>
26
+ <View style={styles.imageContainer}>
27
+ {/* Parte gráfica da "Tela 1" */}
28
+ <Image
29
+ source={{ uri: `data:image/jpeg;base64,${base64Image}` }}
30
+ style={styles.image}
31
+ />
32
+ <Text style={styles.imageText}>Para cadastro, qualidade ruim !</Text>
33
+
34
+ {/* Parte gráfica da "Tela 2" */}
35
+ <View style={styles.additionalGraphics}>
36
+ <View style={styles.graphicElement1} />
37
+ <View style={styles.graphicElement2} />
38
+ </View>
39
+ </View>
40
+ <View style={styles.buttonContainer}>
41
+ <Button title="Tentar Novamente" onPress={onCloseModalHandler} />
42
+ </View>
43
+ </ScrollView>
44
+ );
45
+ };
@@ -0,0 +1,55 @@
1
+ import { Dimensions, StyleSheet } from 'react-native';
2
+
3
+ export const styles = StyleSheet.create({
4
+ container: {
5
+ paddingBottom: 30,
6
+ flex: 1,
7
+ backgroundColor: '#ffffff',
8
+ },
9
+ imageContainer: {
10
+ marginBottom: 5,
11
+ alignItems: 'center',
12
+ justifyContent: 'center',
13
+ },
14
+ image: {
15
+ width: '100%',
16
+ height: '90%',
17
+ aspectRatio: 1,
18
+ resizeMode: 'contain',
19
+ },
20
+ imageText: {
21
+ marginTop: 15,
22
+ fontSize: 16,
23
+ fontWeight: 'bold',
24
+ },
25
+ buttonContainer: {
26
+ marginBottom: 150,
27
+ alignItems: 'center',
28
+ },
29
+ additionalGraphics: {
30
+ width: '100%',
31
+ height: Dimensions.get('window').height * 0.4,
32
+ backgroundColor: 'transparent', // Ajuste a cor de fundo desejada
33
+ position: 'absolute',
34
+ alignSelf: 'center',
35
+ marginTop: '35%',
36
+ alignItems: 'center',
37
+ justifyContent: 'center',
38
+ },
39
+ graphicElement1: {
40
+ width: Dimensions.get('window').width * 0.5,
41
+ height: Dimensions.get('window').height * 0.3,
42
+ backgroundColor: 'transparent', // Ajuste o estilo desejado
43
+ borderWidth: 3,
44
+ borderColor: 'yellow',
45
+ marginLeft: 40,
46
+ borderTopLeftRadius: 60,
47
+ borderBottomLeftRadius: 60,
48
+ borderTopRightRadius: 0,
49
+ borderBottomRightRadius: 0,
50
+ transform: [{ scaleX: 2 }],
51
+ },
52
+ graphicElement2: {
53
+ // Defina o estilo para o segundo elemento gráfico
54
+ },
55
+ });
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import { CameraCadastro } from './components/CameraCadastro';
3
+ import Modal, { type ModalProps } from 'react-native-modal';
4
+ import type { ScreenProps } from '../../types/screen';
5
+
6
+ interface CadastroFingerProps {
7
+ isVisible: boolean;
8
+ onCloseModal?: () => void;
9
+ onError?: (response?: any) => void;
10
+ onSuccess?: (response?: any) => void;
11
+ ModalParams?: ModalProps;
12
+ screenProps?: ScreenProps;
13
+ onMaxAttempts?: () => void;
14
+ maxAttempts?: number;
15
+ }
16
+
17
+ export const CadastroFinger: React.FC<CadastroFingerProps> = ({
18
+ isVisible = false,
19
+ onCloseModal,
20
+ onError,
21
+ onSuccess,
22
+ ModalParams,
23
+ screenProps,
24
+ onMaxAttempts,
25
+ maxAttempts,
26
+ }) => {
27
+ const onCloseModalHandler = () => {
28
+ onCloseModal && onCloseModal();
29
+ };
30
+
31
+ return (
32
+ <Modal
33
+ // eslint-disable-next-line react-native/no-inline-styles
34
+ style={{ margin: 0 }}
35
+ isVisible={isVisible}
36
+ swipeDirection="down"
37
+ propagateSwipe={true}
38
+ onSwipeComplete={onCloseModalHandler}
39
+ {...ModalParams}
40
+ >
41
+ <CameraCadastro
42
+ maxAttempts={maxAttempts}
43
+ onMaxAttempts={onMaxAttempts}
44
+ isVisible={isVisible}
45
+ onCloseModal={onCloseModalHandler}
46
+ screenProps={screenProps}
47
+ onError={() => {
48
+ onError && onError();
49
+ }}
50
+ onSuccess={() => {
51
+ onSuccess && onSuccess();
52
+ }}
53
+ />
54
+ </Modal>
55
+ );
56
+ };