forked from rpeden/tomtom-maps-react-native-web
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSuggestions.js
52 lines (48 loc) · 1.42 KB
/
Suggestions.js
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
import React from 'react';
import { StyleSheet, View, TextInput, FlatList } from 'react-native';
import { SuggestionListItem } from "./SuggestionListItem";
export function Suggestions(props) {
let searchInputRef = undefined;
const handleOnPressItem = (item, event) => {
this.searchInputRef.blur()
props.onPressItem(item, event)
}
return (<View style={styles.suggestionListContainer}>
<TextInput
ref={(ref) => {this.searchInputRef = ref}}
style={styles.searchInput}
placeholder={props.placeholder}
onChangeText={props.handleSearchTextChange}>
</TextInput>
{props.showList && <FlatList style={styles.searchList} keyExtractor={(item, index) => index.toString()} keyboardShouldPersistTaps="always" initialNumToRender={5} data={props.suggestionListData} renderItem={({
item
}) => <SuggestionListItem onPressItem={handleOnPressItem} item={item}></SuggestionListItem>} />}
</View>);
}
const styles = StyleSheet.create({
searchButtons: {
flexDirection: 'row',
height: '10%',
backgroundColor: '#fff',
color: '#000',
alignItems: 'center',
justifyContent: 'center',
marginTop: 0,
paddingLeft: 18,
paddingRight: 18
},
searchInput: {
height: 40,
paddingLeft: 10,
paddingRight: 10,
borderWidth: 1
},
suggestionListContainer: {
width: "90%",
marginLeft: "5%",
},
searchList: {
width: "95%",
marginTop: 10,
}
});