import React, { FC, ReactNode } from 'react'; import { Text, TouchableOpacity, View } from 'react-native'; import { CommonActions, useNavigation } from '@react-navigation/native'; import { styles } from './style'; import ChevronLeft from '../../../assets/icons/chevron-left.svg'; import CloseSvg from '../../../assets/icons/close.svg'; import { NAVIGATION_PAGES } from 'src/types'; import { Colors } from 'src/theme'; type Props = { label: string; rightElement?: ReactNode; shouldClose?: boolean; }; export const Header: FC = ({ label, rightElement, shouldClose }) => { const navigation = useNavigation(); const handlePress = () => { if (shouldClose) { navigation.dispatch( CommonActions.reset({ index: 1, routes: [{ name: NAVIGATION_PAGES.IN_APP }] }) ); } else { navigation.goBack(); } }; // navigation.setOptions() TODO return ( {shouldClose ? : } {label} {rightElement ? {rightElement} : } ); };