react-native-timacare 3.3.11 → 3.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/lib/commonjs/RNTimacare.js +1 -1
  2. package/lib/commonjs/RNTimacare.js.flow +2 -11
  3. package/lib/commonjs/RNTimacare.js.map +1 -1
  4. package/lib/commonjs/assets/digital_topup/index.js +2 -0
  5. package/lib/commonjs/assets/digital_topup/index.js.flow +28 -0
  6. package/lib/commonjs/assets/digital_topup/index.js.map +1 -0
  7. package/lib/commonjs/assets/digital_topup/step1.svg +31 -0
  8. package/lib/commonjs/assets/digital_topup/step1_disable.svg +31 -0
  9. package/lib/commonjs/assets/digital_topup/step1_success.svg +21 -0
  10. package/lib/commonjs/assets/digital_topup/step2.svg +39 -0
  11. package/lib/commonjs/assets/digital_topup/step2_disable.svg +16 -0
  12. package/lib/commonjs/assets/digital_topup/step2_success.svg +21 -0
  13. package/lib/commonjs/assets/digital_topup/step3.svg +23 -0
  14. package/lib/commonjs/assets/digital_topup/step3_disable.svg +10 -0
  15. package/lib/commonjs/assets/digital_topup/step3_success.svg +21 -0
  16. package/lib/commonjs/assets/digital_topup/step4_disable.svg +16 -0
  17. package/lib/commonjs/assets/digital_topup/step4_success.svg +21 -0
  18. package/lib/commonjs/components/AlertLoan.js +1 -1
  19. package/lib/commonjs/components/AlertLoan.js.flow +1 -1
  20. package/lib/commonjs/components/AlertLoan.js.map +1 -1
  21. package/lib/commonjs/components/ItemTimaOneV3.js +1 -1
  22. package/lib/commonjs/components/ItemTimaOneV3.js.flow +1 -5
  23. package/lib/commonjs/components/ItemTimaOneV3.js.map +1 -1
  24. package/lib/commonjs/components/MHeader.js +1 -1
  25. package/lib/commonjs/components/MHeader.js.flow +3 -2
  26. package/lib/commonjs/components/MHeader.js.map +1 -1
  27. package/lib/commonjs/components/ModalOptionLoan.js +1 -1
  28. package/lib/commonjs/components/ModalOptionLoan.js.flow +4 -2
  29. package/lib/commonjs/components/ModalOptionLoan.js.map +1 -1
  30. package/lib/commonjs/components/ModalOptionLoanDigital.js +2 -0
  31. package/lib/commonjs/components/ModalOptionLoanDigital.js.flow +297 -0
  32. package/lib/commonjs/components/ModalOptionLoanDigital.js.map +1 -0
  33. package/lib/commonjs/navigation/primary-navigator.js +1 -1
  34. package/lib/commonjs/navigation/primary-navigator.js.flow +0 -3
  35. package/lib/commonjs/navigation/primary-navigator.js.map +1 -1
  36. package/lib/commonjs/screens/camera/CCCDCameraScreen.js +1 -1
  37. package/lib/commonjs/screens/camera/CCCDCameraScreen.js.flow +299 -126
  38. package/lib/commonjs/screens/camera/CCCDCameraScreen.js.map +1 -1
  39. package/lib/commonjs/screens/detail-loan/QrPayment.js +1 -1
  40. package/lib/commonjs/screens/detail-loan/QrPayment.js.flow +1 -0
  41. package/lib/commonjs/screens/detail-loan/QrPayment.js.map +1 -1
  42. package/lib/commonjs/screens/detail-loan/ShowQrCode.js +1 -1
  43. package/lib/commonjs/screens/detail-loan/ShowQrCode.js.flow +1 -1
  44. package/lib/commonjs/screens/detail-loan/ShowQrCode.js.map +1 -1
  45. package/lib/commonjs/screens/home/DigitalTopupItem.js +2 -0
  46. package/lib/commonjs/screens/home/DigitalTopupItem.js.flow +562 -0
  47. package/lib/commonjs/screens/home/DigitalTopupItem.js.map +1 -0
  48. package/lib/commonjs/screens/home/index.js +1 -1
  49. package/lib/commonjs/screens/home/index.js.flow +49 -4
  50. package/lib/commonjs/screens/home/index.js.map +1 -1
  51. package/lib/commonjs/screens/liveness-v2/index.js +1 -1
  52. package/lib/commonjs/screens/liveness-v2/index.js.flow +12 -9
  53. package/lib/commonjs/screens/liveness-v2/index.js.map +1 -1
  54. package/lib/commonjs/screens/nationalID/index.js +1 -1
  55. package/lib/commonjs/screens/nationalID/index.js.flow +4 -2
  56. package/lib/commonjs/screens/nationalID/index.js.map +1 -1
  57. package/lib/commonjs/screens/nationalIDBack/index.js +1 -1
  58. package/lib/commonjs/screens/nationalIDBack/index.js.flow +3 -1
  59. package/lib/commonjs/screens/nationalIDBack/index.js.map +1 -1
  60. package/lib/commonjs/screens/toan-trinh-so/OCR.js +1 -1
  61. package/lib/commonjs/screens/toan-trinh-so/OCR.js.flow +3 -1
  62. package/lib/commonjs/screens/toan-trinh-so/OCR.js.map +1 -1
  63. package/lib/commonjs/screens/toan-trinh-so/ReviewLoan.js +1 -1
  64. package/lib/commonjs/screens/toan-trinh-so/ReviewLoan.js.flow +1 -375
  65. package/lib/commonjs/screens/toan-trinh-so/ReviewLoan.js.map +1 -1
  66. package/lib/commonjs/screens/toan-trinh-so/TTSNationalIDFront.js +1 -1
  67. package/lib/commonjs/screens/toan-trinh-so/TTSNationalIDFront.js.flow +12 -9
  68. package/lib/commonjs/screens/toan-trinh-so/TTSNationalIDFront.js.map +1 -1
  69. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js +1 -1
  70. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.flow +16 -10
  71. package/lib/commonjs/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
  72. package/lib/commonjs/screens/toan-trinh-so/TTSSignLoan.js +1 -1
  73. package/lib/commonjs/screens/toan-trinh-so/TTSSignLoan.js.flow +18 -15
  74. package/lib/commonjs/screens/toan-trinh-so/TTSSignLoan.js.map +1 -1
  75. package/lib/commonjs/screens/toan-trinh-so/TopupLoanInfo.js +1 -1
  76. package/lib/commonjs/screens/toan-trinh-so/TopupLoanInfo.js.flow +1 -1
  77. package/lib/commonjs/screens/toan-trinh-so/TopupLoanInfo.js.map +1 -1
  78. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js +1 -1
  79. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.flow +8 -1
  80. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  81. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistration.js +1 -1
  82. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistration.js.flow +20 -17
  83. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistration.js.map +1 -1
  84. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistrationFront.js +1 -1
  85. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistrationFront.js.flow +14 -9
  86. package/lib/commonjs/screens/toan-trinh-so/VehicleRegistrationFront.js.map +1 -1
  87. package/lib/commonjs/screens/uploadVideo/index.js +1 -1
  88. package/lib/commonjs/screens/uploadVideo/index.js.flow +109 -61
  89. package/lib/commonjs/screens/uploadVideo/index.js.map +1 -1
  90. package/lib/commonjs/screens/uploadVideo/videoStore.js +1 -1
  91. package/lib/commonjs/screens/uploadVideo/videoStore.js.flow +4 -4
  92. package/lib/commonjs/screens/uploadVideo/videoStore.js.map +1 -1
  93. package/lib/commonjs/sdkConfig.js +1 -1
  94. package/lib/commonjs/sdkConfig.js.flow +6 -0
  95. package/lib/commonjs/sdkConfig.js.map +1 -1
  96. package/lib/commonjs/services/api/api.js +1 -1
  97. package/lib/commonjs/services/api/api.js.flow +32 -0
  98. package/lib/commonjs/services/api/api.js.map +1 -1
  99. package/lib/module/RNTimacare.js +1 -1
  100. package/lib/module/RNTimacare.js.map +1 -1
  101. package/lib/module/assets/digital_topup/index.js +2 -0
  102. package/lib/module/assets/digital_topup/index.js.map +1 -0
  103. package/lib/module/assets/digital_topup/step1.svg +31 -0
  104. package/lib/module/assets/digital_topup/step1_disable.svg +31 -0
  105. package/lib/module/assets/digital_topup/step1_success.svg +21 -0
  106. package/lib/module/assets/digital_topup/step2.svg +39 -0
  107. package/lib/module/assets/digital_topup/step2_disable.svg +16 -0
  108. package/lib/module/assets/digital_topup/step2_success.svg +21 -0
  109. package/lib/module/assets/digital_topup/step3.svg +23 -0
  110. package/lib/module/assets/digital_topup/step3_disable.svg +10 -0
  111. package/lib/module/assets/digital_topup/step3_success.svg +21 -0
  112. package/lib/module/assets/digital_topup/step4_disable.svg +16 -0
  113. package/lib/module/assets/digital_topup/step4_success.svg +21 -0
  114. package/lib/module/components/AlertLoan.js +1 -1
  115. package/lib/module/components/AlertLoan.js.map +1 -1
  116. package/lib/module/components/ItemTimaOneV3.js +1 -1
  117. package/lib/module/components/ItemTimaOneV3.js.map +1 -1
  118. package/lib/module/components/MHeader.js +1 -1
  119. package/lib/module/components/MHeader.js.map +1 -1
  120. package/lib/module/components/ModalOptionLoan.js +1 -1
  121. package/lib/module/components/ModalOptionLoan.js.map +1 -1
  122. package/lib/module/components/ModalOptionLoanDigital.js +2 -0
  123. package/lib/module/components/ModalOptionLoanDigital.js.map +1 -0
  124. package/lib/module/navigation/primary-navigator.js +1 -1
  125. package/lib/module/navigation/primary-navigator.js.map +1 -1
  126. package/lib/module/screens/camera/CCCDCameraScreen.js +1 -1
  127. package/lib/module/screens/camera/CCCDCameraScreen.js.map +1 -1
  128. package/lib/module/screens/detail-loan/QrPayment.js +1 -1
  129. package/lib/module/screens/detail-loan/QrPayment.js.map +1 -1
  130. package/lib/module/screens/detail-loan/ShowQrCode.js +1 -1
  131. package/lib/module/screens/detail-loan/ShowQrCode.js.map +1 -1
  132. package/lib/module/screens/home/DigitalTopupItem.js +2 -0
  133. package/lib/module/screens/home/DigitalTopupItem.js.map +1 -0
  134. package/lib/module/screens/home/index.js +1 -1
  135. package/lib/module/screens/home/index.js.map +1 -1
  136. package/lib/module/screens/liveness-v2/index.js +1 -1
  137. package/lib/module/screens/liveness-v2/index.js.map +1 -1
  138. package/lib/module/screens/nationalID/index.js +1 -1
  139. package/lib/module/screens/nationalID/index.js.map +1 -1
  140. package/lib/module/screens/nationalIDBack/index.js +1 -1
  141. package/lib/module/screens/nationalIDBack/index.js.map +1 -1
  142. package/lib/module/screens/toan-trinh-so/OCR.js +1 -1
  143. package/lib/module/screens/toan-trinh-so/OCR.js.map +1 -1
  144. package/lib/module/screens/toan-trinh-so/ReviewLoan.js +1 -1
  145. package/lib/module/screens/toan-trinh-so/ReviewLoan.js.map +1 -1
  146. package/lib/module/screens/toan-trinh-so/TTSNationalIDFront.js +1 -1
  147. package/lib/module/screens/toan-trinh-so/TTSNationalIDFront.js.map +1 -1
  148. package/lib/module/screens/toan-trinh-so/TTSSelfie.js +1 -1
  149. package/lib/module/screens/toan-trinh-so/TTSSelfie.js.map +1 -1
  150. package/lib/module/screens/toan-trinh-so/TTSSignLoan.js +1 -1
  151. package/lib/module/screens/toan-trinh-so/TTSSignLoan.js.map +1 -1
  152. package/lib/module/screens/toan-trinh-so/TopupLoanInfo.js +1 -1
  153. package/lib/module/screens/toan-trinh-so/TopupLoanInfo.js.map +1 -1
  154. package/lib/module/screens/toan-trinh-so/VehicleCamera.js +1 -1
  155. package/lib/module/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  156. package/lib/module/screens/toan-trinh-so/VehicleRegistration.js +1 -1
  157. package/lib/module/screens/toan-trinh-so/VehicleRegistration.js.map +1 -1
  158. package/lib/module/screens/toan-trinh-so/VehicleRegistrationFront.js +1 -1
  159. package/lib/module/screens/toan-trinh-so/VehicleRegistrationFront.js.map +1 -1
  160. package/lib/module/screens/uploadVideo/index.js +1 -1
  161. package/lib/module/screens/uploadVideo/index.js.map +1 -1
  162. package/lib/module/screens/uploadVideo/videoStore.js +1 -1
  163. package/lib/module/screens/uploadVideo/videoStore.js.map +1 -1
  164. package/lib/module/sdkConfig.js +1 -1
  165. package/lib/module/sdkConfig.js.map +1 -1
  166. package/lib/module/services/api/api.js +1 -1
  167. package/lib/module/services/api/api.js.map +1 -1
  168. package/lib/typescript/RNTimacare.d.ts +1 -1
  169. package/lib/typescript/RNTimacare.d.ts.map +1 -1
  170. package/lib/typescript/assets/digital_topup/index.d.ts +14 -0
  171. package/lib/typescript/assets/digital_topup/index.d.ts.map +1 -0
  172. package/lib/typescript/components/ItemTimaOneV3.d.ts.map +1 -1
  173. package/lib/typescript/components/MHeader.d.ts.map +1 -1
  174. package/lib/typescript/components/ModalOptionLoan.d.ts.map +1 -1
  175. package/lib/typescript/components/ModalOptionLoanDigital.d.ts +9 -0
  176. package/lib/typescript/components/ModalOptionLoanDigital.d.ts.map +1 -0
  177. package/lib/typescript/navigation/primary-navigator.d.ts.map +1 -1
  178. package/lib/typescript/screens/camera/CCCDCameraScreen.d.ts.map +1 -1
  179. package/lib/typescript/screens/detail-loan/QrPayment.d.ts.map +1 -1
  180. package/lib/typescript/screens/home/DigitalTopupItem.d.ts +7 -0
  181. package/lib/typescript/screens/home/DigitalTopupItem.d.ts.map +1 -0
  182. package/lib/typescript/screens/home/index.d.ts.map +1 -1
  183. package/lib/typescript/screens/liveness-v2/index.d.ts.map +1 -1
  184. package/lib/typescript/screens/nationalID/index.d.ts.map +1 -1
  185. package/lib/typescript/screens/nationalIDBack/index.d.ts.map +1 -1
  186. package/lib/typescript/screens/toan-trinh-so/OCR.d.ts.map +1 -1
  187. package/lib/typescript/screens/toan-trinh-so/ReviewLoan.d.ts.map +1 -1
  188. package/lib/typescript/screens/toan-trinh-so/TTSNationalIDFront.d.ts.map +1 -1
  189. package/lib/typescript/screens/toan-trinh-so/TTSSelfie.d.ts.map +1 -1
  190. package/lib/typescript/screens/toan-trinh-so/TTSSignLoan.d.ts.map +1 -1
  191. package/lib/typescript/screens/toan-trinh-so/VehicleCamera.d.ts.map +1 -1
  192. package/lib/typescript/screens/toan-trinh-so/VehicleRegistration.d.ts.map +1 -1
  193. package/lib/typescript/screens/toan-trinh-so/VehicleRegistrationFront.d.ts.map +1 -1
  194. package/lib/typescript/screens/uploadVideo/index.d.ts.map +1 -1
  195. package/lib/typescript/sdkConfig.d.ts.map +1 -1
  196. package/lib/typescript/services/api/api.d.ts +32 -0
  197. package/lib/typescript/services/api/api.d.ts.map +1 -1
  198. package/package.json +3 -2
  199. package/src/RNTimacare.tsx +2 -11
  200. package/src/assets/digital_topup/index.tsx +28 -0
  201. package/src/assets/digital_topup/step1.svg +31 -0
  202. package/src/assets/digital_topup/step1_disable.svg +31 -0
  203. package/src/assets/digital_topup/step1_success.svg +21 -0
  204. package/src/assets/digital_topup/step2.svg +39 -0
  205. package/src/assets/digital_topup/step2_disable.svg +16 -0
  206. package/src/assets/digital_topup/step2_success.svg +21 -0
  207. package/src/assets/digital_topup/step3.svg +23 -0
  208. package/src/assets/digital_topup/step3_disable.svg +10 -0
  209. package/src/assets/digital_topup/step3_success.svg +21 -0
  210. package/src/assets/digital_topup/step4_disable.svg +16 -0
  211. package/src/assets/digital_topup/step4_success.svg +21 -0
  212. package/src/components/AlertLoan.tsx +1 -1
  213. package/src/components/ItemTimaOneV3.tsx +1 -5
  214. package/src/components/MHeader.tsx +3 -2
  215. package/src/components/ModalOptionLoan.tsx +4 -2
  216. package/src/components/ModalOptionLoanDigital.tsx +297 -0
  217. package/src/navigation/primary-navigator.tsx +0 -3
  218. package/src/screens/camera/CCCDCameraScreen.tsx +299 -126
  219. package/src/screens/detail-loan/QrPayment.tsx +1 -0
  220. package/src/screens/detail-loan/ShowQrCode.tsx +1 -1
  221. package/src/screens/home/DigitalTopupItem.tsx +562 -0
  222. package/src/screens/home/index.tsx +49 -4
  223. package/src/screens/liveness-v2/index.tsx +12 -9
  224. package/src/screens/nationalID/index.tsx +4 -2
  225. package/src/screens/nationalIDBack/index.tsx +3 -1
  226. package/src/screens/toan-trinh-so/OCR.tsx +3 -1
  227. package/src/screens/toan-trinh-so/ReviewLoan.tsx +1 -375
  228. package/src/screens/toan-trinh-so/TTSNationalIDFront.tsx +12 -9
  229. package/src/screens/toan-trinh-so/TTSSelfie.tsx +16 -10
  230. package/src/screens/toan-trinh-so/TTSSignLoan.tsx +18 -15
  231. package/src/screens/toan-trinh-so/TopupLoanInfo.tsx +1 -1
  232. package/src/screens/toan-trinh-so/VehicleCamera.tsx +8 -1
  233. package/src/screens/toan-trinh-so/VehicleRegistration.tsx +20 -17
  234. package/src/screens/toan-trinh-so/VehicleRegistrationFront.tsx +14 -9
  235. package/src/screens/uploadVideo/index.tsx +109 -61
  236. package/src/screens/uploadVideo/videoStore.tsx +4 -4
  237. package/src/sdkConfig.ts +6 -0
  238. package/src/services/api/api.ts +32 -0
