Browse Source

apply webview props for index.ios.js

iou90 5 years ago
parent
commit
70f3e5a759
1 changed files with 24 additions and 32 deletions
  1. 24
    32
      autoHeightWebView/index.ios.js

+ 24
- 32
autoHeightWebView/index.ios.js View File

2
 
2
 
3
 import React, { PureComponent } from 'react';
3
 import React, { PureComponent } from 'react';
4
 
4
 
5
-import { Animated, StyleSheet, ViewPropTypes, WebView } from 'react-native';
5
+import { Animated, StyleSheet, WebView } from 'react-native';
6
 
6
 
7
 import PropTypes from 'prop-types';
7
 import PropTypes from 'prop-types';
8
 
8
 
9
+import { commonPropTypes } from './propTypes.js';
10
+
9
 import {
11
 import {
10
   isEqual,
12
   isEqual,
11
   setState,
13
   setState,
20
 
22
 
21
 export default class AutoHeightWebView extends PureComponent {
23
 export default class AutoHeightWebView extends PureComponent {
22
   static propTypes = {
24
   static propTypes = {
25
+    ...commonPropTypes,
23
     hasIframe: PropTypes.bool,
26
     hasIframe: PropTypes.bool,
24
-    onNavigationStateChange: PropTypes.func,
25
-    onMessage: PropTypes.func,
26
-    source: WebView.propTypes.source,
27
-    customScript: PropTypes.string,
28
-    customStyle: PropTypes.string,
29
-    enableAnimation: PropTypes.bool,
30
-    style: ViewPropTypes.style,
31
-    scrollEnabled: PropTypes.bool,
32
-    // either height or width updated will trigger this
33
-    onSizeUpdated: PropTypes.func,
34
-    // if set to true may cause some layout issues (smaller font size)
35
-    scalesPageToFit: PropTypes.bool,
36
     // only works on enable animation
27
     // only works on enable animation
37
     animationDuration: PropTypes.number,
28
     animationDuration: PropTypes.number,
38
     // offset of rn webview margin
29
     // offset of rn webview margin
39
     heightOffset: PropTypes.number,
30
     heightOffset: PropTypes.number,
40
-    //  rn WebView callback
41
-    onError: PropTypes.func,
42
-    onLoad: PropTypes.func,
43
-    onLoadStart: PropTypes.func,
44
-    onLoadEnd: PropTypes.func,
31
+    // webview props
32
+    scrollEnabled: PropTypes.bool,
45
     onShouldStartLoadWithRequest: PropTypes.func,
33
     onShouldStartLoadWithRequest: PropTypes.func,
34
+    decelerationRate: PropTypes.number,
46
     allowsInlineMediaPlayback: PropTypes.bool,
35
     allowsInlineMediaPlayback: PropTypes.bool,
47
-    // 'web/' by default
48
-    baseUrl: PropTypes.string,
49
-    // add baseUrl/files... to project root
50
-    files: PropTypes.arrayOf(
51
-      PropTypes.shape({
52
-        href: PropTypes.string,
53
-        type: PropTypes.string,
54
-        rel: PropTypes.string
55
-      })
56
-    )
36
+    bounces: PropTypes.bool,
37
+    dataDetectorTypes: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
57
   };
38
   };
58
 
39
 
59
   static defaultProps = {
40
   static defaultProps = {
139
   render() {
120
   render() {
140
     const { height, width } = this.state;
121
     const { height, width } = this.state;
141
     const {
122
     const {
123
+      renderError,
124
+      originWhitelist,
125
+      mediaPlaybackRequiresUserAction,
126
+      bounces,
127
+      decelerationRate,
128
+      allowsInlineMediaPlayback,
129
+      dataDetectorTypes,
142
       onMessage,
130
       onMessage,
143
       onError,
131
       onError,
144
       onLoad,
132
       onLoad,
149
       enableAnimation,
137
       enableAnimation,
150
       heightOffset,
138
       heightOffset,
151
       style,
139
       style,
152
-      scrollEnabled,
153
-      allowsInlineMediaPlayback
140
+      scrollEnabled
154
     } = this.props;
141
     } = this.props;
155
     const { source, script } = this.getUpdatedState(this.props, getBaseScript, getIframeBaseScript);
142
     const { source, script } = this.getUpdatedState(this.props, getBaseScript, getIframeBaseScript);
156
     return (
143
     return (
166
         ]}
153
         ]}
167
       >
154
       >
168
         <WebView
155
         <WebView
169
-          originWhitelist={['*']}
156
+          renderError={renderError}
157
+          mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}
158
+          bounces={bounces}
159
+          decelerationRate={decelerationRate}
160
+          allowsInlineMediaPlayback={allowsInlineMediaPlayback}
161
+          dataDetectorTypes={dataDetectorTypes}
162
+          originWhitelist={originWhitelist || ['*']}
170
           ref={this.webView}
163
           ref={this.webView}
171
           onMessage={onMessage}
164
           onMessage={onMessage}
172
           onError={onError}
165
           onError={onError}
180
           injectedJavaScript={script}
173
           injectedJavaScript={script}
181
           source={source}
174
           source={source}
182
           onNavigationStateChange={this.handleNavigationStateChange}
175
           onNavigationStateChange={this.handleNavigationStateChange}
183
-          allowsInlineMediaPlayback={allowsInlineMediaPlayback}
184
         />
176
         />
185
       </Animated.View>
177
       </Animated.View>
186
     );
178
     );