aboutsummaryrefslogtreecommitdiff
path: root/src/components/search/RecentSearches.tsx
blob: b4cc5483b6f3d2dca54b2c3bb1961b22af012133 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React from 'react';
import {
  View,
  Text,
  TouchableOpacity,
  StyleSheet,
  TouchableOpacityProps,
  ScrollView,
} from 'react-native';
import {
  PreviewType,
  ProfilePreviewType,
  ScreenType,
  CategoryPreviewType,
} from '../../types';
import {TAGG_LIGHT_BLUE} from '../../constants';
import SearchResults from './SearchResults';
import {SCREEN_HEIGHT} from '../../utils';

interface RecentSearchesProps extends TouchableOpacityProps {
  sectionTitle: PreviewType;
  recents: Array<ProfilePreviewType>;
  recentCategories: CategoryPreviewType[];
  screenType: ScreenType;
}

const RecentSearches: React.FC<RecentSearchesProps> = (props) => {
  const {
    sectionTitle,
    recents,
    recentCategories,
    screenType,
  } = props;
  return (
    <ScrollView
      style={styles.mainContainer}
      contentContainerStyle={styles.contentContainer}>
      <View style={styles.header}>
        <Text style={styles.title}>{sectionTitle}</Text>
        <TouchableOpacity {...props}>
          <Text style={styles.clear}>Clear all</Text>
        </TouchableOpacity>
      </View>
      <SearchResults
        results={recents}
        categories={recentCategories}
        previewType={sectionTitle}
        screenType={screenType}
      />
    </ScrollView>
  );
};

const styles = StyleSheet.create({
  mainContainer: {
    flexGrow: 1,
  },
  contentContainer: {
    paddingBottom: SCREEN_HEIGHT * 0.1,
  },
  header: {
    paddingHorizontal: 25,
    paddingVertical: 5,
    flexDirection: 'row',
  },
  title: {
    fontSize: 18,
    fontWeight: '600',
    flexGrow: 1,
  },
  clear: {
    fontSize: 18,
    fontWeight: 'bold',
    color: TAGG_LIGHT_BLUE,
  },
});

export default RecentSearches;