Files
super-app/components/reusable/static-header/StaticHeader.tsx
Kshitij Pramod Ghongadi 377c2c0b80 NTP-6602 | Feature | Multi Plan For all (#12981)
Co-authored-by: SANDEEP KUMAR <sandeep.ku@navi.com>
Co-authored-by: Somarapu Vamshi <somarapu.vamshi@navi.com>
Co-authored-by: Shivam Goyal <shivam.goyal@navi.com>
Co-authored-by: vedant aggarwal <vedant.aggarwal@navi.com>
Co-authored-by: Mehul Garg <mehul.garg@navi.com>
Co-authored-by: Hardik Chaudhary <hardik.chaudhary@navi.com>
Co-authored-by: Aditya Narayan Malik <aditya.narayan@navi.com>
Co-authored-by: Shaurya Rehan <shaurya.rehan@navi.com>
Co-authored-by: Divyesh Shinde <divyesh.shinde@navi.com>
Co-authored-by: Mohit Rajput <mohit.rajput@navi.com>
Co-authored-by: sharmapoojabalrambhai <sharma.balrambhai@navi.com>
Co-authored-by: Prajjaval Verma <prajjaval.verma@navi.com>
2024-10-21 18:27:59 +00:00

59 lines
1.7 KiB
TypeScript

import { useEffect } from "react";
import { BackHandler, TouchableOpacity, View } from "react-native";
import { HARDWARE_BACK_PRESS, ImageName } from "../../../App/common/constants";
import { CtaData } from "../../../App/common/interface";
import { AppImage } from "../../AppImage";
import { styles } from "./StaticHeaderStyle";
export const StaticHeader = ({
handleClick,
leftIcon,
rightIcon,
leftIconCta,
rightIconCta,
}: {
handleClick?: (ctaData: CtaData) => void;
leftIcon?: keyof typeof ImageName;
rightIcon?: keyof typeof ImageName;
leftIconCta?: CtaData | null;
rightIconCta?: CtaData | null;
}) => {
const handleBackButtonClick = () => {
handleClick && leftIconCta && handleClick(leftIconCta);
return true;
};
useEffect(() => {
BackHandler.addEventListener(HARDWARE_BACK_PRESS, handleBackButtonClick);
return () => {
BackHandler.removeEventListener(
HARDWARE_BACK_PRESS,
handleBackButtonClick,
);
};
}, [leftIconCta]);
return (
<View style={styles.container}>
{!!leftIconCta && (
<TouchableOpacity
onPress={() => {
handleClick && leftIconCta && handleClick(leftIconCta);
}}
activeOpacity={1}
>
{AppImage(leftIcon || ImageName.CROSS, styles.leftImageStyle)}
</TouchableOpacity>
)}
{!!rightIconCta && (
<TouchableOpacity
onPress={() => {
handleClick && rightIconCta && handleClick(rightIconCta);
}}
activeOpacity={1}
>
{AppImage(rightIcon || ImageName.HELP, styles.rightImageStyle)}
</TouchableOpacity>
)}
</View>
);
};