Repository navigation
Expand file tree
/
Copy pathApp.js
More file actions
66 lines (59 loc) · 1.59 KB
/
Copy pathApp.js
File metadata and controls
66 lines (59 loc) · 1.59 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
63
64
65
66
import React, { useState } from 'react';
import { StyleSheet, SafeAreaView, ScrollView, Text } from 'react-native';
import SearchBar from 'react-native-search-bar';
const items = ['Apples', 'Pie', 'Juice', 'Cake', 'Nuggets'];
const App = () => {
const [search, setSearch] = useState('');
const search1 = React.createRef();
const search2 = React.createRef();
return (
<SafeAreaView style={styles.container}>
<ScrollView contentContainerStyle={styles.inset}>
<Text style={styles.header}>Dark Style</Text>
<SearchBar
ref={search1}
barStyle="black"
onSearchButtonPress={() => search1.current.blur()}
/>
<Text style={styles.header}>Search Example</Text>
<SearchBar
text={search}
ref={search2}
onChange={e => console.log(e.nativeEvent)}
onChangeText={setSearch}
onSearchButtonPress={() => search2.current.blur()}
/>
{items
.filter(a => a.toLowerCase().indexOf(search.toLowerCase()) !== -1)
.map(a => (
<Text style={styles.listItem} key={a}>
{a}
</Text>
))}
</ScrollView>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: '#F5FCFF',
},
inset: {
flex: 1,
},
header: {
textAlign: 'center',
margin: 15,
fontSize: 18,
fontWeight: 'bold',
},
listItem: {
paddingHorizontal: 15,
paddingVertical: 12,
fontSize: 18,
backgroundColor: '#fff',
},
});
export default App;