-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchBar.jsx
58 lines (54 loc) · 1.5 KB
/
SearchBar.jsx
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
import { Pressable, StyleSheet, TextInput, View } from "react-native";
import { Feather, Ionicons } from "@expo/vector-icons";
import { theme } from "../constants/theme";
import { hp, wp } from "../heplers/common";
const SearchBar = ({ search, handleTextDebounce, clearSearch, searchRef }) => {
return (
<View style={styles.searchBar}>
<View style={styles.searchIcon}>
<Feather name="search" size={24} color={theme.colors.neutral(0.4)} />
</View>
<TextInput
ref={searchRef}
placeholder="Search For Photos..."
style={styles.searchInput}
// value={search}
onChangeText={handleTextDebounce}
/>
{search !== "" ? (
<Pressable onPress={() => clearSearch()} style={styles.closeIcon}>
<Ionicons name="close" size={24} color={theme.colors.neutral(0.6)} />
</Pressable>
) : (
<View />
)}
</View>
);
};
export default SearchBar;
const styles = StyleSheet.create({
searchBar: {
backgroundColor: theme.colors.white,
borderRadius: theme.radius.sm,
marginHorizontal: wp(4),
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
paddingVertical: 6,
paddingHorizontal: 10,
},
searchIcon: {
padding: 8,
},
searchInput: {
flex: 1,
borderRadius: theme.radius.sm,
paddingVertical: 10,
fontSize: hp(1.8),
},
closeIcon: {
backgroundColor: theme.colors.neutral(0.1),
padding: 8,
borderRadius: theme.radius.sm,
},
});