import React, {useCallback} from 'react'; import { View, Pressable, Image, ViewStyle, TextStyle, ImageStyle, ImageRequireSource, } from 'react-native'; import {SvgProps} from 'react-native-svg'; import {Heading3} from '../TextComponents'; import styles from './styles'; interface HeaderProps { wrapperBackgroundColor?: string; containerStyle?: ViewStyle; showBottomBorder?: boolean; wrapperStyle?: ViewStyle; LeftIconSource?: React.FC; onLeftPress?: () => void; disableLeft?: boolean; leftButtonStyle?: ViewStyle; leftIconStyle?: ImageStyle; rightIconSource?: ImageRequireSource; onRightPress?: () => void; disableRight?: boolean; rightButtonStyle?: ViewStyle; renderRightButton?: () => React.ReactNode; rightIconStyle?: ImageStyle; title?: string; titleColor?: string; titleStyle?: TextStyle; renderCenterTitle?: () => React.ReactNode; } const Header: React.FC = ({ wrapperBackgroundColor, containerStyle, showBottomBorder, wrapperStyle, LeftIconSource, onLeftPress, disableLeft, leftButtonStyle, rightIconSource, onRightPress, disableRight, rightButtonStyle, renderRightButton, rightIconStyle, title, titleStyle, renderCenterTitle, }) => { const renderLeft = useCallback(() => { if (disableLeft || !LeftIconSource) { return ; } return ( ); }, [disableLeft, leftButtonStyle, LeftIconSource, onLeftPress]); const renderRight = useCallback(() => { if (renderRightButton) { return renderRightButton(); } if (!disableRight && rightIconSource) { return ( ); } return ; }, [ disableRight, onRightPress, renderRightButton, rightButtonStyle, rightIconSource, rightIconStyle, ]); const renderTitle = useCallback(() => { if (renderCenterTitle) { return renderCenterTitle(); } if (title) { return ( {title} ); } return ; }, [renderCenterTitle, title, titleStyle]); return ( {renderLeft()} {renderTitle()} {renderRight()} ); }; export default Header;