-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSearchBar.js
More file actions
62 lines (58 loc) · 2.43 KB
/
SearchBar.js
File metadata and controls
62 lines (58 loc) · 2.43 KB
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
import React from 'react';
import { View, StyleSheet, Text, TouchableOpacity, Alert } from 'react-native';
import tailwind from 'tailwind-react-native-classnames';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete'
import { Ionicons } from '@expo/vector-icons';
import { MaterialCommunityIcons } from '@expo/vector-icons';
const SearchBar = ({ setCity, city }) => {
return (
<View style={tailwind`flex-row mt-3 px-4 pb-3 border-b border-gray-100 border-b-2`}>
<GooglePlacesAutocomplete
placeholder={city || "Search"}
nearbyPlacesAPI="GooglePlacesSearch"
debounce={400}
onPress={data => setCity(data.structured_formatting.main_text)}
minLength={2}
fetchDetails={true}
returnKeyType={"search"}
onFail={error => Alert.alert('Worning', error)}
query={{
key: "",
language: 'en',
}}
styles={{
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
textInput: {
fontSize: 15,
fontWeight: '700',
backgroundColor: '#F3F4F6',
marginTop: 4
},
textInputContainer: {
backgroundColor: '#F3F4F6',
borderRadius: 40,
justifyContent: 'center',
}
}}
enablePoweredByContainer={false}
renderLeftButton={() => (
<View style={tailwind`self-center ml-3`}>
<Ionicons name="ios-location-sharp" size={24} color="#CCCCCC" />
</View>
)}
renderRightButton={() => (
<TouchableOpacity style={tailwind`self-center ml-3 flex-row items-center bg-white py-2 px-3 rounded-full mr-3`}>
<MaterialCommunityIcons name="clock-time-four" size={13} color="black" />
<Text style={tailwind`ml-1`}>Search</Text>
</TouchableOpacity>
)}
/>
</View>
);
}
const styles = StyleSheet.create({})
export default SearchBar;