import React from 'react'; import { ActivityIndicator, FlatList, StyleSheet, Text, View } from 'react-native'; import { vw } from 'stream-chat-react-native'; import { UserGridItem } from './UserGridItem'; import { EmptySearchState } from '../../icons/EmptySearchState'; import type { UserResponse } from 'stream-chat'; import type { LocalUserType } from '../../types'; const totalUserSpace = vw(100) - 56; // 36 = outside margin 8 * 2 + inner padding 20 * 2; const styles = StyleSheet.create({ container: { flex: 1, paddingHorizontal: 20, }, contentContainer: { flexGrow: 1 }, emptyResultIndicator: { alignItems: 'center', height: 300, justifyContent: 'center', }, flex: { flex: 1 }, userGridItemContainer: { paddingBottom: 10, width: 64, }, }); type UserSearchResultsGridProps = { onPress: (user: UserResponse) => void; results: UserResponse[]; gridSize?: number; loading?: boolean; loadMore?: () => void; searchText?: string; showOnlineStatus?: boolean; }; export const UserSearchResultsGrid: React.FC = ({ gridSize = 4, loading = false, loadMore = () => null, onPress, results, searchText, }) => ( {loading && results.length === 0 && searchText === '' ? ( ) : ( `${item.id}-${index}`} ListEmptyComponent={() => ( No user matches these keywords {loading ? 'true' : 'false'} {results.length} )} numColumns={gridSize} onEndReached={loadMore} renderItem={({ index, item: user }) => ( { onPress(user); }} removeButton={false} user={user} /> )} showsVerticalScrollIndicator={false} style={styles.flex} /> )} );