Keep screen awake in camera mode; nudge flip button toward shutter
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState, forwardRef, useImperativeHandle, type ComponentProps } from 'react';
|
||||
import { View, Text, StyleSheet, TouchableOpacity, useWindowDimensions, AppState } from 'react-native';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake';
|
||||
import { useCameraDevice, type CameraPhotoOutput } from 'react-native-vision-camera';
|
||||
import { SkiaCamera, type SkiaCameraRef } from 'react-native-vision-camera-skia';
|
||||
import { createSynchronizable } from 'react-native-worklets';
|
||||
@@ -313,6 +314,17 @@ const Viewfinder = forwardRef<ViewfinderHandle, ViewfinderProps>(function Viewfi
|
||||
const sub = AppState.addEventListener('change', (s) => setAppActive(s === 'active'));
|
||||
return () => sub.remove();
|
||||
}, []);
|
||||
// Keep the screen lit while the live camera is showing. Without this the
|
||||
// display sleeps after the system timeout; when the user wakes it much later
|
||||
// (deep idle/doze) the preview surface is gone but the JS AppState never saw
|
||||
// a background event, so the session is never restarted and the viewfinder
|
||||
// (and capture) stay black until the camera is re-mounted (flip/switch).
|
||||
useEffect(() => {
|
||||
if (mode === 'camera') {
|
||||
activateKeepAwake('camera-viewfinder');
|
||||
return () => deactivateKeepAwake('camera-viewfinder');
|
||||
}
|
||||
}, [mode]);
|
||||
// Tap-to-focus / AE-AF-AWB lock point (view coords). null = auto continuous.
|
||||
const [focusPoint, setFocusPoint] = useState<{ x: number; y: number } | null>(null);
|
||||
const controller = cameraActive ? skiaCameraRef.current?.controller : undefined;
|
||||
|
||||
Reference in New Issue
Block a user