@@ -12,25 +12,88 @@ import {
12
12
  import {
13
13
  Camera,
14
14
  useCameraDevice,
15
+ useCameraFormat,
15
16
  useCameraPermission,
16
17
  } from 'react-native-vision-camera';
17
18
  import { IconBackWhite, TakePhotoSvg } from '../../assets/icons';
18
19
  import { MText } from '../../components/MText';
19
- import ImageEditor from '@react-native-community/image-editor';
20
- import { CommonActions, useNavigation } from '@react-navigation/native';
21
- import DeviceInfo from 'react-native-device-info';
20
+ import { useNavigation } from '@react-navigation/native';
21
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
22
+ import RNImageManipulator from '@oguzhnatly/react-native-image-manipulator';
22
23
 
23
24
  const { width: screenWidth, height: screenHeight } = Dimensions.get('window');
24
- const frameWidth = screenWidth * 0.85;
25
- const frameHeight = frameWidth * 0.63; // tỷ lệ giống CCCD
26
- const frameLeft = (screenWidth - frameWidth) / 2;
27
- const frameTop = ((screenWidth * 4) / 3 - frameHeight) / 2;
25
+
26
+ const getImageSize = (
27
+ uri: string
28
+ ): Promise<{ width: number; height: number }> =>
29
+ new Promise((resolve, reject) => {
30
+ Image.getSize(
31
+ uri,
32
+ (width, height) => resolve({ width, height }),
33
+ (err) => reject(err)
34
+ );
35
+ });
36
+
37
+ const clamp = (value: number, min: number, max: number) =>
38
+ Math.min(Math.max(value, min), max);
39
+
40
+ const getSnapshotCropRect = ({
41
+ imageWidth,
42
+ imageHeight,
43
+ previewWidth,
44
+ previewHeight,
45
+ frameX,
46
+ frameY,
47
+ frameWidth,
48
+ frameHeight,
49
+ }: {
50
+ imageWidth: number;
51
+ imageHeight: number;
52
+ previewWidth: number;
53
+ previewHeight: number;
54
+ frameX: number;
55
+ frameY: number;
56
+ frameWidth: number;
57
+ frameHeight: number;
58
+ }) => {
59
+ const scaleX = imageWidth / previewWidth;
60
+ const scaleY = imageHeight / previewHeight;
61
+ const originX = clamp(frameX * scaleX, 0, imageWidth);
62
+ const originY = clamp(frameY * scaleY, 0, imageHeight);
63
+ const width = clamp(frameWidth * scaleX, 1, imageWidth - originX);
64
+ const height = clamp(frameHeight * scaleY, 1, imageHeight - originY);
65
+
66
+ return {
67
+ originX: Math.round(originX),
68
+ originY: Math.round(originY),
69
+ width: Math.round(width),
70
+ height: Math.round(height),
71
+ };
72
+ };
73
+
28
74
  export default function CCCDCameraScreen(props) {
75
+ const insets = useSafeAreaInsets();
29
76
  const navigation = useNavigation();
30
77
  const camera = useRef(null);
31
78
  const device = useCameraDevice('back');
32
79
  const [cameraActive, setCameraActive] = useState(true);
33
80
  const { hasPermission, requestPermission } = useCameraPermission();
81
+ const [previewLayout, setPreviewLayout] = useState({
82
+ width: screenWidth,
83
+ height: screenHeight,
84
+ });
85
+
86
+ const format = useCameraFormat(device, [
87
+ {
88
+ photoAspectRatio: previewLayout.height / previewLayout.width,
89
+ },
90
+ {
91
+ videoAspectRatio: previewLayout.height / previewLayout.width,
92
+ },
93
+ {
94
+ photoResolution: 'max',
95
+ },
96
+ ]);
34
97
 
35
98
  useEffect(() => {
36
99
  if (!hasPermission) requestPermission();
@@ -38,84 +101,194 @@ export default function CCCDCameraScreen(props) {
38
101
 
39
102
  const takePicture = async () => {
40
103
  if (camera.current == null) return;
104
+ try {
105
+ const snapshot = await camera.current.takeSnapshot({
106
+ quality: 100,
107
+ });
108
+ const imageUri = `file://${snapshot.path}`;
109
+ const normalized = await RNImageManipulator.manipulate(imageUri, [], {
110
+ format: 'jpg',
111
+ compress: 1,
112
+ });
113
+ const { width: imageWidth, height: imageHeight } = await getImageSize(
114
+ normalized.uri
115
+ );
116
+
117
+ const previewWidth = previewLayout.width;
118
+ const previewHeight = previewLayout.height;
119
+
120
+ const frameWidth = previewWidth * 0.85;
121
+ const frameHeight = frameWidth * 0.63;
122
+ const frameX = (previewWidth - frameWidth) / 2;
123
+ const frameY = (previewHeight - frameHeight) / 2;
41
124
 
42
- const photo = await camera.current.takePhoto({
43
- skipMetadata: true,
44
- });
45
-
46
- Image.getSize(`file://${photo.path}`, async (width, height) => {
47
- const previewHeight = (screenWidth * 4) / 3; // Tỷ lệ khung preview camera
48
-
49
- // Tính scale giữa ảnh thật và khung preview
50
- const scaleX = width / screenWidth;
51
- const scaleY = height / previewHeight;
52
-
53
- // Tính tọa độ vùng cần crop trên ảnh gốc
54
- const cropData = {
55
- offset: {
56
- x: frameLeft * scaleX,
57
- y: frameTop * scaleY,
58
- },
59
- size: {
60
- width: frameWidth * scaleX,
61
- height: frameHeight * scaleY,
62
- },
63
- displaySize: {
64
- width: frameWidth * scaleX,
65
- height: frameHeight * scaleY,
66
- },
67
- resizeMode: 'contain',
68
- };
69
-
70
- try {
71
- const croppedUri = await ImageEditor.cropImage(
72
- `file://${photo.path}`,
73
- cropData
74
- );
75
- setCameraActive(false);
76
- navigation.goBack();
77
- if (props.route.params.callback) {
78
- props.route.params.callback(croppedUri.uri);
79
- }
80
- } catch (err) {
81
- console.error(err);
125
+ const cropRect = getSnapshotCropRect({
126
+ imageWidth,
127
+ imageHeight,
128
+ previewWidth,
129
+ previewHeight,
130
+ frameX,
131
+ frameY,
132
+ frameWidth,
133
+ frameHeight,
134
+ });
135
+
136
+ const result = await RNImageManipulator.manipulate(
137
+ normalized.uri,
138
+ [
139
+ {
140
+ crop: cropRect,
141
+ },
142
+ ],
143
+ { format: 'jpg', compress: 1 }
144
+ );
145
+ setCameraActive(false);
146
+ navigation.goBack();
147
+ if (props.route?.params?.callback) {
148
+ props.route.params.callback(result?.uri);
82
149
  }
83
- });
150
+ } catch (err) {
151
+ console.error(err);
152
+ }
84
153
  };
85
154
 
86
155
  if (!device || !hasPermission)
87
- return <View style={{ flex: 1, backgroundColor: '#000' }} />;
156
+ return (
157
+ <View
158
+ style={{
159
+ flex: 1,
160
+ backgroundColor: '#000',
161
+ alignItems: 'center',
162
+ justifyContent: 'center',
163
+ }}
164
+ >
165
+ <MText style={{ color: '#fff' }}>
166
+ Vui lòng cấp quyền truy cập Camera
167
+ </MText>
168
+ </View>
169
+ );
170
+
171
+ const frameWidth = previewLayout.width * 0.85;
172
+ const frameHeight = frameWidth * 0.63;
173
+ const frameX = (previewLayout.width - frameWidth) / 2;
174
+ const frameY = (previewLayout.height - frameHeight) / 2;
175
+
88
176
  return (
89
- <View style={styles.container}>
90
- <View style={styles.topContainer}>
177
+ <View
178
+ style={$container}
179
+ onLayout={(e) => {
180
+ const { width, height } = e.nativeEvent.layout;
181
+ if (width > 0 && height > 0) setPreviewLayout({ width, height });
182
+ }}
183
+ >
184
+ <Camera
185
+ style={{ flex: 1 }}
186
+ device={device}
187
+ isActive={cameraActive}
188
+ photo={false}
189
+ video={true}
190
+ outputOrientation="preview"
191
+ ref={camera}
192
+ format={format}
193
+ resizeMode="cover"
194
+ />
195
+ <View style={$overlay} pointerEvents="none">
196
+ <View style={[$darkOverlayTop, { height: frameY }]} />
197
+ <View style={$row}>
198
+ <View
199
+ style={[$darkOverlaySide, { width: frameX, height: frameHeight }]}
200
+ />
201
+ <View
202
+ style={[$frameBorder, { width: frameWidth, height: frameHeight }]}
203
+ >
204
+ {/* Top Left */}
205
+ <Corner
206
+ style={{
207
+ top: 0,
208
+ left: 0,
209
+ borderTopWidth: CORNER_WIDTH,
210
+ borderLeftWidth: CORNER_WIDTH,
211
+ borderColor: BORDER_COLOR,
212
+ }}
213
+ />
214
+
215
+ {/* Top Right */}
216
+ <Corner
217
+ style={{
218
+ top: 0,
219
+ right: 0,
220
+ borderTopWidth: CORNER_WIDTH,
221
+ borderRightWidth: CORNER_WIDTH,
222
+ borderColor: BORDER_COLOR,
223
+ }}
224
+ />
225
+
226
+ {/* Bottom Left */}
227
+ <Corner
228
+ style={{
229
+ bottom: 0,
230
+ left: 0,
231
+ borderBottomWidth: CORNER_WIDTH,
232
+ borderLeftWidth: CORNER_WIDTH,
233
+ borderColor: BORDER_COLOR,
234
+ }}
235
+ />
236
+
237
+ {/* Bottom Right */}
238
+ <Corner
239
+ style={{
240
+ bottom: 0,
241
+ right: 0,
242
+ borderBottomWidth: CORNER_WIDTH,
243
+ borderRightWidth: CORNER_WIDTH,
244
+ borderColor: BORDER_COLOR,
245
+ }}
246
+ />
247
+ </View>
248
+ <View
249
+ style={[$darkOverlaySide, { width: frameX, height: frameHeight }]}
250
+ />
251
+ </View>
252
+ <View style={[$darkOverlayBottom, { height: frameY }]} />
253
+ </View>
254
+ <View style={[$back, { top: insets.top + 16 }]}>
91
255
  <TouchableOpacity
92
256
  onPress={() => {
93
257
  navigation.goBack();
94
258
  }}
95
- style={[
96
- { width: 48, height: 48, zIndex: 1000, alignItems: 'center' },
97
- ]}
259
+ style={{
260
+ position: 'absolute',
261
+ left: 0,
262
+ width: 48,
263
+ height: 48,
264
+ zIndex: 1000,
265
+ alignItems: 'center',
266
+ }}
98
267
  >
99
268
  <IconBackWhite />
100
269
  </TouchableOpacity>
270
+ <MText
271
+ style={{
272
+ textAlign: 'center',
273
+ zIndex: 10,
274
+ color: '#FFFFFF',
275
+ fontSize: 16,
276
+ }}
277
+ >
278
+ {props?.route?.params?.front
279
+ ? 'Chụp CMND/ CCCD mặt trước'
280
+ : 'Chụp CMND/ CCCD mặt sau'}
281
+ </MText>
101
282
  </View>
102
- <Camera
103
- style={styles.camera}
104
- device={device}
105
- isActive={cameraActive}
106
- photo={true}
107
- ref={camera}
108
- />
109
- <View style={styles.overlay}>
110
- <View style={styles.darkOverlayTop} />
111
- <View style={styles.row}>
112
- <View style={styles.darkOverlaySide} />
113
- <View style={styles.frameBorder} />
114
- <View style={styles.darkOverlaySide} />
115
- </View>
116
- <View style={styles.darkOverlayBottom} />
117
- </View>
118
- <View style={styles.captureButton}>
283
+ <View
284
+ style={{
285
+ position: 'absolute',
286
+ bottom: 24 + insets.bottom,
287
+ alignSelf: 'center',
288
+ flexDirection: 'column',
289
+ alignItems: 'center',
290
+ }}
291
+ >
119
292
  <MText
120
293
  style={{
121
294
  color: '#fff',
@@ -135,59 +308,59 @@ export default function CCCDCameraScreen(props) {
135
308
  );
136
309
  }
137
310
 
311
+ const CORNER_SIZE = 20;
312
+ const CORNER_WIDTH = 2;
313
+ const BORDER_COLOR = '#FDFDFD';
314
+
315
+ const Corner = ({ style }: { style: ViewStyle }) => (
316
+ <View
317
+ style={[
318
+ style,
319
+ {
320
+ position: 'absolute',
321
+ width: CORNER_SIZE,
322
+ height: CORNER_SIZE,
323
+ },
324
+ ]}
325
+ />
326
+ );
327
+
138
328
  const overlayColor = 'rgba(22, 22, 22, 0.7)';
139
- const styles = StyleSheet.create({
140
- container: { flex: 1, backgroundColor: '#000' },
141
- camera: { flex: 1 },
142
- overlay: {
143
- ...StyleSheet.absoluteFillObject,
144
- justifyContent: 'center',
145
- alignItems: 'center',
146
- },
147
- frameBorder: {
148
- width: frameWidth,
149
- height: frameHeight,
150
- borderColor: '#FDFDFD',
151
- borderWidth: 2,
152
- },
153
- row: {
154
- flexDirection: 'row',
155
- alignItems: 'center',
156
- },
157
- darkOverlayTop: {
158
- width: '100%',
159
- height: (screenHeight - frameHeight) / 2,
160
- backgroundColor: overlayColor,
161
- },
162
- darkOverlayBottom: {
163
- width: '100%',
164
- height: (screenHeight - frameHeight) / 2,
165
- backgroundColor: overlayColor,
166
- },
167
- darkOverlaySide: {
168
- width: (screenWidth - frameWidth) / 2,
169
- height: frameHeight,
170
- backgroundColor: overlayColor,
171
- },
172
- captureContainer: {
173
- position: 'absolute',
174
- bottom: 40,
175
- width: '100%',
176
- alignItems: 'center',
177
- },
178
- captureButton: {
179
- position: 'absolute',
180
- bottom: 30,
181
- alignSelf: 'center',
182
- flexDirection: 'column',
183
- alignItems: 'center',
184
- },
185
- topContainer: {
186
- position: 'absolute',
187
- top: DeviceInfo.hasNotch() ? 60 : 24,
188
- },
189
- textContainer: {
190
- position: 'absolute',
191
- top: DeviceInfo.hasNotch() ? 60 : 24,
192
- },
193
- });
329
+ const $back: ViewStyle = {
330
+ position: 'absolute',
331
+ left: 0,
332
+ right: 0,
333
+ };
334
+
335
+ const $overlay: ViewStyle = {
336
+ ...StyleSheet.absoluteFillObject,
337
+ justifyContent: 'center',
338
+ alignItems: 'center',
339
+ };
340
+
341
+ const $container: ViewStyle = {
342
+ flex: 1,
343
+ backgroundColor: '#000',
344
+ };
345
+
346
+ const $row: ViewStyle = {
347
+ flexDirection: 'row',
348
+ alignItems: 'center',
349
+ };
350
+
351
+ const $darkOverlayTop: ViewStyle = {
352
+ width: '100%',
353
+ backgroundColor: overlayColor,
354
+ };
355
+
356
+ const $darkOverlayBottom: ViewStyle = {
357
+ width: '100%',
358
+ backgroundColor: overlayColor,
359
+ };
360
+ const $darkOverlaySide: ViewStyle = {
361
+ backgroundColor: overlayColor,
362
+ };
363
+ const $frameBorder: ViewStyle = {
364
+ // borderColor: '#FDFDFD',
365
+ // borderWidth: 2,
366
+ };
@@ -89,6 +89,7 @@ export const QrPayment = observer(function QrPayment(props: any) {
89
89
  paddingHorizontal: 16,
90
90
  marginTop: 8,
91
91
  fontSize: 16,
92
+ color: '#333333',
92
93
  }}
93
94
  onChangeText={(text) => {
94
95
  const numericValue = text.replace(/\D/g, '');
@@ -34,7 +34,7 @@ export const ShowQrCode = observer(function ShowQrCode(props: any) {
34
34
  .getQrPayment({
35
35
  LoanBriefId: props?.route?.params?.id,
36
36
  TypeCloseLoan: 0, // đóng tiền kỳ
37
- Money: props?.route?.params?.amount,
37
+ Money: Number(props?.route?.params?.amount),
38
38
  })
39
39
  .then((response) => {
40
40
  setIsLoading(false);