import React, { useState, useEffect, useRef } from "react"; import { Text, TouchableOpacity, View, Image, StatusBar, StyleSheet } from "react-native"; import { GetPageTheme, customStyles, globalStyles } from "../styles/Global"; import { useRoute } from '@react-navigation/native'; import {Entypo, Fontisto, MaterialCommunityIcons, FontAwesome } from "./icons"; import moment from 'moment'; import LinearGradient from 'react-native-linear-gradient'; import { DevType } from "../constants/constants"; function DrawerHeader(props) { const route = useRoute(); const isCancelled = useRef(false); const PageTheme = GetPageTheme(props.DarkTheme, route.name); const globalStyle = globalStyles(props.DarkMode, route.name); const customStyle = customStyles(props.DarkMode, route.name); const [currentTime, setCurrentTime] = useState(''); const [currentDate, setCurrentDate] = useState(''); const [isRed, setIsRed] = useState(true); useEffect(() => { setTimer(); return () => { isCancelled.current = true; }; }, []); useEffect(() => { var interval if (props?.TrainingOrg2?.length > 0) { interval = setInterval(() => { setIsRed(prev => !prev); }, 500); // changes every 500ms } return () => clearInterval(interval); // cleanup }, [props?.TrainingOrg2]); function setTimer() { if (!isCancelled.current) { let d1 = new Date(); let now = moment(d1).format('hh:mm:ss a'); let ndate = moment(d1).format('DD/MM/YYYY'); setCurrentTime(now); setCurrentDate(ndate); setTimeout(() => { setTimer(); }, 1000); } } function toggleDrawer() { props.navigation.toggleDrawer(); } return ( {props.drawer_title != null ? props.drawer_title : route.name} { toggleDrawer() }}> {'Id : ' + (DevType == "Prod" ? (props.projectCode != null ? props.projectCode : '') : props?.projectCode + "_Dev")} props.navigation.navigate('NotificationList')} > {props?.badgeCount ? props?.badgeCount : 0} {/* {currentDate} {currentTime} */} {currentDate} {currentTime} {props.Gyancast && { props.navigation.navigate('Gyancasts') }}> {/* 0?Gyancastsicon_red:Mic}/> */} {props?.TrainingOrg2?.length > 0 && {'\u2022'}} GyanCast } ) } export default DrawerHeader; const styles = StyleSheet.create({ button: { marginRight: 20, }, itemCountContainer: { position: "absolute", height: 20, width: 20, borderRadius: 15, backgroundColor: "#FF7D7D", left: 18, bottom: 10, alignItems: "center", justifyContent: "center", zIndex: 2000, }, itemCountText: { color: "white", fontWeight: "bold", textAlign: "center", }, })