1
+ /* eslint-disable react-native/no-inline-styles */
1
2
import React , { useCallback , useState } from 'react' ;
2
3
import { StatusBar } from 'expo-status-bar' ;
3
4
import * as WebBrowser from 'expo-web-browser' ;
@@ -24,31 +25,47 @@ import YoutubeExample from './YoutubeExample';
24
25
25
26
const Stack = createStackNavigator ( ) ;
26
27
28
+ function Monospace ( { children } ) {
29
+ return (
30
+ < Text
31
+ style = { {
32
+ fontFamily : Platform . select ( { default : 'monospace' , ios : 'Menlo' } ) ,
33
+ fontWeight : 'bold'
34
+ } } >
35
+ { children }
36
+ </ Text >
37
+ ) ;
38
+ }
39
+
27
40
function SimpleExampleDescription ( ) {
28
41
return (
29
42
< Text style = { styles . welcome } >
30
- This Table renderer was created with extractHtmlProps function, and will
31
- render HTML tables in the body of the HTML component.
43
+ This < Monospace > TableRenderer</ Monospace > is the default export of{ ' ' }
44
+ < Monospace > @native-html/table-plugin</ Monospace > , and will render HTML
45
+ tables in the body of the HTML component via a{ ' ' }
46
+ < Monospace > WebView</ Monospace > .
32
47
</ Text >
33
48
) ;
34
49
}
35
50
36
51
function CustomExampleDescription ( ) {
37
52
return (
38
53
< Text style = { styles . welcome } >
39
- This Table renderer was created with extractHtmlTableProps function to
40
- register a custom component. Depending on the table complexity, it will
41
- display the HTLM table in the content or through an actionable modal.
54
+ This Table renderer was created with{ ' ' }
55
+ < Monospace > useHtmlTableProps</ Monospace > hook to register a custom
56
+ component. Depending on the table complexity, it will display the HTLM
57
+ table in the content or through an actionable modal.
42
58
</ Text >
43
59
) ;
44
60
}
45
61
46
- function YoutubeExampleDescription ( ) {
62
+ function YoutubeExampleDescription ( { scalesPageToFit } ) {
47
63
return (
48
64
< Text style = { styles . welcome } >
49
- This Iframe renderer has the scalesPageToFit option set to true. It will
50
- zoom down to a level that allows the whole content to be visible. Default
51
- is false.
65
+ This < Monospace > IframeRenderer</ Monospace > has the{ ' ' }
66
+ < Monospace > scalesPageToFit</ Monospace > option set to{ ' ' }
67
+ < Monospace children = { scalesPageToFit + '' } /> . It will zoom down to a
68
+ level that allows the whole content to be visible. Default is false.
52
69
</ Text >
53
70
) ;
54
71
}
@@ -91,16 +108,20 @@ function SimpleExampleScreen({ onLinkPress, availableWidth }) {
91
108
) ;
92
109
}
93
110
94
- function YoutubeExampleScreen ( { availableWidth } ) {
111
+ function YoutubeExampleScreen ( { availableWidth, scalesPageToFit } ) {
95
112
const [ instance , setInstance ] = useState ( 0 ) ;
96
113
return (
97
114
< ScrollView
98
115
contentContainerStyle = { styles . contentStyle }
99
116
style = { styles . scrollViewStyle } >
100
- < YoutubeExampleDescription />
117
+ < YoutubeExampleDescription scalesPageToFit = { scalesPageToFit } />
101
118
< Button title = "reload" onPress = { ( ) => setInstance ( ( i ) => i + 1 ) } />
102
119
< View style = { styles . example } >
103
- < YoutubeExample availableWidth = { availableWidth } instance = { instance } />
120
+ < YoutubeExample
121
+ scalesPageToFit = { scalesPageToFit }
122
+ availableWidth = { availableWidth }
123
+ instance = { instance }
124
+ />
104
125
</ View >
105
126
</ ScrollView >
106
127
) ;
@@ -112,21 +133,29 @@ function HomeScreen() {
112
133
< View style = { styles . buttonsContainer } >
113
134
< View style = { styles . button } >
114
135
< Button
115
- title = "Open simple table example"
136
+ title = "simple table example"
116
137
onPress = { ( ) => navigation . navigate ( 'SimpleExample' ) }
117
138
style = { styles . button }
118
139
/>
119
140
</ View >
120
141
< View style = { styles . button } >
121
142
< Button
122
- title = "Open custom table example"
143
+ title = "custom table example"
123
144
onPress = { ( ) => navigation . navigate ( 'CustomExample' ) }
124
145
/>
125
146
</ View >
126
- < Button
127
- title = "Open Youtube iframe example"
128
- onPress = { ( ) => navigation . navigate ( 'YoutubeExample' ) }
129
- />
147
+ < View style = { styles . button } >
148
+ < Button
149
+ title = "Youtube iframe example (scaling ON)"
150
+ onPress = { ( ) => navigation . navigate ( 'YoutubeExampleScaleOn' ) }
151
+ />
152
+ </ View >
153
+ < View style = { styles . button } >
154
+ < Button
155
+ title = "Youtube iframe example (scaling OFF)"
156
+ onPress = { ( ) => navigation . navigate ( 'YoutubeExampleScaleOff' ) }
157
+ />
158
+ </ View >
130
159
</ View >
131
160
) ;
132
161
}
@@ -184,9 +213,24 @@ export default function App() {
184
213
) }
185
214
</ Stack . Screen >
186
215
< Stack . Screen
187
- name = "YoutubeExample"
188
- options = { { title : 'Youtube Example' } } >
189
- { ( ) => < YoutubeExampleScreen availableWidth = { availableWidth } /> }
216
+ name = "YoutubeExampleScaleOn"
217
+ options = { { title : 'Youtube Example' , scalesPageToFit : true } } >
218
+ { ( ) => (
219
+ < YoutubeExampleScreen
220
+ availableWidth = { availableWidth }
221
+ scalesPageToFit = { true }
222
+ />
223
+ ) }
224
+ </ Stack . Screen >
225
+ < Stack . Screen
226
+ name = "YoutubeExampleScaleOff"
227
+ options = { { title : 'Youtube Example' , scalesPageToFit : false } } >
228
+ { ( ) => (
229
+ < YoutubeExampleScreen
230
+ availableWidth = { availableWidth }
231
+ scalesPageToFit = { false }
232
+ />
233
+ ) }
190
234
</ Stack . Screen >
191
235
</ Stack . Navigator >
192
236
</ NavigationContainer >
0 commit comments