import React, {useEffect, useState} from 'react'; import { SectionList, StyleSheet, Text, View, Keyboard, SectionListData, } from 'react-native'; import {useSelector} from 'react-redux'; import {RootState} from '../../store/rootreducer'; import {NO_RESULTS_FOUND} from '../../constants/strings'; import {PreviewType, ScreenType} from '../../types'; import {normalize, SCREEN_WIDTH} from '../../utils'; import SearchResultsCell from './SearchResultCell'; import {useBottomTabBarHeight} from '@react-navigation/bottom-tabs'; interface SearchResultsProps { // TODO: make sure results come in as same type, regardless of profile, category, badges results: SectionListData[]; previewType: PreviewType; screenType: ScreenType; } const sectionHeader: React.FC = (showBorder: Boolean) => { if (showBorder) { return ; } return null; }; const SearchResultList: React.FC = ({results}) => { const [showEmptyView, setshowEmptyView] = useState(false); const {user: loggedInUser} = useSelector((state: RootState) => state.user); const tabBarHeight = useBottomTabBarHeight(); useEffect(() => { if (results && results.length > 0) { setshowEmptyView( results[0].data.length === 0 && results[1].data.length === 0 && results[2].data.length === 0, ); } }, [results]); return showEmptyView ? ( {NO_RESULTS_FOUND} ) : ( item.id + index} renderItem={({item}) => { return ( ); }} renderSectionHeader={({section: {data}}) => sectionHeader(data.length !== 0) } stickySectionHeadersEnabled={false} /> ); }; 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), }, }); export default SearchResultList;