i have this below expo codes please make them better and modernize them from the latest documentations
// components/scanner/Scanner.tsx
import React from 'react';
import { StyleSheet, Dimensions } from 'react-native';
import { BarCodeScanner, } from 'expo-barcode-scanner';
import { CameraView, CameraType, useCameraPermissions } from 'expo-camera';
type ScannerProps = {
onBarCodeScanned: BarCodeScannerProps['onBarCodeScanned'];
};
export const Scanner: React.FC = ({ onBarCodeScanned }) => {
return (
);
};
// components/scanner/ScannerPermissionRequest.tsx
import React from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import * as IntentLauncher from 'expo-intent-launcher';
import { Platform } from 'react-native';
import Colors from '@/constants/Colors';
export const ScannerPermissionRequest: React.FC = () => {
const openSettings = () => {
if (Platform.OS === 'ios') {
IntentLauncher.startActivityAsync(IntentLauncher.ActivityAction.APN_SETTINGS);
} else {
IntentLauncher.startActivityAsync(IntentLauncher.ActivityAction.APPLICATION_DETAILS_SETTINGS);
}
};
return (
Camera Permission Required
We need camera access to scan QR codes. Please grant permission in your device settings.
Open Settings
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff',
padding: 20,
},
title: {
fontSize: 22,
fontWeight: 'bold',
color: '#333',
marginTop: 20,
marginBottom: 10,
},
message: {
fontSize: 16,
color: '#666',
textAlign: 'center',
marginBottom: 30,
},
button: {
backgroundColor: Colors.primary,
paddingVertical: 12,
paddingHorizontal: 30,
borderRadius: 8,
},
buttonText: {
color: '#fff',
fontSize: 16,
fontWeight: '600',
},
});