aboutsummaryrefslogtreecommitdiff
path: root/src/components/search/SearchResults.tsx
blob: 9d95593a57a1d1d9b30a3d9ed127daf1263d9045 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React from 'react';
import {ProfilePreviewType, PreviewType, ScreenType} from '../../types';
import ProfilePreview from '../profile/ProfilePreview';
import {StyleSheet, View} from 'react-native';
interface SearchResultsProps {
  results: Array<ProfilePreviewType>;
  previewType: PreviewType;
  screenType: ScreenType;
}
const SearchResults: React.FC<SearchResultsProps> = ({
  results,
  previewType,
  screenType,
}) => {
  /**
   * Added the following swicth case to make Results on Search and Recents screen a list
   * Flex is love
   */
  var containerStyle;
  switch (previewType) {
    case 'Search':
      containerStyle = styles.containerSearch;
      break;
    case 'Recent':
      containerStyle = styles.containerSearch;
      break;
    default:
      containerStyle = styles.container;
  }
  return (
    <View style={containerStyle}>
      {results.map((profilePreview) => (
        <ProfilePreview
          style={styles.result}
          key={profilePreview.id}
          {...{profilePreview}}
          previewType={previewType}
          screenType={screenType}
        />
      ))}
    </View>
  );
};

const styles = StyleSheet.create({
  containerSearch: {flexDirection: 'column', flexWrap: 'wrap'},
  container: {flexDirection: 'row', flexWrap: 'wrap'},
  result: {
    marginVertical: 10,
  },
});

export default SearchResults;