-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathReadingPane.ios.js
69 lines (60 loc) · 1.28 KB
/
ReadingPane.ios.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
'use strict';
const React = require('react-native');
const {
StyleSheet,
ScrollView,
View,
WebView,
Text,
Platform
} = React;
const content = require('./services/content');
const { readingPaneStyles } = require('./config');
const ReadingPane = React.createClass({
getInitialState() {
return {
article: this.props.article || {}
}
},
componentDidMount() {
let { article } = this.props;
content.loadArticle(article.id)
.then(article => {
this.isMounted && this.setState({article})
})
},
render() {
let { contentHTML, title } = this.state.article;
contentHTML = readingPaneStyles + (contentHTML || '');
return (
<View style={styles.container}>
<View style={styles.header}>
<Text style={styles.title}>
{title}
</Text>
</View>
<WebView
style={{flex:1}}
html={contentHTML}
automaticallyAdjustContentInsets={true}
allowsInlineMediaPlayback={true}
/>
</View>
);
}
});
module.exports = ReadingPane;
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
alignItems: 'stretch'
},
header: {
marginTop: 60
},
title: {
margin: 10,
fontSize: 24
}
});