aboutsummaryrefslogtreecommitdiff
path: root/src/screens/search/SearchScreen.tsx
blob: 8ef56b739c78b81d5b712ce76e3b24a95ee74e5a (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
79
80
81
82
83
import React, {useState} from 'react';
import {
  StatusBar,
  SafeAreaView,
  StyleSheet,
  Text,
  View,
  ScrollView,
} from 'react-native';
import {SearchBar, SuggestedSection, SearchBackground} from '../../components';
import {SCREEN_HEIGHT} from '../../utils';

/**
 * Search Screen for user recommendations and a search
 * tool to allow user to find other users
 */

const SearchScreen: React.FC = () => {
  const sections: Array<string> = [
    'People you follow',
    'People you may know',
    'Trending in sports',
    'Trending on Tagg',
    'Trending in music',
  ];
  // dummy user data
  const users: Array<string> = [
    'Sam Davis',
    'Becca Smith',
    'Ann Taylor',
    'Clara Johnson',
    'Sarah Jung',
    'Lila Hernandez',
  ];
  const [isSearching, setIsSearching] = useState<boolean>(false);
  const handleFocus = () => {
    setIsSearching(true);
  };
  const handleBlur = () => {
    setIsSearching(false);
  };
  return (
    <SearchBackground style={styles.screen}>
      <StatusBar />
      <SafeAreaView>
        <ScrollView showsVerticalScrollIndicator={false}>
          <Text style={styles.header}>Explore</Text>
          <SearchBar
            active={isSearching}
            onFocus={handleFocus}
            onBlur={handleBlur}
          />
          {!isSearching && (
            <View style={styles.content}>
              {sections.map((title) => (
                <SuggestedSection key={title} title={title} users={users} />
              ))}
            </View>
          )}
        </ScrollView>
      </SafeAreaView>
    </SearchBackground>
  );
};

const styles = StyleSheet.create({
  screen: {
    paddingTop: 50,
    paddingBottom: SCREEN_HEIGHT / 10,
    paddingHorizontal: 15,
  },
  content: {
    paddingVertical: 20,
  },
  header: {
    fontWeight: 'bold',
    fontSize: 24,
    color: '#fff',
    marginBottom: 20,
    textAlign: 'center',
  },
});
export default SearchScreen;