react-native-timacare 3.1.30-production → 3.1.31-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 (29) 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/VehicleCamera.js +1 -1
  11. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.flow +42 -68
  12. package/lib/commonjs/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  13. package/lib/module/screens/home/index.js +1 -1
  14. package/lib/module/screens/home/index.js.map +1 -1
  15. package/lib/module/screens/toan-trinh-so/OCR.js +1 -1
  16. package/lib/module/screens/toan-trinh-so/OCR.js.map +1 -1
  17. package/lib/module/screens/toan-trinh-so/RegisterCamera.js +1 -1
  18. package/lib/module/screens/toan-trinh-so/RegisterCamera.js.map +1 -1
  19. package/lib/module/screens/toan-trinh-so/VehicleCamera.js +1 -1
  20. package/lib/module/screens/toan-trinh-so/VehicleCamera.js.map +1 -1
  21. package/lib/typescript/screens/home/index.d.ts.map +1 -1
  22. package/lib/typescript/screens/toan-trinh-so/OCR.d.ts.map +1 -1
  23. package/lib/typescript/screens/toan-trinh-so/RegisterCamera.d.ts.map +1 -1
  24. package/lib/typescript/screens/toan-trinh-so/VehicleCamera.d.ts.map +1 -1
  25. package/package.json +2 -1
  26. package/src/screens/home/index.tsx +5 -27
  27. package/src/screens/toan-trinh-so/OCR.tsx +49 -72
  28. package/src/screens/toan-trinh-so/RegisterCamera.tsx +44 -70
  29. package/src/screens/toan-trinh-so/VehicleCamera.tsx +42 -68
@@ -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
@@ -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 (