fix: camera flash rendering and timing

This commit is contained in:
2026-06-11 21:13:18 +02:00
parent cfa77b7469
commit f5ccda3608
2 changed files with 17 additions and 9 deletions
BIN
View File
Binary file not shown.
+15 -7
View File
@@ -126,12 +126,14 @@ export default function CameraScreen({
opacity: flashOpacity.value, opacity: flashOpacity.value,
})); }));
// Trigger white flash effect // Turn on white flash effect
const triggerFlash = useCallback(() => { const turnFlashOn = useCallback(() => {
flashOpacity.value = withSequence( flashOpacity.value = withTiming(1, { duration: 50 });
withTiming(1, { duration: 80 }), }, []);
withTiming(0, { duration: 400 })
); // Turn off white flash effect
const turnFlashOff = useCallback(() => {
flashOpacity.value = withTiming(0, { duration: 400 });
}, []); }, []);
// 1. Request built-in camera permission on mount (just in case we fallback) // 1. Request built-in camera permission on mount (just in case we fallback)
@@ -314,7 +316,7 @@ export default function CameraScreen({
const tempUri = tempFile.uri; const tempUri = tempFile.uri;
try { try {
triggerFlash(); turnFlashOn();
let capturedUri: string; let capturedUri: string;
@@ -338,6 +340,8 @@ export default function CameraScreen({
} }
} }
turnFlashOff();
// If user cancelled while the camera promise was processing, abort before side-effects // If user cancelled while the camera promise was processing, abort before side-effects
if (isCancelledRef.current) { if (isCancelledRef.current) {
console.log('Capture cancelled by user during processing.'); console.log('Capture cancelled by user during processing.');
@@ -403,6 +407,7 @@ export default function CameraScreen({
}, 400); }, 400);
} }
} catch (error: any) { } catch (error: any) {
turnFlashOff();
console.error('Capture failed:', error); console.error('Capture failed:', error);
alert('Fehler beim Aufnehmen des Fotos: ' + error.message); alert('Fehler beim Aufnehmen des Fotos: ' + error.message);
onCancel(); onCancel();
@@ -674,6 +679,9 @@ export default function CameraScreen({
{/* Render UI controls/overlays on top */} {/* Render UI controls/overlays on top */}
{renderContent()} {renderContent()}
{/* Flash overlay */}
<Animated.View style={[styles.flashOverlay, flashAnimatedStyle]} pointerEvents="none" />
</View> </View>
); );
} }