feat: Implement UI enhancements and fix burst bug
This commit is contained in:
@@ -51,9 +51,11 @@ interface CameraScreenProps {
|
||||
adminPassword?: string;
|
||||
welcomeText?: string;
|
||||
burstCount?: number;
|
||||
burstIntervalSec?: number;
|
||||
frameMode?: 'off' | 'always' | 'available';
|
||||
selectedFrameId?: string | null;
|
||||
burstIntervalSec: number;
|
||||
frameMode: 'off' | 'always' | 'available';
|
||||
selectedFrameId: string | null;
|
||||
footerText: string;
|
||||
useFrontCamera: boolean;
|
||||
}
|
||||
|
||||
export default function CameraScreen({
|
||||
@@ -67,20 +69,23 @@ export default function CameraScreen({
|
||||
adminPassword = '1234',
|
||||
welcomeText = 'Willkommen zu unserer Feier!',
|
||||
burstCount = 1,
|
||||
burstIntervalSec = 5,
|
||||
frameMode = 'off',
|
||||
selectedFrameId = null,
|
||||
burstIntervalSec,
|
||||
frameMode,
|
||||
selectedFrameId,
|
||||
footerText,
|
||||
useFrontCamera,
|
||||
}: CameraScreenProps) {
|
||||
const [permission, requestPermission] = useCameraPermissions();
|
||||
const [isUsbConnected, setIsUsbConnected] = useState<boolean>(false);
|
||||
const [countdown, setCountdown] = useState<number | string>('');
|
||||
const [countdown, setCountdown] = useState<number | 'smile'>(countdownDuration);
|
||||
const [isCapturing, setIsCapturing] = useState<boolean>(false);
|
||||
const [hasStarted, setHasStarted] = useState<boolean>(false);
|
||||
const [pictureSize, setPictureSize] = useState<string | undefined>(undefined);
|
||||
|
||||
// Burst mode state
|
||||
// Burst mode state and refs
|
||||
const [burstIndex, setBurstIndex] = useState<number>(0);
|
||||
const [burstUris, setBurstUris] = useState<string[]>([]);
|
||||
const burstIndexRef = useRef<number>(0);
|
||||
const burstUrisRef = useRef<string[]>([]);
|
||||
const [showBurstIndicator, setShowBurstIndicator] = useState<string>('');
|
||||
const [isBurstWaiting, setIsBurstWaiting] = useState<boolean>(false);
|
||||
|
||||
@@ -228,14 +233,15 @@ export default function CameraScreen({
|
||||
if (burstTimerRef.current) clearTimeout(burstTimerRef.current);
|
||||
if (countdownTimerRef.current) clearTimeout(countdownTimerRef.current);
|
||||
if (completionTimerRef.current) clearTimeout(completionTimerRef.current);
|
||||
const urisToDelete = [...burstUris];
|
||||
const urisToDelete = [...burstUrisRef.current];
|
||||
|
||||
setCountdown(countdownDuration);
|
||||
setIsCapturing(false);
|
||||
setIsBurstWaiting(false);
|
||||
setHasStarted(false);
|
||||
setBurstIndex(0);
|
||||
setBurstUris([]);
|
||||
burstIndexRef.current = 0;
|
||||
burstUrisRef.current = [];
|
||||
setShowBurstIndicator('');
|
||||
onCancel();
|
||||
|
||||
@@ -254,7 +260,8 @@ export default function CameraScreen({
|
||||
if (isIdle) {
|
||||
setHasStarted(false);
|
||||
setBurstIndex(0);
|
||||
setBurstUris([]);
|
||||
burstIndexRef.current = 0;
|
||||
burstUrisRef.current = [];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -361,13 +368,14 @@ export default function CameraScreen({
|
||||
|
||||
// Handle burst mode
|
||||
const effectiveBurst = burstCount || 1;
|
||||
const newIndex = burstIndex + 1;
|
||||
const newUris = [...burstUris, capturedUri];
|
||||
const newIndex = burstIndexRef.current + 1;
|
||||
const newUris = [...burstUrisRef.current, capturedUri];
|
||||
|
||||
if (effectiveBurst > 1 && newIndex < effectiveBurst) {
|
||||
// More burst photos to take
|
||||
burstIndexRef.current = newIndex;
|
||||
burstUrisRef.current = newUris;
|
||||
setBurstIndex(newIndex);
|
||||
setBurstUris(newUris);
|
||||
setShowBurstIndicator(`Foto ${newIndex} von ${effectiveBurst} ✓`);
|
||||
setIsCapturing(false);
|
||||
setIsBurstWaiting(true);
|
||||
@@ -379,8 +387,9 @@ export default function CameraScreen({
|
||||
}, burstIntervalSec * 1000);
|
||||
} else if (effectiveBurst > 1) {
|
||||
// Final burst photo
|
||||
burstIndexRef.current = 0;
|
||||
burstUrisRef.current = [];
|
||||
setBurstIndex(0);
|
||||
setBurstUris([]);
|
||||
// Short delay prevents Android expo-camera crash on immediate unmount
|
||||
completionTimerRef.current = setTimeout(() => {
|
||||
onBurstComplete(newUris);
|
||||
@@ -512,7 +521,7 @@ export default function CameraScreen({
|
||||
adjustsFontSizeToFit
|
||||
numberOfLines={1}
|
||||
>
|
||||
ZUM STARTEN TIPPEN • Fotos machen • Collage • Drucken
|
||||
{footerText}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
@@ -644,7 +653,7 @@ export default function CameraScreen({
|
||||
{/* Camera Preview Background */}
|
||||
<View style={styles.previewContainer}>
|
||||
<View style={styles.cameraWrapper}>
|
||||
{Platform.OS === 'android' && isUsbConnected ? (
|
||||
{Platform.OS === 'android' && !useFrontCamera ? (
|
||||
<UsbCameraView
|
||||
ref={usbCameraRef}
|
||||
style={[styles.cameraPreview, { position: 'absolute', opacity: 1, zIndex: 10 }]}
|
||||
|
||||
Reference in New Issue
Block a user