react-native-timacare 3.1.30-production → 3.1.32-production

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 (49) hide show
  1. package/lib/commonjs/screens/home/index.js +1 -1
  2. package/lib/commonjs/screens/home/index.js.flow +5 -27
  3. package/lib/commonjs/screens/home/index.js.map +1 -1
  4. package/lib/commonjs/screens/toan-trinh-so/OCR.js +1 -1
  5. package/lib/commonjs/screens/toan-trinh-so/OCR.js.flow +49 -72
  6. package/lib/commonjs/screens/toan-trinh-so/OCR.js.map +1 -1
  7. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js +1 -1
  8. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js.flow +44 -70
  9. package/lib/commonjs/screens/toan-trinh-so/RegisterCamera.js.map +1 -1
  10. package/lib/commonjs/screens/toan-trinh-so/ReviewInformation.js +1 -1
  11. package/lib/commonjs/screens/toan-trinh-so/ReviewInformation.js.flow +10 -3
  12. package/lib/commonjs/screens/toan-trinh-so/ReviewInformation.js.map +1 -1
  13. package/lib/commonjs/screens/toan-trinh-so/ReviewInformationOther.js +1 -1
  14. package/lib/commonjs/screens/toan-trinh-so/ReviewInformationOther.js.flow +4 -4
  15. package/lib/commonjs/screens/toan-trinh-so/ReviewInformationOther.js.map +1 -1
  16. package/lib/commonjs/screens/toan-trinh-so/ReviewLoan.js +1 -1
  17. package/lib/commonjs/screens/toan-trinh-so/ReviewLoan.js.flow +8 -3
  18. package/lib/commonjs/screens/toan-trinh-so/ReviewLoan.js.map +1 -1
  19. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js +1 -1
  20. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.flow +42 -68
  21. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  22. package/lib/module/screens/home/index.js +1 -1
  23. package/lib/module/screens/home/index.js.map +1 -1
  24. package/lib/module/screens/toan-trinh-so/OCR.js +1 -1
  25. package/lib/module/screens/toan-trinh-so/OCR.js.map +1 -1
  26. package/lib/module/screens/toan-trinh-so/RegisterCamera.js +1 -1
  27. package/lib/module/screens/toan-trinh-so/RegisterCamera.js.map +1 -1
  28. package/lib/module/screens/toan-trinh-so/ReviewInformation.js +1 -1
  29. package/lib/module/screens/toan-trinh-so/ReviewInformation.js.map +1 -1
  30. package/lib/module/screens/toan-trinh-so/ReviewInformationOther.js +1 -1
  31. package/lib/module/screens/toan-trinh-so/ReviewInformationOther.js.map +1 -1
  32. package/lib/module/screens/toan-trinh-so/ReviewLoan.js +1 -1
  33. package/lib/module/screens/toan-trinh-so/ReviewLoan.js.map +1 -1
  34. package/lib/module/screens/toan-trinh-so/VehicleCamera.js +1 -1
  35. package/lib/module/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  36. package/lib/typescript/screens/home/index.d.ts.map +1 -1
  37. package/lib/typescript/screens/toan-trinh-so/OCR.d.ts.map +1 -1
  38. package/lib/typescript/screens/toan-trinh-so/RegisterCamera.d.ts.map +1 -1
  39. package/lib/typescript/screens/toan-trinh-so/ReviewInformation.d.ts.map +1 -1
  40. package/lib/typescript/screens/toan-trinh-so/ReviewLoan.d.ts.map +1 -1
  41. package/lib/typescript/screens/toan-trinh-so/VehicleCamera.d.ts.map +1 -1
  42. package/package.json +2 -1
  43. package/src/screens/home/index.tsx +5 -27
  44. package/src/screens/toan-trinh-so/OCR.tsx +49 -72
  45. package/src/screens/toan-trinh-so/RegisterCamera.tsx +44 -70
  46. package/src/screens/toan-trinh-so/ReviewInformation.tsx +10 -3
  47. package/src/screens/toan-trinh-so/ReviewInformationOther.tsx +4 -4
  48. package/src/screens/toan-trinh-so/ReviewLoan.tsx +8 -3
  49. package/src/screens/toan-trinh-so/VehicleCamera.tsx +42 -68
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-timacare",
3
- "version": "3.1.30-production",
3
+ "version": "3.1.32-production",
4
4
  "description": "SDK Tima Care",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -88,6 +88,7 @@
