Fix add evidence navigation (#1598)

* Fix navigation for AddEvidenceSheet; closes #1571

* Update pods
This commit is contained in:
Amanda Bullington
2024-05-21 17:19:33 -07:00
committed by GitHub
parent 799d83f286
commit c021b88591

View File

@@ -6,13 +6,13 @@ import {
} from "components/SharedComponents";
import { View } from "components/styledComponents";
import type { Node } from "react";
import React, { useState } from "react";
import React from "react";
import useTranslation from "sharedHooks/useTranslation";
type Props = {
disableAddingMoreEvidence: boolean,
hidden?: boolean,
onClose: Function
disableAddingMoreEvidence: boolean,
hidden?: boolean,
onClose: Function
}
const AddEvidenceSheet = ( {
@@ -22,7 +22,6 @@ const AddEvidenceSheet = ( {
}: Props ): Node => {
const { t } = useTranslation( );
const navigation = useNavigation( );
const [choice, setChoice] = useState( null );
return (
<BottomSheet
@@ -33,30 +32,8 @@ const AddEvidenceSheet = ( {
// -1 means the sheet is fully hidden... and in theory it's safe to navigate away
if ( position > -1 ) return;
if ( choice === "camera" ) {
// Since we're on ObsEdit, the "Camera" screen might already be in
// the stack, e.g. the AICamera, so if we use navigate() we risk
// going *back* to it and popping ObsEdit off the stack. Instead,
// we *push* another instance of that screen on to the stack so we
// can return to ObsEdit
navigation.push( "Camera", {
addEvidence: true,
camera: "Standard"
} );
} else if ( choice === "import" ) {
// Show photo gallery, but skip group photos phase
navigation.navigate( "NoBottomTabStackNavigator", {
screen: "PhotoGallery",
params: { skipGroupPhotos: true }
} );
} else if ( choice === "sound" ) {
navigation.navigate(
"NoBottomTabStackNavigator",
{ screen: "SoundRecorder", params: { addEvidence: true } }
);
}
// make sure backdrop press is handled
if ( onClose && position === -1 ) {
if ( position === -1 ) {
// make sure backdrop press is handled
onClose( );
}
}}
@@ -71,8 +48,15 @@ const AddEvidenceSheet = ( {
<EvidenceButton
icon="camera"
handlePress={( ) => {
setChoice( "camera" );
onClose( );
// Since we're on ObsEdit, the "Camera" screen might already be in
// the stack, e.g. the AICamera, so if we use navigate() we risk
// going *back* to it and popping ObsEdit off the stack. Instead,
// we *push* another instance of that screen on to the stack so we
// can return to ObsEdit
navigation.push( "Camera", {
addEvidence: true,
camera: "Standard"
} );
}}
disabled={disableAddingMoreEvidence}
accessibilityLabel={t( "Camera" )}
@@ -81,8 +65,11 @@ const AddEvidenceSheet = ( {
<EvidenceButton
icon="gallery"
handlePress={( ) => {
setChoice( "import" );
onClose( );
// Show photo gallery, but skip group photos phase
navigation.navigate( "NoBottomTabStackNavigator", {
screen: "PhotoGallery",
params: { skipGroupPhotos: true }
} );
}}
disabled={disableAddingMoreEvidence}
accessibilityLabel={t( "Bulk-importer" )}
@@ -91,8 +78,10 @@ const AddEvidenceSheet = ( {
<EvidenceButton
icon="microphone"
handlePress={( ) => {
setChoice( "sound" );
onClose( );
navigation.navigate(
"NoBottomTabStackNavigator",
{ screen: "SoundRecorder", params: { addEvidence: true } }
);
}}
disabled={disableAddingMoreEvidence}
accessibilityLabel={t( "Sound-recorder" )}