Skip to content

Commit

Permalink
Replaced selectImagesFromLibrary with selectImageFromLibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKScanbot committed Dec 12, 2024
1 parent 2ce0840 commit de35d21
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 32 deletions.
7 changes: 3 additions & 4 deletions src/hooks/operations/document/useAddDocumentPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
errorMessageAlert,
PrimaryRouteNavigationProp,
Screens,
selectImagesFromLibrary,
selectImageFromLibrary,
} from '@utils';
import {ActivityIndicatorContext, DocumentContext} from '@context';
import {useNavigation} from '@react-navigation/native';
Expand All @@ -31,16 +31,15 @@ export function useAddDocumentPage() {
* Return early if no image is selected or there is an issue selecting an image
**/
setLoading(true);
const selectedImageResult = await selectImagesFromLibrary();
const selectedImageResult = await selectImageFromLibrary();
if (!selectedImageResult) {
return;
}

const [imageFileUri] = selectedImageResult;
/** Add a page to the document */
const documentResult = await ScanbotSDK.Document.addPage({
documentID,
imageFileUri,
imageFileUri: selectedImageResult,
documentDetection: true,
});
/**
Expand Down
9 changes: 4 additions & 5 deletions src/hooks/operations/useDocumentQualityAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
checkLicense,
errorMessageAlert,
infoMessageAlert,
selectImagesFromLibrary,
selectImageFromLibrary,
} from '@utils';

import ScanbotSDK from 'react-native-scanbot-sdk';
Expand All @@ -26,15 +26,14 @@ export function useDocumentQualityAnalyzer() {
* Return early if no image is selected or there is an issue selecting an image
**/
setLoading(true);
const selectedImageResult = await selectImagesFromLibrary();
if (!selectedImageResult) {
const selectedImage = await selectImageFromLibrary();
if (!selectedImage) {
return;
}

const [imageFileUri] = selectedImageResult;
// Detect document quality on selected image
const quality = await ScanbotSDK.documentQualityAnalyzer({
imageFileUri: imageFileUri,
imageFileUri: selectedImage,
});
/**
* Handle the result by displaying an alert
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/operations/usePerformOCR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ export function usePerformOCR() {
* Select an image from the Image Library
* Return early if no image is selected or there is an issue selecting an image
**/
const selectedImage = await selectImagesFromLibrary();
if (!selectedImage) {
const selectedImages = await selectImagesFromLibrary();
if (!selectedImages) {
return;
}
/**
* Perform optical character recognition with provided configuration and
* Display the result
*/
const result = await ScanbotSDK.performOCR({
imageFileUris: selectedImage,
imageFileUris: selectedImages,
ocrConfiguration: {
engineMode: 'SCANBOT_OCR',
},
Expand Down
9 changes: 5 additions & 4 deletions src/hooks/operations/useRecognizeCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
errorMessageAlert,
PrimaryRouteNavigationProp,
Screens,
selectImagesFromLibrary,
selectImageFromLibrary,
} from '@utils';
import {ActivityIndicatorContext} from '@context';
import {useNavigation} from '@react-navigation/native';
Expand All @@ -29,16 +29,17 @@ export function useRecognizeCheck() {
* Select an image from the Image Library
* Return early if no image is selected or there is an issue selecting an image
**/
const selectedImage = await selectImagesFromLibrary();
const selectedImage = await selectImageFromLibrary();
if (!selectedImage) {
return;
}
/**
* Recognize Check on the selected image and
* Handle the result by navigating to Screens.CHECK_RECOGNIZER_RESULT
*/
const [imageFileUri] = selectedImage;
const result = await ScanbotSDK.recognizeCheck({imageFileUri});
const result = await ScanbotSDK.recognizeCheck({
imageFileUri: selectedImage,
});
navigation.navigate(Screens.CHECK_RECOGNIZER_RESULT, result);
} catch (e: any) {
errorMessageAlert(e.message);
Expand Down
7 changes: 3 additions & 4 deletions src/hooks/operations/useRecognizeEHIC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
infoMessageAlert,
PrimaryRouteNavigationProp,
Screens,
selectImagesFromLibrary,
selectImageFromLibrary,
} from '@utils';
import {ActivityIndicatorContext} from '@context';
import {useNavigation} from '@react-navigation/native';
Expand All @@ -30,16 +30,15 @@ export function useRecognizeEHIC() {
* Select an image from the Image Library
* Return early if no image is selected or there is an issue selecting an image
**/
const selectedImage = await selectImagesFromLibrary();
const selectedImage = await selectImageFromLibrary();
if (!selectedImage) {
return;
}
/**
* Recognize health insurance card on the selected image and
* Handle the result by displaying an alert
*/
const [imageFileUri] = selectedImage;
const result = await ScanbotSDK.recognizeEHIC(imageFileUri);
const result = await ScanbotSDK.recognizeEHIC(selectedImage);
/**
* Handle the result by navigating to result screen
*/
Expand Down
7 changes: 3 additions & 4 deletions src/hooks/operations/useRecognizeGenericDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
infoMessageAlert,
PrimaryRouteNavigationProp,
Screens,
selectImagesFromLibrary,
selectImageFromLibrary,
} from '@utils';
import {ActivityIndicatorContext} from '@context';
import {useNavigation} from '@react-navigation/native';
Expand All @@ -30,17 +30,16 @@ export function useRecognizeGenericDocument() {
* Select an image from the Image Library
* Return early if no image is selected or there is an issue selecting an image
**/
const selectedImage = await selectImagesFromLibrary();
const selectedImage = await selectImageFromLibrary();
if (!selectedImage) {
return;
}
/**
* Recognize Generic Document on the selected image and
* Handle the result by navigating to Screens.GENERIC_DOCUMENT_RESULT
*/
const [imageFileUri] = selectedImage;
const result = await ScanbotSDK.recognizeGenericDocument({
imageFileUri,
imageFileUri: selectedImage,
acceptedDocumentFormats: [],
});

Expand Down
7 changes: 3 additions & 4 deletions src/hooks/operations/useRecognizeMRZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
errorMessageAlert,
PrimaryRouteNavigationProp,
Screens,
selectImagesFromLibrary,
selectImageFromLibrary,
} from '@utils';
import {ActivityIndicatorContext} from '@context';

Expand All @@ -29,16 +29,15 @@ export function useRecognizeMRZ() {
* Select an image from the Image Library
* Return early if no image is selected or there is an issue selecting an image
**/
const selectedImage = await selectImagesFromLibrary();
const selectedImage = await selectImageFromLibrary();
if (!selectedImage) {
return;
}
/**
* Recognize MRZ on the selected image and
* Handle the result by navigating to Screens.MRZ_RESULT
*/
const [imageFileUri] = selectedImage;
const result = await ScanbotSDK.recognizeMrz(imageFileUri);
const result = await ScanbotSDK.recognizeMrz(selectedImage);
navigation.navigate(Screens.MRZ_RESULT, result);
} catch (e: any) {
errorMessageAlert(e.message);
Expand Down
7 changes: 3 additions & 4 deletions src/hooks/operations/useRecognizeMedicalCertificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
infoMessageAlert,
PrimaryRouteNavigationProp,
Screens,
selectImagesFromLibrary,
selectImageFromLibrary,
} from '@utils';
import {useCallback, useContext} from 'react';
import {ActivityIndicatorContext} from '@context';
Expand Down Expand Up @@ -45,17 +45,16 @@ export function useRecognizeMedicalCertificate() {
* Select an image from the Image Library
* Return early if no image is selected or there is an issue selecting an image
**/
const selectedImage = await selectImagesFromLibrary();
const selectedImage = await selectImageFromLibrary();
if (!selectedImage) {
return;
}
/**
* Recognize Medical Certificate on the selected image and
* Handle the result by navigating to Screens.MEDICAL_CERTIFICATE_RESULT
*/
const [imageFileUri] = selectedImage;
const result = await ScanbotSDK.recognizeMedicalCertificate({
imageFileUri,
imageFileUri: selectedImage,
options: {
returnCroppedDocumentUri: true,
patientInfoRecognitionEnabled: true,
Expand Down

0 comments on commit de35d21

Please sign in to comment.