-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
107 lines (101 loc) · 2.33 KB
/
App.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import React from 'react';
import {
StyleSheet,
Text,
View,
ScrollView,
Image
} from 'react-native';
import {
ReactiveBase,
DataSearch,
ReactiveList
} from '@appbaseio/reactivesearch-native';
export default class App extends React.Component {
constructor() {
super();
this.state = {
isReady: false
}
}
async componentWillMount() {
await Expo.Font.loadAsync({
Roboto: require('native-base/Fonts/Roboto.ttf'),
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
Ionicons: require('native-base/Fonts/Ionicons.ttf'),
});
this.setState({ isReady: true });
}
render() {
if (!this.state.isReady) {
return (
<View style={styles.container}>
<Text>Loading...</Text>
</View>
)
}
return (
<ReactiveBase
app="good-books-ds"
credentials="nY6NNTZZ6:27b76b9f-18ea-456c-bc5e-3a5263ebc63d"
>
<ScrollView>
<View style={styles.container}>
<DataSearch
componentId="searchbox"
dataField={[
'original_title',
'original_title.search',
'authors',
'authors.search',
]}
placeholder="Search for books"
/>
<ReactiveList
componentId="results"
dataField="original_title"
size={7}
showResultStats={false}
pagination={true}
react={{
and: "searchbox"
}}
onData={(res) => (
<View style={styles.result}>
<Image source={{ uri: res.image }} style={styles.image} />
<View style={styles.item}>
<Text style={styles.title}>{res.original_title}</Text>
<Text>{res.authors}</Text>
</View>
</View>
)}
/>
</View>
</ScrollView>
</ReactiveBase>
);
}
}
const styles = StyleSheet.create({
container: {
padding: 10,
marginTop: 25
},
image: {
width: 100,
height: 100
},
result: {
flexDirection: 'row',
width: '100%',
margin: 5,
alignItems: 'center',
},
item: {
flexDirection: 'column',
paddingLeft: 10
},
title: {
fontWeight: 'bold'
}
});