Untitled

 avatar
unknown
plain_text
2 years ago
6.3 kB
0
Indexable
// @ts-ignore
// @ts-nocheck
import { View, Text, TouchableOpacity, Image } from "react-native";
import React, { useEffect, useState } from "react";
import FastImage from "react-native-fast-image";
import Apptheme from "../../blocks/HamburgerMenu/src/Apptheme";
import Scale from "./Scale";
import StorageProvider from "../../framework/src/StorageProvider"
import styles from "./bottomStyle";
import CreatePostModal from "./CreatePostModal";
import { SvgXml } from 'react-native-svg';
import { AvatarIcon } from "react-native-elements";
import { add, chatFill, chatPlain, notificationfill, notificationPlain, profileFill, profilePlain, vFill, vPlain } from "../../blocks/HamburgerMenu/src/assets";
import { FONTS } from "framework/src/AppFonts";

interface Props {
  navigation: any;
  onRefresh: () => any;
  onCreatePost: (value: any) => any;
  showCreatepost: boolean;
  selectedTab: string;
  testID: any;
  testrefresh: string;
}
export default function CustomBottomBar(props: Props) {
  const { navigation, onRefresh } = props;
  const [showCreatepost, setShowCreatePost] = useState<boolean>(props.showCreatepost);
  const [count, setCount] = useState(0)
  const [time_count, setTime_count] = useState(0)
  const [time, setTime] = useState(false)




  // useEffect(() => {
  //   const interval = setInterval(() => {
  //     countApi()
  //   }, 5000);

  // }, []);

  const timerCountFun = () =>{
   
    var curr_time = 0
      x = setInterval(function () {
        setTime_count(curr_time)
        curr_time = curr_time + 1
        console.log("curr",curr_time);
        setTime(true)
        if(curr_time === 30){
          clearInterval(x)
          setTime(false)
        }
      }, 1000);
  }

  const countApi = async () => {

    const _token = await StorageProvider.get('USER_TOKEN')
    var myHeaders = new Headers()
    myHeaders.append('token', _token)
    var requestOptions: any = {
      method: 'GET',
      headers: myHeaders,
      redirect: 'follow',
    }

    fetch(
      'https://vibesocialmusic-82830-ruby.b82830.dev.us-east-1.aws.svc.builder.cafe/bx_block_notifications/app_notifications/unread_notification_count',
      requestOptions,
    )
      .then((response) => response.text())
      .then((result) => {
        const _data = JSON.parse(result)
        //console.log("ddddddddddddddddddd",_data)
        setCount(_data.unread_notification_count)

      })
      .catch((error) => {
        // console.log('error in delete comment api>>>>', error)
      })
  }

  return (
    <View>
      <View
        style={[
          styles.smallCard2
        ]}
      >
        <View
          style={{
            width: "100%",
            paddingHorizontal: Scale(25),
            flexDirection: "row",
            justifyContent: "space-between",
            alignItems:'center',
          }}
        >
          <TouchableOpacity
          testID={props.testID}
            onPress={() => {
              navigation.navigate("Chats")
            }}
            style={styles.touchablestyle}
          >

            <SvgXml xml={props?.selectedTab == "Chats" ? chatFill : chatPlain} width={Scale(24)} height={Scale(24)} />
          </TouchableOpacity>
          <TouchableOpacity
         
            onPress={() => {

              navigation.navigate("MyProfile")
            }}
            style={styles.touchablestyle}
          >

            <SvgXml xml={props?.selectedTab == 'MyProfile' ? profileFill : profilePlain} width={Scale(24)} height={Scale(24)} />
          </TouchableOpacity>
          <TouchableOpacity

            onPress={() => {
              props.onCreatePost(true)
              setShowCreatePost(true)
            }
            }
            style={styles.touchablestyle}
          >
            <SvgXml xml={add} width={Scale(32)} height={Scale(32)} />

          </TouchableOpacity>
          <TouchableOpacity
            onPress={() => {

              navigation.navigate("Notifications")
            }}
            style={styles.touchablestyle}
          >
          

            <SvgXml xml={props?.selectedTab === 'Notifications' ? notificationfill : notificationPlain} width={Scale(24)} height={Scale(24)} />
            {count > 0 ?
            <View style={{
              borderWidth:3,
              borderColor:'#17161F',
              height:Scale(20),
              width:Scale(20),
       
              borderRadius:100,
              position: 'absolute', 
              left: Scale(10),
              justifyContent:'center',
              alignItems:'center',
            
              bottom: Scale(12)}}>
                <View style={{height:Scale(17),
              width:Scale(17),backgroundColor:Apptheme.getartisttextcolor(),
              borderRadius:100, justifyContent:'center',
              alignItems:'center',flexDirection:'row'}}>
                    <Text style={{color:'white',fontSize:Scale(8),fontFamily:FONTS.RobotoCondensedBold,letterSpacing: 1}}>{count ? count : 0}</Text>
                    {count > 99 ? 
                     <Text style={{color:'white',fontSize:Scale(8),marginBottom:Scale(8), letterSpacing: 1}}>+</Text>
                    :null}
                   
              </View>
   
             
           
            </View>
          :null}
          </TouchableOpacity>
          <TouchableOpacity
          disabled={time}
          testID={props.testrefresh}
           onPress={() => {
          navigation.navigate("FeedBlock", { index:1 })
          //  navigation.navigate("FeedBlock")
          timerCountFun()
            onRefresh()
          }}
            style={styles.touchablestyle}>

            <SvgXml xml={props?.selectedTab === 'Feed' ? vFill : vPlain} width={Scale(19)} height={Scale(24)} />
          </TouchableOpacity>
        </View>
      </View>
      <CreatePostModal
        navigation={props.navigation}
        showCreatepost={showCreatepost}
        onDismiss={() => {
          setShowCreatePost(false);
          props.onCreatePost(false);
        }}
        onRequestClose={() => {
          setShowCreatePost(false);
          props.onCreatePost(false);
        }}
        onDah={() => {
          setShowCreatePost(false);
          props.onCreatePost(false);
        }}
      />
    </View>
  );
}
Editor is loading...