mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-23 06:59:10 -04:00
MOB-135: AICamera first pass
This commit is contained in:
@@ -115,7 +115,8 @@ const AICamera = ( {
|
||||
const [initialVolume, setInitialVolume] = useState( null );
|
||||
const [hasTakenPhoto, setHasTakenPhoto] = useState( false );
|
||||
|
||||
const [useLocation, setUseLocation] = useState( !!hasLocationPermissions );
|
||||
const [userDisabledLocation, setUserDisabledLocation] = useState( false );
|
||||
const useLocation = hasLocationPermissions && !userDisabledLocation;
|
||||
const [locationStatusVisible, setLocationStatusVisible] = useState( false );
|
||||
|
||||
const [debugFormatIndex, setDebugFormatIndex] = useState( 0 );
|
||||
@@ -131,7 +132,7 @@ const AICamera = ( {
|
||||
requestLocationPermissions( );
|
||||
return;
|
||||
}
|
||||
setUseLocation( prev => !prev );
|
||||
setUserDisabledLocation( prev => !prev );
|
||||
// Always show status when button is pressed
|
||||
setLocationStatusVisible( true );
|
||||
};
|
||||
@@ -140,12 +141,6 @@ const AICamera = ( {
|
||||
setLocationStatusVisible( false );
|
||||
};
|
||||
|
||||
useEffect( ( ) => {
|
||||
if ( hasLocationPermissions ) {
|
||||
setUseLocation( true );
|
||||
}
|
||||
}, [hasLocationPermissions] );
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { loadTime } = usePerformance( {
|
||||
|
||||
@@ -106,22 +106,19 @@ const FrameProcessorCamera = ( {
|
||||
}, [onLog] );
|
||||
|
||||
useEffect( () => {
|
||||
const unsubscribeFocus = navigation.addListener( "focus", () => {
|
||||
InatVision.resetStoredResults( );
|
||||
resetCameraOnFocus( );
|
||||
} );
|
||||
|
||||
return unsubscribeFocus;
|
||||
}, [navigation, resetCameraOnFocus] );
|
||||
|
||||
useEffect( () => {
|
||||
const unsubscribeBlur = navigation.addListener( "blur", () => {
|
||||
const resetAll = () => {
|
||||
InatVision.resetStoredResults();
|
||||
resetCameraOnFocus( );
|
||||
} );
|
||||
resetCameraOnFocus();
|
||||
};
|
||||
console.log( "AI cam foc listeners" );
|
||||
const unsubscribeFocus = navigation.addListener( "focus", resetAll );
|
||||
const unsubscribeBlur = navigation.addListener( "blur", resetAll );
|
||||
|
||||
return unsubscribeBlur;
|
||||
}, [navigation, resetCameraOnFocus, sentinelFileName] );
|
||||
return () => {
|
||||
unsubscribeFocus();
|
||||
unsubscribeBlur();
|
||||
};
|
||||
}, [navigation, resetCameraOnFocus] );
|
||||
|
||||
const handleResults = Worklets.createRunOnJS( ( result, timeTaken ) => {
|
||||
setLastTimestamp( result.timestamp );
|
||||
|
||||
@@ -84,10 +84,10 @@ const useZoom = ( device: CameraDevice ): object => {
|
||||
startZoom.set( zoom.get() );
|
||||
}, [startZoom, zoom] );
|
||||
|
||||
const resetZoom = ( ) => {
|
||||
const resetZoom = useCallback( ( ) => {
|
||||
zoom.set( initialZoom );
|
||||
setZoomTextValue( initialZoomTextValue );
|
||||
};
|
||||
}, [initialZoom, initialZoomTextValue, zoom] );
|
||||
|
||||
const updateZoomTextValue = useCallback( ( newZoom: number ) => {
|
||||
const closestZoomTextValue = zoomButtonOptions.reduce(
|
||||
|
||||
Reference in New Issue
Block a user