import {useBottomTabBarHeight} from '@react-navigation/bottom-tabs'; import React, {useEffect, useState} from 'react'; import { Keyboard, SectionList, SectionListData, StyleSheet, Text, View, } from 'react-native'; import {useSelector} from 'react-redux'; import {NO_RESULTS_FOUND} from '../../constants/strings'; import {RootState} from '../../store/rootreducer'; import {PreviewType, ScreenType} from '../../types'; import {normalize, SCREEN_WIDTH} from '../../utils'; import ChatResultsCell from './ChatResultsCell'; interface ChatResultsProps { // TODO: make sure results come in as same type, regardless of profile, category, badges results: SectionListData[]; previewType: PreviewType; screenType: ScreenType; setChatModalVisible: Function; } const ChatResultsList: React.FC = ({ results, setChatModalVisible, }) => { const [showEmptyView, setshowEmptyView] = useState(false); const {user: loggedInUser} = useSelector((state: RootState) => state.user); const tabbarHeight = useBottomTabBarHeight(); useEffect(() => { if (results && results.length > 0) { let showEmpty = true; results.forEach((e) => { if (e.data.length > 0) { showEmpty = false; } }); setshowEmptyView(showEmpty); } }, [results]); return showEmptyView ? ( {NO_RESULTS_FOUND} ) : ( item.id + index} renderItem={({item}) => ( )} stickySectionHeadersEnabled={false} ListEmptyComponent={() => ( Start a new chat by searching for someone )} /> ); }; const styles = StyleSheet.create({ container: { flex: 1, marginTop: 30, alignItems: 'center', }, sectionHeaderStyle: { width: '100%', height: 0.5, marginVertical: 5, backgroundColor: '#C4C4C4', }, noResultsTextContainer: { justifyContent: 'center', flexDirection: 'row', width: SCREEN_WIDTH, }, noResultsTextStyle: { fontWeight: '500', fontSize: normalize(14), }, empty: { marginTop: 20, justifyContent: 'center', alignItems: 'center', }, }); export default ChatResultsList;