Update camera screens, configuration, and build setup
This commit is contained in:
@@ -10,7 +10,8 @@ import {
|
||||
TouchableWithoutFeedback,
|
||||
} from 'react-native';
|
||||
import { CameraView, useCameraPermissions } from 'expo-camera';
|
||||
import * as FileSystem from 'expo-file-system/legacy';
|
||||
import { File, Paths } from 'expo-file-system';
|
||||
import Animated, { useSharedValue, useAnimatedStyle, withSpring, withTiming, FadeIn, FadeOut } from 'react-native-reanimated';
|
||||
import { THEME } from '../styles/theme';
|
||||
import { UsbCameraView, UsbCameraRef } from '../../modules/usb-camera';
|
||||
import { saveToGallery } from '../services/storage';
|
||||
@@ -48,6 +49,22 @@ export default function CameraScreen({
|
||||
const usbCameraRef = useRef<UsbCameraRef>(null);
|
||||
const expoCameraRef = useRef<any>(null);
|
||||
|
||||
// Reanimated countdown pulse animation
|
||||
const scale = useSharedValue(1);
|
||||
|
||||
useEffect(() => {
|
||||
if (countdown !== '') {
|
||||
scale.value = 0.5;
|
||||
scale.value = withSpring(1.25, { damping: 10, stiffness: 120 }, () => {
|
||||
scale.value = withTiming(1.0, { duration: 150 });
|
||||
});
|
||||
}
|
||||
}, [countdown]);
|
||||
|
||||
const animatedStyle = useAnimatedStyle(() => ({
|
||||
transform: [{ scale: scale.value }],
|
||||
}));
|
||||
|
||||
// 1. Request built-in camera permission on mount (just in case we fallback)
|
||||
useEffect(() => {
|
||||
if (!permission || !permission.granted) {
|
||||
@@ -117,7 +134,8 @@ export default function CameraScreen({
|
||||
// 4. Capture photo function
|
||||
const capture = async () => {
|
||||
const filename = `photo_${Date.now()}.jpg`;
|
||||
const tempUri = `${FileSystem.cacheDirectory}${filename}`;
|
||||
const tempFile = new File(Paths.cache, filename);
|
||||
const tempUri = tempFile.uri;
|
||||
|
||||
try {
|
||||
if (Platform.OS === 'android' && isUsbConnected && usbCameraRef.current) {
|
||||
@@ -289,9 +307,9 @@ export default function CameraScreen({
|
||||
{/* Countdown overlay */}
|
||||
{hasStarted && (
|
||||
<View style={styles.countdownOverlay} pointerEvents="none">
|
||||
<View style={styles.countdownBox}>
|
||||
<Animated.View style={[styles.countdownBox, animatedStyle]}>
|
||||
<Text style={styles.countdownText}>{countdown}</Text>
|
||||
</View>
|
||||
</Animated.View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
@@ -306,7 +324,7 @@ export default function CameraScreen({
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Animated.View entering={FadeIn.duration(400)} exiting={FadeOut.duration(300)} style={styles.container}>
|
||||
{/* Camera Preview Background */}
|
||||
<View style={styles.previewContainer}>
|
||||
{Platform.OS === 'android' && isUsbConnected ? (
|
||||
@@ -322,7 +340,7 @@ export default function CameraScreen({
|
||||
|
||||
{/* Render UI controls/overlays on top */}
|
||||
{renderContent()}
|
||||
</View>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user