88
88
  "react-native-geolocation-service": "*",
89
89
  "react-native-gesture-handler": "*",
90
90
  "react-native-image-crop-picker": "*",
91
+ "react-native-image-picker": "*",
91
92
  "react-native-image-pan-zoom": "*",
92
93
  "react-native-image-slider-box": "*",
93
94
  "react-native-image-viewing": "*",
@@ -644,32 +644,6 @@ export const Home = observer(function Home() {
644
644
  </View>
645
645
  </View>
646
646
  )}
647
- {/* <View
648
- style={{
649
- flexDirection: 'row',
650
- alignItems: 'center',
651
- }}
652
- >
653
- <Contract />
654
- <View style={{ flex: 1, paddingLeft: 8 }}>
655
- <MText style={commonStyles.textNormalBold}>
656
- Mã Đơn vay-{item?.id}
657
- </MText>
658
- <MText style={commonStyles.textNormal}>
659
- Số tiền vay (VND):{' '}
660
- {item?.loanAmount
661
- ? formatMoney(item?.loanAmount)
662
- : 'Chưa xác định'}
663
- </MText>
664
- </View>
665
- </View>
666
- <View
667
- style={{
668
- height: 1,
669
- backgroundColor: '#E0E0E0',
670
- marginVertical: 16,
671
- }}
672
- /> */}
673
647
 
674
648
  <View
