fix: camera flash rendering and timing
This commit is contained in:
LFS
BIN
Binary file not shown.
@@ -126,12 +126,14 @@ export default function CameraScreen({
|
||||
opacity: flashOpacity.value,
|
||||
}));
|
||||
|
||||
// Trigger white flash effect
|
||||
const triggerFlash = useCallback(() => {
|
||||
flashOpacity.value = withSequence(
|
||||
withTiming(1, { duration: 80 }),
|
||||
withTiming(0, { duration: 400 })
|
||||
);
|
||||
// Turn on white flash effect
|
||||
const turnFlashOn = useCallback(() => {
|
||||
flashOpacity.value = withTiming(1, { duration: 50 });
|
||||
}, []);
|
||||
|
||||
// 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)
|
||||
@@ -314,7 +316,7 @@ export default function CameraScreen({
|
||||
const tempUri = tempFile.uri;
|
||||
|
||||
try {
|
||||
triggerFlash();
|
||||
turnFlashOn();
|
||||
|
||||
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 (isCancelledRef.current) {
|
||||
console.log('Capture cancelled by user during processing.');
|
||||
@@ -403,6 +407,7 @@ export default function CameraScreen({
|
||||
}, 400);
|
||||
}
|
||||
} catch (error: any) {
|
||||
turnFlashOff();
|
||||
console.error('Capture failed:', error);
|
||||
alert('Fehler beim Aufnehmen des Fotos: ' + error.message);
|
||||
onCancel();
|
||||
@@ -674,6 +679,9 @@ export default function CameraScreen({
|
||||
|
||||
{/* Render UI controls/overlays on top */}
|
||||
{renderContent()}
|
||||
|
||||
{/* Flash overlay */}
|
||||
<Animated.View style={[styles.flashOverlay, flashAnimatedStyle]} pointerEvents="none" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user