From c021b885916e3d808fbbbba4a04777dccbe78c32 Mon Sep 17 00:00:00 2001 From: Amanda Bullington <35536439+albullington@users.noreply.github.com> Date: Tue, 21 May 2024 17:19:33 -0700 Subject: [PATCH] Fix add evidence navigation (#1598) * Fix navigation for AddEvidenceSheet; closes #1571 * Update pods --- .../ObsEdit/Sheets/AddEvidenceSheet.js | 59 ++++++++----------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/src/components/ObsEdit/Sheets/AddEvidenceSheet.js b/src/components/ObsEdit/Sheets/AddEvidenceSheet.js index 00c520001..43649681b 100644 --- a/src/components/ObsEdit/Sheets/AddEvidenceSheet.js +++ b/src/components/ObsEdit/Sheets/AddEvidenceSheet.js @@ -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 ( -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 = ( { { - 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 = ( { { - 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 = ( { { - setChoice( "sound" ); - onClose( ); + navigation.navigate( + "NoBottomTabStackNavigator", + { screen: "SoundRecorder", params: { addEvidence: true } } + ); }} disabled={disableAddingMoreEvidence} accessibilityLabel={t( "Sound-recorder" )}