diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-03-08 15:48:55 -0500 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-03-08 15:48:55 -0500 |
| commit | 7657657c2b8a28b96962ac4fa816bb1625a36e4b (patch) | |
| tree | f5233751e98ee871534473330cf59b518c5c0009 /src/components | |
| parent | 7e5f9c63360f8c4505bb414384e13f8c0f7576e4 (diff) | |
added support for badges
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/search/SearchResultCell.tsx | 3 | ||||
| -rw-r--r-- | src/components/search/SearchResultList.tsx | 20 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/components/search/SearchResultCell.tsx b/src/components/search/SearchResultCell.tsx index 0f6f5b7d..b6ce55d0 100644 --- a/src/components/search/SearchResultCell.tsx +++ b/src/components/search/SearchResultCell.tsx @@ -17,11 +17,13 @@ import { } from '../../utils/users'; interface SearchResults { + type: 'badges' | 'categories' | 'users'; profileData: ProfilePreviewType; loggedInUser: UserType; } const SearchResultsCell: React.FC<SearchResults> = ({ + type, profileData: { id, name, @@ -133,6 +135,7 @@ const SearchResultsCell: React.FC<SearchResults> = ({ style={styles.cellContainer} onPress={() => navigation.navigate('DiscoverUsers', { + type, searchCategory: {id, name}, }) }> diff --git a/src/components/search/SearchResultList.tsx b/src/components/search/SearchResultList.tsx index 14d5de6d..32caa764 100644 --- a/src/components/search/SearchResultList.tsx +++ b/src/components/search/SearchResultList.tsx @@ -53,14 +53,22 @@ const SearchResultList: React.FC<SearchResultsProps> = ({ contentContainerStyle={{paddingBottom: SCREEN_HEIGHT * 0.1}} sections={results} keyExtractor={(item, index) => item.id + index} - renderItem={({item}) => ( - <SearchResultsCell profileData={item} loggedInUser={loggedInUser} /> - )} + renderItem={({section, item}) => { + return ( + <SearchResultsCell + type={section.title} + profileData={item} + loggedInUser={loggedInUser} + /> + ); + }} renderSectionHeader={({section: {title, data}}) => { - if (title === 'categories' && data.length === 0) { + if (['categories', 'badges'].includes(title) && data.length === 0) { setShowSection(false); } - return sectionHeader(title !== 'categories' && showSection); + return sectionHeader( + ['users', 'categories'].includes(title) && showSection, + ); }} /> )} @@ -71,7 +79,7 @@ const SearchResultList: React.FC<SearchResultsProps> = ({ const styles = StyleSheet.create({ container: { marginTop: SCREEN_HEIGHT * 0.02, - height: SCREEN_HEIGHT, + height: SCREEN_HEIGHT * 0.9, }, sectionHeaderStyle: { width: '100%', |
