From fda66a770380267920e662ca4568f188bd64008f Mon Sep 17 00:00:00 2001 From: Aleksandar Date: Thu, 11 Dec 2025 13:23:56 +0100 Subject: [PATCH] fix: completely disable camera/barcode on web platform --- apps/mobile/src/components/ScanFoodModal.tsx | 23 ++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/mobile/src/components/ScanFoodModal.tsx b/apps/mobile/src/components/ScanFoodModal.tsx index b90db2c..ff060db 100644 --- a/apps/mobile/src/components/ScanFoodModal.tsx +++ b/apps/mobile/src/components/ScanFoodModal.tsx @@ -20,7 +20,7 @@ const FOOD_DATABASE: { [key: string]: { name: string; calories: number; servingS }; export function ScanFoodModal({ visible, onClose, onAddFood }: ScanFoodModalProps) { - const [permission, requestPermission] = useCameraPermissions(); + const [permission, requestPermission] = Platform.OS === 'web' ? [null, null] : useCameraPermissions() as any; const [scanned, setScanned] = useState(false); const [foodData, setFoodData] = useState<{ name: string; calories: number; servingSize: string } | null>(null); const [servings, setServings] = useState('1'); @@ -68,10 +68,29 @@ export function ScanFoodModal({ visible, onClose, onAddFood }: ScanFoodModalProp }; if (!permission) { + if (Platform.OS === 'web') { + // On web, show normal modal without permissions + return ( + + + + + + + Scan Food Barcode + + + + Barcode scanning is only available on mobile devices + + + + ); + } return null; } - if (!permission.granted) { + if (!permission.granted && Platform.OS !== 'web') { return (