-
Notifications
You must be signed in to change notification settings - Fork 4
/
before.js
65 lines (56 loc) · 1.32 KB
/
before.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
import React, { Component } from 'react'
import { ScrollView, Text, View } from 'react-native'
import Loading from 'components/loading'
import Video from 'components/video'
import API from 'services/api'
class SeriesPage extends Component {
constructor(props) {
super(props)
this.state = { data: null }
}
async fetchData(id) {
let res = await API.getSeries(id)
let json = await res.json()
this.setState({ data: json.series })
}
componentWillMount() {
this.fetchData(this.props.id)
}
renderVideo(video) {
return (
<Video key={video.id} data={video} />
)
}
renderVideoList() {
if(this.state.data.videos.length > 0) {
return this.state.data.videos.map(video => this.renderVideo(video))
} else {
return (
<View>
<Text>No videos found</Text>
</View>
)
}
}
buildPage() {
if (this.state.data) {
return (
<ScrollView>
<View>
<Text>{this.state.data.title}</Text>
{ this.state.data.description ? <Text>{this.state.data.description}</Text> : null }
</View>
<View>
{this.renderVideoList()}
</View>
</ScrollView>
)
} else {
return <Loading />
}
}
render() {
return this.buildPage()
}
}
export default SeriesPage