|
@@ -6,25 +6,22 @@ import { ScrollView, StyleSheet, Text, TouchableOpacity } from 'react-native';
|
6
|
6
|
|
7
|
7
|
import AutoHeightWebView from 'react-native-autoheight-webview';
|
8
|
8
|
|
|
9
|
+import {
|
|
10
|
+ autoHeightHtml0,
|
|
11
|
+ autoHeightHtml1,
|
|
12
|
+ autoHeightScript,
|
|
13
|
+ autoHeightStyle0,
|
|
14
|
+ autoWidthHtml0,
|
|
15
|
+ autoWidthHtml1,
|
|
16
|
+ autoWidthScript,
|
|
17
|
+ autoWidthStyle0
|
|
18
|
+} from './config';
|
|
19
|
+
|
9
|
20
|
export default class Explorer extends Component {
|
10
|
21
|
constructor(props) {
|
11
|
22
|
super(props);
|
12
|
|
- this.html0 = `<p style="font-weight: 400;font-style: normal;font-size: 21px;line-height: 1.58;letter-spacing: -.003em;">Tags are great for describing the essence of your story in a single word or phrase, but stories are rarely about a single thing. <span style="background-color: transparent !important;background-image: linear-gradient(to bottom, rgba(146, 249, 190, 1), rgba(146, 249, 190, 1));">If I pen a story about moving across the country to start a new job in a car with my husband, two cats, a dog, and a tarantula, I wouldn’t only tag the piece with “moving”. I’d also use the tags “pets”, “marriage”, “career change”, and “travel tips”.</span></p>`;
|
13
|
|
- this.html1 = `Tags are great for describing the essence of your story in a single word or phrase, but stories are rarely about a single thing. If I pen a story about moving across the country to start a new job in a car with my husband, two cats, a dog, and a tarantula, I wouldn’t only tag the piece with “moving”. I’d also use the tags “pets”, “marriage”, “career change”, and “travel tips”.`;
|
14
|
|
- this.testStyle = `
|
15
|
|
- p {
|
16
|
|
- font-size: 25px !important;
|
17
|
|
- }
|
18
|
|
- `;
|
19
|
|
- this.script0 = `
|
20
|
|
- var styleElement = document.createElement('style');
|
21
|
|
- styleElement.innerHTML = '${this.testStyle.replace(/\'/g, "\\'").replace(/\n/g, '\\n')}';
|
22
|
|
- document.head.appendChild(styleElement)
|
23
|
|
- `;
|
24
|
|
- this.script1 = `document.body.style.background = 'cornflowerblue';`;
|
25
|
|
- // this.script1 = null;
|
26
|
23
|
this.state = {
|
27
|
|
- html: this.html0,
|
|
24
|
+ html: autoHeightHtml0,
|
28
|
25
|
script: null,
|
29
|
26
|
webViewStyle: null,
|
30
|
27
|
size: {
|
|
@@ -36,20 +33,19 @@ export default class Explorer extends Component {
|
36
|
33
|
|
37
|
34
|
changeSource = () => {
|
38
|
35
|
this.setState(prevState => ({
|
39
|
|
- html: prevState.html === this.html0 ? this.html1 : this.html0
|
|
36
|
+ html: prevState.html === autoHeightHtml0 ? autoHeightHtml1 : autoHeightHtml0
|
40
|
37
|
}));
|
41
|
38
|
};
|
42
|
39
|
|
43
|
40
|
changeStyle = () => {
|
44
|
41
|
this.setState(prevState => ({
|
45
|
|
- webViewStyle: prevState.webViewStyle == null ? this.testStyle : null
|
|
42
|
+ webViewStyle: prevState.webViewStyle == null ? autoHeightStyle0 : null
|
46
|
43
|
}));
|
47
|
44
|
};
|
48
|
45
|
|
49
|
46
|
changeScript = () => {
|
50
|
|
- // this.changeSource();
|
51
|
47
|
this.setState(prevState => ({
|
52
|
|
- script: prevState.script === this.script0 ? this.script1 : this.script0
|
|
48
|
+ script: prevState.script === null ? autoHeightScript : null
|
53
|
49
|
}));
|
54
|
50
|
};
|
55
|
51
|
|