-
Notifications
You must be signed in to change notification settings - Fork 18
/
SimpleExample.js
203 lines (194 loc) · 5.22 KB
/
SimpleExample.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import React from 'react';
import RenderHTML from 'react-native-render-html';
import table from '@native-html/table-plugin';
import WebView from 'react-native-webview';
const table1 = `
<h2>Small table</h2>
<table>
<tr>
<th>Entry Header 1</th>
<th>Entry Header 2</th>
<th>Entry Header 3</th>
</tr>
<tr>
<td>Entry First Line 1</td>
<td>Entry First Line 2</td>
<td>Entry First Line 3</td>
</tr>
<tr>
<td>Entry Second Line 1</td>
<td>Entry Second Line 2</td>
<td>Entry Second Line 3</td>
</tr>
<tr>
<td>Entry Third Line 1</td>
<td>Entry Third Line 2</td>
<td>Entry Third Line 3</td>
</tr>
</table>
<h2>Big table</h2>
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste website</td>
<td>Maria Anders</td>
<td><a class="a" href="https://en.wikipedia.org/wiki/germany">Germany</a></td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td><a href="https://en.wikipedia.org/wiki/mexico">Mexico</a></td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td><a href="https://en.wikipedia.org/wiki/austria">Austria</a></td>
</tr>
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td><a href="https://en.wikipedia.org/wiki/united_kingdom">UK</td>
</tr>
<tr>
<td>Laughing Bacchus Winecellars</td>
<td>Yoshi Tannamuri</td>
<td><a href="https://en.wikipedia.org/wiki/canada">Canada</a></td>
</tr>
<tr>
<td>Magazzini Alimentari Riuniti</td>
<td>Giovanni Rovelli</td>
<td><a href="https://en.wikipedia.org/wiki/italy">Italy</a></td>
</tr>
<tr>
<td>Alfreds Futterkiste website</td>
<td>Maria Anders</td>
<td><a href="https://en.wikipedia.org/wiki/germany">Germany</a></td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td><a href="https://en.wikipedia.org/wiki/mexico">Mexico</a></td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td><a href="https://en.wikipedia.org/wiki/austria">Austria</a></td>
</tr>
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td><a href="https://en.wikipedia.org/wiki/united_kingdom">UK</td>
</tr>
<tr>
<td>Laughing Bacchus Winecellars</td>
<td>Yoshi Tannamuri</td>
<td><a href="https://en.wikipedia.org/wiki/canada">Canada</a></td>
</tr>
<tr>
<td>Magazzini Alimentari Riuniti</td>
<td>Giovanni Rovelli</td>
<td><a href="https://en.wikipedia.org/wiki/italy">Italy</a></td>
</tr>
<tr>
<td>Alfreds Futterkiste website</td>
<td>Maria Anders</td>
<td><a href="https://en.wikipedia.org/wiki/germany">Germany</a></td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td><a href="https://en.wikipedia.org/wiki/mexico">Mexico</a></td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td><a href="https://en.wikipedia.org/wiki/austria">Austria</a></td>
</tr>
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td><a href="https://en.wikipedia.org/wiki/united_kingdom">UK</td>
</tr>
<tr>
<td>Laughing Bacchus Winecellars</td>
<td>Yoshi Tannamuri</td>
<td><a href="https://en.wikipedia.org/wiki/canada">Canada</a></td>
</tr>
<tr>
<td>Magazzini Alimentari Riuniti</td>
<td>Giovanni Rovelli</td>
<td><a href="https://en.wikipedia.org/wiki/italy">Italy</a></td>
</tr>
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td><a href="https://en.wikipedia.org/wiki/united_kingdom">UK</td>
</tr>
<tr>
<td>Laughing Bacchus Winecellars</td>
<td>Yoshi Tannamuri</td>
<td><a href="https://en.wikipedia.org/wiki/canada">Canada</a></td>
</tr>
<tr>
<td>Magazzini Alimentari Riuniti</td>
<td>Giovanni Rovelli</td>
<td><a href="https://en.wikipedia.org/wiki/italy">Italy</a></td>
</tr>
</table>
<h2>Header 2</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
`;
const renderers = {
table
};
const htmlConfig = {
renderers,
WebView,
renderersProps: {
table: {
animationType: 'animated',
tableStyleSpecs: {
outerBorderWidthPx: 1,
rowsBorderWidthPx: 1,
columnsBorderWidthPx: 1
}
}
},
tagsStyles: {
table: {
flex: 1
}
},
defaultWebViewProps: {},
computeEmbeddedMaxWidth: (contentWidth, tagName) => {
if (tagName === 'table') {
return Math.min(contentWidth, 500);
}
return contentWidth;
}
};
export default function SimpleExample({
instance,
onLinkPress,
availableWidth
}) {
return (
<RenderHTML
key={`simple-${instance}`}
source={{ html: table1 }}
contentWidth={availableWidth}
{...htmlConfig}
renderersProps={{
a: { onPress: onLinkPress },
...htmlConfig.renderersProps
}}
debug={false}
/>
);
}