forked from callstack/react-native-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchBarExample.js
68 lines (60 loc) · 1.68 KB
/
SearchBarExample.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* @flow */
import * as React from 'react';
import { StyleSheet, View } from 'react-native';
import { Colors, Caption, SearchBar, withTheme } from 'react-native-paper';
import type { Theme } from 'react-native-paper/types';
type Props = {
navigation: any,
theme: Theme,
};
type State = {
firstQuery: string,
secondQuery: string,
thirdQuery: string,
};
class SearchExample extends React.Component<Props, State> {
static title = 'Search bar';
state = {
firstQuery: '',
secondQuery: '',
thirdQuery: '',
};
render() {
const { theme: { colors: { background } } } = this.props;
return (
<View style={[styles.container, { backgroundColor: background }]}>
<SearchBar
placeholder="Search"
onChangeText={query => this.setState({ firstQuery: query })}
value={this.state.firstQuery}
/>
<Caption style={styles.caption}>Clickable icon</Caption>
<SearchBar
placeholder="Search"
onChangeText={query => this.setState({ secondQuery: query })}
value={this.state.secondQuery}
onIconPress={() => this.props.navigation.goBack()}
icon="arrow-back"
/>
<SearchBar
placeholder="Search"
onChangeText={query => this.setState({ thirdQuery: query })}
value={this.state.thirdQuery}
onIconPress={/* In real code, this will open the drawer */ () => {}}
icon="menu"
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.grey200,
},
caption: {
paddingHorizontal: 16,
paddingVertical: 8,
},
});
export default withTheme(SearchExample);