diff options
| author | ankit-thanekar007 <ankit.thanekar007@gmail.com> | 2021-03-02 13:04:27 -0800 |
|---|---|---|
| committer | ankit-thanekar007 <ankit.thanekar007@gmail.com> | 2021-03-03 12:44:58 -0800 |
| commit | 7a5ae728ee96acdf6b52fefa6ebaf7640a8724a1 (patch) | |
| tree | 5eca9475afee1354801964879a1732cce993d0c8 /src/components/search/SearchResultCell.tsx | |
| parent | d73e99036e5b78a9b7dbcc43e9a87aa6f9c1faeb (diff) | |
TMA-663-Updated Search init
Diffstat (limited to 'src/components/search/SearchResultCell.tsx')
| -rw-r--r-- | src/components/search/SearchResultCell.tsx | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/components/search/SearchResultCell.tsx b/src/components/search/SearchResultCell.tsx new file mode 100644 index 00000000..46d5ee44 --- /dev/null +++ b/src/components/search/SearchResultCell.tsx @@ -0,0 +1,100 @@ +import React, {useEffect, useState} from 'react'; +import {ProfilePreviewType, PreviewType, ScreenType} from '../../types'; +import ProfilePreview from '../profile/ProfilePreview'; +import {Image, SectionList, StyleSheet, View, Text} from 'react-native'; +import {normalize} from '../../utils'; +import {defaultUserProfile} from '../../utils/users'; +import {loadImageFromURL} from '../../services'; + + +const SearchResultsCell: React.FC<ProfilePreviewType> = ({ + item: {id, name, username, first_name, last_name, thumbnail_url}, + }) => { + const [avatar, setAvatar] = useState(''); + useEffect(() => { + (async () => { + const response = await loadImageFromURL(thumbnail_url); + if (response) { + setAvatar(response); + } + })(); + }, []); + + const userCell = () => { + return ( + <View + style={{ + flexDirection: 'row', + marginHorizontal: 24, + marginBottom: 24, + }}> + <Image + defaultSource={defaultUserProfile()} + source={{uri: avatar}} + style={{width: 42, height: 42, borderRadius: 21}} + /> + <View + style={{ + marginLeft: 30, + flexDirection: 'column', + justifyContent: 'space-between', + }}> + <Text + style={{ + fontWeight: '500', + fontSize: normalize(14), + }}> + {username} + </Text> + <Text + style={{ + fontWeight: '500', + fontSize: normalize(14), + }}> + {first_name + ' ' + last_name} + </Text> + </View> + </View> + ); + }; + + const categoryCell = () => { + return ( + <View + style={{ + flexDirection: 'row', + marginHorizontal: 24, + marginBottom: 24, + }}> + <Image + defaultSource={defaultUserProfile()} + source={{uri: avatar}} + style={{width: 42, height: 42, borderRadius: 21}} + /> + <View + style={{ + marginLeft: 30, + flexDirection: 'column', + justifyContent: 'center', + }}> + <Text + style={{ + fontWeight: '500', + fontSize: normalize(14), + }}> + {name} + </Text> + </View> + </View> + ); + }; + + return ( + <> + {name !== undefined && categoryCell()} + {name === undefined && userCell()} + </> + ); + }; + + export default SearchResultsCell
\ No newline at end of file |
