MOB-512 add header edit icon for saved match

This commit is contained in:
sepeterson
2025-11-20 17:43:42 -06:00
parent 53915996cc
commit 3a2c110c93
2 changed files with 56 additions and 1 deletions

View File

@@ -10,6 +10,8 @@ import React from "react";
import type { RealmObservation } from "realmModels/types";
import { useTranslation } from "sharedHooks";
import SavedMatchHeaderRight from "./SavedMatchHeaderRight";
const cardClassTop
= "rounded-t-2xl border-lightGray border-[2px] py-[18px] px-5 border-b-0 -mb-0.5";
const cardClassBottom
@@ -31,13 +33,14 @@ const SavedMatch = ( {
const { taxon } = observation;
/* left todo
- fill in functionality in container
- simplify match header
- add edit pencil
- fix type errors
*/
return (
<ScrollViewWrapper>
<SavedMatchHeaderRight uuid={observation.uuid} />
<View className={cardClassTop}>
<MatchHeader topSuggestion={observation} />
</View>

View File

@@ -0,0 +1,52 @@
import { useNavigation } from "@react-navigation/native";
import {
INatIconButton
} from "components/SharedComponents";
import React, { useCallback, useEffect } from "react";
import type { RealmObservation } from "realmModels/types";
import {
useLocalObservation,
useNavigateToObsEdit,
useTranslation
} from "sharedHooks";
import colors from "styles/tailwindColors";
interface Props {
uuid: string;
}
const SavedMatchHeaderRight = ( {
uuid
}: Props ) => {
const navigation = useNavigation( );
const { localObservation } = useLocalObservation( uuid );
const { t } = useTranslation( );
const navigateToObsEdit = useNavigateToObsEdit( );
const headerRight = useCallback(
( ) => (
<INatIconButton
testID="ObsDetail.editButton"
// TODO remove cast when useLocalObservation converted to typescript
onPress={() => navigateToObsEdit( localObservation as RealmObservation )}
icon="pencil"
color={String( colors?.darkGray )}
accessibilityLabel={t( "Edit" )}
/>
),
[
localObservation,
navigateToObsEdit,
t
]
);
useEffect(
( ) => navigation.setOptions( { headerRight } ),
[headerRight, navigation]
);
return null;
};
export default SavedMatchHeaderRight;