Not a Plant Fehlermeldung
This commit is contained in:
@@ -37,6 +37,8 @@ const getBillingCopy = (language: 'de' | 'en' | 'es') => {
|
||||
timeoutTitle: 'Scan zu langsam',
|
||||
timeoutMessage: 'Die Analyse hat zu lange gedauert. Bitte erneut versuchen.',
|
||||
retryLabel: 'Erneut versuchen',
|
||||
notAPlantTitle: 'Keine Pflanze erkannt',
|
||||
notAPlantMessage: 'Das Bild zeigt keine erkennbare Pflanze. Bitte fotografiere eine Pflanze und versuche es erneut.',
|
||||
providerErrorMessage: 'KI-Scan gerade nicht verfügbar. Bitte versuche es erneut.',
|
||||
healthProviderErrorMessage: 'KI-Health-Check gerade nicht verfügbar. Bitte versuche es erneut.',
|
||||
healthTitle: 'Health Check',
|
||||
@@ -61,6 +63,8 @@ const getBillingCopy = (language: 'de' | 'en' | 'es') => {
|
||||
timeoutTitle: 'Escaneo lento',
|
||||
timeoutMessage: 'El análisis tardó demasiado. Inténtalo de nuevo.',
|
||||
retryLabel: 'Reintentar',
|
||||
notAPlantTitle: 'No es una planta',
|
||||
notAPlantMessage: 'La imagen no muestra una planta reconocible. Por favor fotografía una planta e inténtalo de nuevo.',
|
||||
providerErrorMessage: 'Escaneo IA no disponible ahora. Inténtalo de nuevo.',
|
||||
healthProviderErrorMessage: 'Health-check IA no disponible ahora. Inténtalo de nuevo.',
|
||||
healthTitle: 'Health Check',
|
||||
@@ -84,6 +88,8 @@ const getBillingCopy = (language: 'de' | 'en' | 'es') => {
|
||||
timeoutTitle: 'Scan Too Slow',
|
||||
timeoutMessage: 'Analysis took too long. Please try again.',
|
||||
retryLabel: 'Try again',
|
||||
notAPlantTitle: 'No plant detected',
|
||||
notAPlantMessage: 'The image does not show a recognizable plant. Please photograph a plant and try again.',
|
||||
providerErrorMessage: 'AI scan is currently unavailable. Please try again.',
|
||||
healthProviderErrorMessage: 'AI health check is currently unavailable. Please try again.',
|
||||
healthTitle: 'Health Check',
|
||||
@@ -181,8 +187,8 @@ export default function ScannerScreen() {
|
||||
try {
|
||||
const result = await ImageManipulator.manipulateAsync(
|
||||
uri,
|
||||
[{ resize: { width: 1024 } }],
|
||||
{ compress: 0.6, format: ImageManipulator.SaveFormat.JPEG, base64: true },
|
||||
[{ resize: { width: 768 } }],
|
||||
{ compress: 0.7, format: ImageManipulator.SaveFormat.JPEG, base64: true },
|
||||
);
|
||||
return result.base64 ? `data:image/jpeg;base64,${result.base64}` : result.uri;
|
||||
} catch {
|
||||
@@ -334,6 +340,12 @@ export default function ScannerScreen() {
|
||||
{ text: billingCopy.retryLabel, onPress: () => analyzeImage(imageUri, galleryImageUri) },
|
||||
],
|
||||
);
|
||||
} else if (isBackendApiError(error) && error.code === 'NOT_A_PLANT') {
|
||||
Alert.alert(
|
||||
billingCopy.notAPlantTitle,
|
||||
billingCopy.notAPlantMessage,
|
||||
[{ text: billingCopy.dismiss, style: 'cancel' }],
|
||||
);
|
||||
} else if (isBackendApiError(error) && error.code === 'PROVIDER_ERROR') {
|
||||
Alert.alert(
|
||||
billingCopy.genericErrorTitle,
|
||||
@@ -357,14 +369,11 @@ export default function ScannerScreen() {
|
||||
const takePicture = async () => {
|
||||
if (!cameraRef.current || isAnalyzing) return;
|
||||
await Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
|
||||
const photo = await cameraRef.current.takePictureAsync({ base64: true, quality: 0.5 });
|
||||
const photo = await cameraRef.current.takePictureAsync({ base64: false, quality: 0.9 });
|
||||
if (photo) {
|
||||
const analysisUri = photo.base64
|
||||
? `data:image/jpeg;base64,${photo.base64}`
|
||||
: photo.uri;
|
||||
const galleryUri = photo.uri || analysisUri;
|
||||
const analysisUri = await resizeForAnalysis(photo.uri);
|
||||
setSelectedImage(analysisUri);
|
||||
analyzeImage(analysisUri, galleryUri);
|
||||
analyzeImage(analysisUri, photo.uri);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user