675
649
  style={{
@@ -1057,7 +1031,11 @@ export const Home = observer(function Home() {
1057
1031
  key={index}
1058
1032
  style={{
1059
1033
  marginTop: 8,
1060
- borderBottomWidth: 1,
1034
+ borderBottomWidth:
1035
+ index + 1 ===
1036
+ item?.listLoanAllAutoDE.length
1037
+ ? 0
1038
+ : 1,
1061
1039
  borderColor: '#E0E0E0',
1062
1040
  paddingBottom: 8,
1063
1041
  }}
@@ -14,7 +14,7 @@ import {
14
14
  Dimensions,
15
15
  StyleSheet,
16
16
  Alert,
17
- PermissionsAndroid,
17
+ Platform,
18
18
  } from 'react-native';
19
19
  import { MText } from '../../components/MText';
20
20
  import { load, OCR_V1, save } from '../../utils/storage';
@@ -49,6 +49,7 @@ import Loading from '../../components/Loading';
49
49
  import DeviceInfo from 'react-native-device-info';
50
50
  import { IconUpload } from '../../assets/svgs';
51
51
  import ImagePicker from 'react-native-image-crop-picker';
52
+ import { launchImageLibrary } from 'react-native-image-picker';
52
53
 
53
54
  const { NFCReader } = NativeModules;
54
55
 
@@ -149,7 +150,6 @@ export const OCR = observer(function OCR(props: any) {
149
150
 
150
151
  useEffect(() => {
151
152
  let timeout: NodeJS.Timeout;
152
-
153
153
  if (isFocused) {
154
154
  // Delay mounting camera to give Android time to release the previous one
155
155
  timeout = setTimeout(() => {
@@ -319,78 +319,55 @@ export const OCR = observer(function OCR(props: any) {
319
319
  }
320
320
  };
321
321
 
322
- const hasAndroidPermission = async () => {
323
- const getCheckPermissionPromise = () => {
324
- if (Number(Platform.Version) >= 33) {
325
- return Promise.all([
326
- PermissionsAndroid.check(
327
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES
328
- ),
329
- PermissionsAndroid.check(
330
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO
331
- ),
332
- ]).then(
333
- ([hasReadMediaImagesPermission, hasReadMediaVideoPermission]) =>
334
- hasReadMediaImagesPermission && hasReadMediaVideoPermission
335
- );
336
- } else {
337
- return PermissionsAndroid.check(
338
- PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE
339
- );
340
- }
341
- };
342
- const hasPermission = await getCheckPermissionPromise();
343
- if (hasPermission) {
344
- return true;
345
- }
346
-
347
- const getRequestPermissionPromise = () => {
348
- if (Number(Platform.Version) >= 33) {
349
- return PermissionsAndroid.requestMultiple([
350
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES,
351
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO,
352
- ]).then(
353
- (statuses) =>
354
- statuses[PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES] ===
355
- PermissionsAndroid.RESULTS.GRANTED &&
356
- statuses[PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO] ===
357
- PermissionsAndroid.RESULTS.GRANTED
358
- );
359
- } else {
360
- return PermissionsAndroid.request(
361
- PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE
362
- ).then((status) => status === PermissionsAndroid.RESULTS.GRANTED);
363
- }
364
- };
365
-
366
- return await getRequestPermissionPromise();
367
- };
368
-
369
322
  const pickImageFromGallery = async () => {
370
- await hasAndroidPermission();
371
- ImagePicker.openPicker({}).then((image) => {
372
- if (props?.route?.params?.front && !props.route?.params?.callback) {
373
- navigation.push(ScreenNames.TTSNationalIDFront, {
374
- uri:
375
- Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
376
- loan: props?.route?.params?.loan,
377
- });
378
- } else if (
379
- !props?.route?.params?.front &&
380
- !props.route?.params?.callback
381
- ) {
382
- navigation.push(ScreenNames.TTSNationalIDBack, {
383
- uri:
384
- Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
385
- loan: props?.route?.params?.loan,
386
- });
387
- } else {
388
- navigation.goBack();
389
- props.route?.params?.callback(
390
- Platform.OS === 'android' ? image?.path : 'file://' + image?.path
391
- );
323
+ if (Platform.OS === 'android') {
324
+ const result = await launchImageLibrary({
325
+ mediaType: 'photo',
326
+ });
327
+ if (result.assets) {
328
+ if (props?.route?.params?.front && !props.route?.params?.callback) {
329
+ navigation.push(ScreenNames.TTSNationalIDFront, {
330
+ uri: result.assets[0]?.uri,
331
+ loan: props?.route?.params?.loan,
332
+ });
333
+ } else if (
334
+ !props?.route?.params?.front &&
335
+ !props.route?.params?.callback
336
+ ) {
337
+ navigation.push(ScreenNames.TTSNationalIDBack, {
338
+ uri: result.assets[0]?.uri,
339
+ loan: props?.route?.params?.loan,
340
+ });
341
+ } else {
342
+ navigation.goBack();
343
+ props.route?.params?.callback(result.assets[0]?.uri);
344
+ }
392
345
  }
393
- });
346
+ } else {
347
+ ImagePicker.openPicker({}).then((image) => {
348
+ if (props?.route?.params?.front && !props.route?.params?.callback) {
349
+ navigation.push(ScreenNames.TTSNationalIDFront, {
350
+ uri:
351
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
352
+ loan: props?.route?.params?.loan,
353
+ });
354
+ } else if (
355
+ !props?.route?.params?.front &&
356
+ !props.route?.params?.callback
357
+ ) {
358
+ navigation.push(ScreenNames.TTSNationalIDBack, {
359
+ uri:
360
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
361
+ loan: props?.route?.params?.loan,
362
+ });
363
+ } else {
364
+ navigation.goBack();
365
+ props.route?.params?.callback(
366
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path
367
+ );
368
+ }
369
+ });
370
+ }
394
371
  };
395
372
 
396
373
  return (
@@ -5,7 +5,6 @@ import {
5
5
  Dimensions,
6
6
  Image,
7
7
  ImageStyle,
8
- PermissionsAndroid,
9
8
  Platform,
10
9
  SafeAreaView,
11
10
  TextStyle,
@@ -41,6 +40,7 @@ import { ScreenNames } from '../../navigation';
41
40
  import DeviceInfo from 'react-native-device-info';
42
41
  import ImagePicker from 'react-native-image-crop-picker';
43
42
  import { IconUpload } from '../../assets/svgs';
43
+ import { launchImageLibrary } from 'react-native-image-picker';
44
44
 
45
45
  export default function RegisterCamera(props: any) {
46
46
  const isFocused = useIsFocused();
@@ -189,75 +189,49 @@ export default function RegisterCamera(props: any) {
189
189
  }
190
190
  };
191
191
 
192
- const hasAndroidPermission = async () => {
193
- const getCheckPermissionPromise = () => {
194
- if (Number(Platform.Version) >= 33) {
195
- return Promise.all([
196
- PermissionsAndroid.check(
197
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES
198
- ),
199
- PermissionsAndroid.check(
200
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO
201
- ),
202
- ]).then(
203
- ([hasReadMediaImagesPermission, hasReadMediaVideoPermission]) =>
204
- hasReadMediaImagesPermission && hasReadMediaVideoPermission
205
- );
206
- } else {
207
- return PermissionsAndroid.check(
208
- PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE
209
- );
210
- }
211
- };
212
- const hasPermission = await getCheckPermissionPromise();
213
- if (hasPermission) {
214
- return true;
215
- }
216
-
217
- const getRequestPermissionPromise = () => {
218
- if (Number(Platform.Version) >= 33) {
219
- return PermissionsAndroid.requestMultiple([
220
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES,
221
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO,
222
- ]).then(
223
- (statuses) =>
224
- statuses[PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES] ===
225
- PermissionsAndroid.RESULTS.GRANTED &&
226
- statuses[PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO] ===
227
- PermissionsAndroid.RESULTS.GRANTED
228
- );
229
- } else {
230
- return PermissionsAndroid.request(
231
- PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE
232
- ).then((status) => status === PermissionsAndroid.RESULTS.GRANTED);
233
- }
234
- };
235
-
236
- return await getRequestPermissionPromise();
237
- };
238
-
239
192
  const pickImageFromGallery = async () => {
240
- await hasAndroidPermission();
241
- ImagePicker.openPicker({}).then((image) => {
242
- if (props?.route?.params?.front) {
243
- navigation.push(ScreenNames.VehicleRegistration, {
244
- uri:
245
- Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
246
- loan: props?.route?.params?.loan,
247
- });
248
- } else if (props.route?.params?.callback) {
249
- navigation.goBack();
250
- props.route?.params?.callback(
251
- Platform.OS === 'android' ? image?.path : 'file://' + image?.path
252
- );
253
- } else {
254
- navigation.push(ScreenNames.RegisterBack, {
255
- uri:
256
- Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
257
- loan: props?.route?.params?.loan,
258
- });
193
+ if (Platform.OS === 'android') {
194
+ const result = await launchImageLibrary({
195
+ mediaType: 'photo',
196
+ });
197
+ if (result.assets) {
198
+ if (props?.route?.params?.front) {
199
+ navigation.push(ScreenNames.VehicleRegistration, {
200
+ uri: result.assets[0]?.uri,
201
+ loan: props?.route?.params?.loan,
202
+ });
203
+ } else if (props.route?.params?.callback) {
204
+ navigation.goBack();
205
+ props.route?.params?.callback(result.assets[0]?.uri);
206
+ } else {
207
+ navigation.push(ScreenNames.RegisterBack, {
208
+ uri: result.assets[0]?.uri,
209
+ loan: props?.route?.params?.loan,
210
+ });
211
+ }
259
212
  }
260
- });
213
+ } else {
214
+ ImagePicker.openPicker({}).then((image) => {
215
+ if (props?.route?.params?.front) {
216
+ navigation.push(ScreenNames.VehicleRegistration, {
217
+ uri:
218
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
219
+ loan: props?.route?.params?.loan,
220
+ });
221
+ } else if (props.route?.params?.callback) {
222
+ navigation.goBack();
223
+ props.route?.params?.callback(
224
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path
225
+ );
226
+ } else {
227
+ navigation.push(ScreenNames.RegisterBack, {
228
+ uri:
229
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
230
+ loan: props?.route?.params?.loan,
231
+ });
232
+ }
233
+ });
234
+ }
261
235
  };
262
236
  return (
263
237
  <View
@@ -279,7 +253,7 @@ export default function RegisterCamera(props: any) {
279
253
  <View
280
254
  style={{
281
255
  marginVertical: 16,
282
- marginTop: DeviceInfo.hasNotch() ? 70 : 0,
256
+ marginTop: DeviceInfo.hasNotch() ? 70 : 8,
283
257
  }}
284
258
  >
285
259
  <TouchableOpacity
@@ -383,7 +357,7 @@ export default function RegisterCamera(props: any) {
383
357
  <View
384
358
  style={{
385
359
  alignItems: 'center',
386
- marginVertical: 24,
360
+ marginVertical: DeviceInfo.hasNotch() ? 24 : 16,
387
361
  }}
388
362
  >
389
363
  <MButton
@@ -100,7 +100,10 @@ export default function ReviewInformation(props) {
100
100
  ? formatDDMMYYY(response?.data?.data?.dob)
101
101
  : ''
102
102
  );
103
- formRef.current.setFieldValue('gender', response?.data?.data?.gender);
103
+ formRef.current.setFieldValue(
104
+ 'gender',
105
+ response?.data?.data?.gender ?? null
106
+ );
104
107
  formRef.current.setFieldValue(
105
108
  'nationalCard',
106
109
  response?.data?.data?.nationalCard
@@ -297,7 +300,7 @@ export default function ReviewInformation(props) {
297
300
  initialValues={{
298
301
  fullName: '',
299
302
  dob: '',
300
- gender: 0,
303
+ gender: null,
301
304
  nationalCard: '',
302
305
  dateNationalId: '',
303
306
  phone: '',
@@ -426,7 +429,11 @@ export default function ReviewInformation(props) {
426
429
  flex: 1,
427
430
  }}
428
431
  >
429
- {values.gender === 0 ? 'Nam' : 'Nữ'}
432
+ {values.gender === 0
433
+ ? 'Nam'
434
+ : values.gender === 1
435
+ ? 'Nữ'
436
+ : ''}
430
437
  </MText>
431
438
  <DropDown2 />
432
439
  </TouchableOpacity>
@@ -256,17 +256,17 @@ export default function ReviewInformationOther(props) {
256
256
  districtName: yup.string().required('Vui lòng nhập quận/huyện'),
257
257
  wardName: yup.string().required('Vui lòng nhập phường/xã'),
258
258
  address: yup.string().required('Vui lòng nhập địa chỉ'),
259
- fullName1: yup.string().required('Vui lòng nhập tên'),
259
+ fullName1: yup.string().required('Vui lòng nhập họ tên'),
260
260
  phone1: yup.string().required('Vui lòng nhập số điện thoại'),
261
261
  relationshipType1: yup
262
262
  .object()
263
- .required('Vui lòng chọn')
263
+ .required('Vui lòng chọn mối quan hệ')
264
264
  .nullable(),
265
- fullName2: yup.string().required('Vui lòng nhập tên'),
265
+ fullName2: yup.string().required('Vui lòng nhập họ tên'),
266
266
  phone2: yup.string().required('Vui lòng nhập số điện thoại'),
267
267
  relationshipType2: yup
268
268
  .object()
269
- .required('Vui lòng chọn')
269
+ .required('Vui lòng chọn mối quan hệ')
270
270
  .nullable(),
271
271
  })}
272
272
  innerRef={formRef}
@@ -355,9 +355,14 @@ export default function ReviewLoan(props: any) {
355
355
  }}
356
356
  validationSchema={yup.object().shape({
357
357
  loanAmount: yup.string().required('Số tiền là bắt buộc'),
358
- rateTypeId: yup.number().required('Vui lòng chọn').nullable(),
359
- loanTime: yup.number().required('Vui lòng chọn').nullable(),
360
- firstPaymentDate: yup.string().required('Vui lòng chọn'),
358
+ rateTypeId: yup.number().required('HTTT bắt buộc').nullable(),
359
+ loanTime: yup
360
+ .number()
361
+ .required('Thời gian vay là bắt buộc')
362
+ .nullable(),
363
+ firstPaymentDate: yup
364
+ .string()
365
+ .required('Ngày thanh toán đầu kỳ là bắt buộc'),
361
366
  bankName: yup.string().required('Vui lòng chọn ngân hàng'),
362
367
  bankAccountName: yup.string().required('Vui lòng nhập chủ thẻ'),
363
368
  bankAccountNumber: yup
@@ -5,7 +5,6 @@ import {
5
5
  Dimensions,
6
6
  Image,
7
7
  ImageStyle,
8
- PermissionsAndroid,
9
8
  Platform,
10
9
  SafeAreaView,
11
10
  TextStyle,
@@ -40,6 +39,7 @@ import { ScreenNames } from '../../navigation';
40
39
  import { load, OCR_V2, save } from '../../utils/storage';
41
40
  import { IconUpload } from '../../assets/svgs';
42
41
  import ImagePicker from 'react-native-image-crop-picker';
42
+ import { launchImageLibrary } from 'react-native-image-picker';
43
43
 
44
44
  export default function VehicleCamera(props: any) {
45
45
  const isFocused = useIsFocused();
@@ -197,75 +197,49 @@ export default function VehicleCamera(props: any) {
197
197
  return () => clearTimeout(timeout);
198
198
  }, [isFocused]);
199
199
 
200
- const hasAndroidPermission = async () => {
201
- const getCheckPermissionPromise = () => {
202
- if (Number(Platform.Version) >= 33) {
203
- return Promise.all([
204
- PermissionsAndroid.check(
205
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES
206
- ),
207
- PermissionsAndroid.check(
208
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO
209
- ),
210
- ]).then(
211
- ([hasReadMediaImagesPermission, hasReadMediaVideoPermission]) =>
212
- hasReadMediaImagesPermission && hasReadMediaVideoPermission
213
- );
214
- } else {
215
- return PermissionsAndroid.check(
216
- PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE
217
- );
218
- }
219
- };
220
- const hasPermission = await getCheckPermissionPromise();
221
- if (hasPermission) {
222
- return true;
223
- }
224
-
225
- const getRequestPermissionPromise = () => {
226
- if (Number(Platform.Version) >= 33) {
227
- return PermissionsAndroid.requestMultiple([
228
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES,
229
- PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO,
230
- ]).then(
231
- (statuses) =>
232
- statuses[PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES] ===
233
- PermissionsAndroid.RESULTS.GRANTED &&
234
- statuses[PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO] ===
235
- PermissionsAndroid.RESULTS.GRANTED
236
- );
237
- } else {
238
- return PermissionsAndroid.request(
239
- PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE
240
- ).then((status) => status === PermissionsAndroid.RESULTS.GRANTED);
241
- }
242
- };
243
-
244
- return await getRequestPermissionPromise();
245
- };
246
-
247
200
  const pickImageFromGallery = async () => {
248
- await hasAndroidPermission();
249
- ImagePicker.openPicker({}).then((image) => {
250
- if (props?.route?.params?.front) {
251
- navigation.push(ScreenNames.VehicleRegistrationFront, {
252
- uri:
253
- Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
254
- loan: props?.route?.params?.loan,
255
- });
256
- } else if (props.route?.params?.callback) {
257
- navigation.goBack();
258
- props.route?.params?.callback(
259
- Platform.OS === 'android' ? image?.path : 'file://' + image?.path
260
- );
261
- } else {
262
- navigation.push(ScreenNames.VehicleRegistrationBack, {
263
- uri:
264
- Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
265
- loan: props?.route?.params?.loan,
266
- });
201
+ if (Platform.OS === 'android') {
202
+ const result = await launchImageLibrary({
203
+ mediaType: 'photo',
204
+ });
205
+ if (result.assets) {
206
+ if (props?.route?.params?.front) {
207
+ navigation.push(ScreenNames.VehicleRegistrationFront, {
208
+ uri: result.assets[0]?.uri,
209
+ loan: props?.route?.params?.loan,
210
+ });
211
+ } else if (props.route?.params?.callback) {
212
+ navigation.goBack();
213
+ props.route?.params?.callback(result.assets[0]?.uri);
214
+ } else {
215
+ navigation.push(ScreenNames.VehicleRegistrationBack, {
216
+ uri: result.assets[0]?.uri,
217
+ loan: props?.route?.params?.loan,
218
+ });
219
+ }
267
220
  }
268
- });
221
+ } else {
222
+ ImagePicker.openPicker({}).then((image) => {
223
+ if (props?.route?.params?.front) {
224
+ navigation.push(ScreenNames.VehicleRegistrationFront, {
225
+ uri:
226
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
227
+ loan: props?.route?.params?.loan,
228
+ });
229
+ } else if (props.route?.params?.callback) {
230
+ navigation.goBack();
231
+ props.route?.params?.callback(
232
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path
233
+ );
234
+ } else {
235
+ navigation.push(ScreenNames.VehicleRegistrationBack, {
236
+ uri:
237
+ Platform.OS === 'android' ? image?.path : 'file://' + image?.path,
238
+ loan: props?.route?.params?.loan,
239
+ });
240
+ }
241
+ });
242
+ }
269
243
  };
270
244
 
271
245
  return (