This repository was archived by the owner on Jul 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSentences.js
More file actions
62 lines (55 loc) · 1.49 KB
/
Copy pathSentences.js
File metadata and controls
62 lines (55 loc) · 1.49 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
/**
* Author: Yan Nan
* Description:
* Fetch some English-Chinese sentences from www.iciba.com.
* Beautified by 'Card' from 'react-native-elements'
*/
import React, { Component } from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import { Card } from 'react-native-elements';
import getDailySentence from './app/lib/daily-sentence';
// Feature: stateless component
const Sentence = ({ item, index }) => (
<Card title={item.date} image={{ uri: item.image }} >
<Text style={styles.english}> {' ' + item.sentence} </Text>
<Text style={styles.chinese}> {' ' + item.translation} </Text>
</Card>
);
export default class Sentences extends Component {
constructor(props) {
super(props);
this.state = {
dailyData: null,
};
}
componentDidMount() {
getDailySentence(5).then(result => {
this.setState({
dailyData: result,
});
});
}
render() {
return (
<View>
<FlatList
keyExtractor={(item, index) => index}
data={this.state.dailyData}
renderItem={Sentence}
/>
</View>
);
}
}
const styles = StyleSheet.create({
english: {
marginBottom: 10,
fontSize: 18,
fontStyle: 'italic',
fontWeight: 'bold'
},
chinese: {
marginBottom: 10,
fontSize: 18
}
});