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