forked from callstack/react-native-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchbarExample.js
83 lines (75 loc) · 1.84 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* @flow */
import * as React from 'react';
import { StyleSheet, View } from 'react-native';
import {
Colors,
Caption,
Searchbar,
withTheme,
type Theme,
} from 'react-native-paper';
type Props = {
navigation: any,
theme: Theme,
};
type State = {
firstQuery: string,
secondQuery: string,
thirdQuery: string,
};
class SearchExample extends React.Component<Props, State> {
static title = 'Searchbar';
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}
style={styles.searchbar}
/>
<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={{ source: 'arrow-back', direction: 'auto' }}
style={styles.searchbar}
/>
<Searchbar
placeholder="Search"
onChangeText={query => this.setState({ thirdQuery: query })}
value={this.state.thirdQuery}
onIconPress={/* In real code, this will open the drawer */ () => {}}
icon="menu"
style={styles.searchbar}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.grey200,
},
caption: {
paddingHorizontal: 16,
paddingVertical: 8,
},
searchbar: {
margin: 4,
},
});
export default withTheme(SearchExample);