import React from 'react'; import type { CameraPermissionViewProps } from '../../../../types/scanner'; import { Button } from '../../../button/public'; import { Card } from '../../../card/public'; import { View } from '../../../layout/public'; import { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThemeScope'; import { Text } from '../../../typography/public'; function resolvePermissionCopy(status: CameraPermissionViewProps['status']) { if (status === 'denied') { return { title: 'Camera permission needed', description: 'Camera access is denied. Enable camera access in system settings or enter the barcode manually.', }; } if (status === 'requesting') { return { title: 'Requesting camera access', description: 'Waiting for the system permission prompt.', }; } return { title: 'Allow camera access', description: 'Camera access is required to scan barcodes. You can also enter the barcode manually.', }; } function CameraPermissionViewInner({ themeId: _themeId, interactionPolicy, mode: _mode, status, title, description, requestLabel = 'Allow camera access', deniedLabel = 'Open settings', manualEntryLabel = 'Enter barcode manually', onRequestPermission, onManualEntry, requestButtonProps, manualEntryButtonProps, testID, }: CameraPermissionViewProps) { const copy = resolvePermissionCopy(status); const primaryLabel = status === 'denied' ? deniedLabel : requestLabel; const handleRequestPermission = onRequestPermission ? () => { void onRequestPermission(); } : undefined; const handleManualEntry = onManualEntry ? () => { void onManualEntry(); } : undefined; return ( Permission state: {status} {handleRequestPermission ? ( ) : null} {handleManualEntry ? ( ) : null} ); } /*** * ZORA-owned camera permission state for scanner flows. * * Native permission APIs stay in app adapters. This component renders the * request, denied, requesting, and manual-entry surfaces consistently. * */ export const CameraPermissionView = withZoraThemeScope(CameraPermissionViewInner);