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,10 +2,12 @@
2 2
 
3 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 7
 import PropTypes from 'prop-types';
8 8
 
9
+import { commonPropTypes } from './propTypes.js';
10
+
9 11
 import {
10 12
   isEqual,
11 13
   setState,
@@ -20,40 +22,19 @@ import momoize from './momoize';
20 22
 
21 23
 export default class AutoHeightWebView extends PureComponent {
22 24
   static propTypes = {
25
+    ...commonPropTypes,
23 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 27
     // only works on enable animation
37 28
     animationDuration: PropTypes.number,
38 29
     // offset of rn webview margin
39 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 33
     onShouldStartLoadWithRequest: PropTypes.func,
34
+    decelerationRate: PropTypes.number,
46 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 40
   static defaultProps = {
@@ -139,6 +120,13 @@ export default class AutoHeightWebView extends PureComponent {
139 120
   render() {
140 121
     const { height, width } = this.state;
141 122
     const {
123
+      renderError,
124
+      originWhitelist,
125
+      mediaPlaybackRequiresUserAction,
126
+      bounces,
127
+      decelerationRate,
128
+      allowsInlineMediaPlayback,
129
+      dataDetectorTypes,
142 130
       onMessage,
143 131
       onError,
144 132
       onLoad,
@@ -149,8 +137,7 @@ export default class AutoHeightWebView extends PureComponent {
149 137
       enableAnimation,
150 138
       heightOffset,
151 139
       style,
152
-      scrollEnabled,
153
-      allowsInlineMediaPlayback
140
+      scrollEnabled
154 141
     } = this.props;
155 142
     const { source, script } = this.getUpdatedState(this.props, getBaseScript, getIframeBaseScript);
156 143
     return (
@@ -166,7 +153,13 @@ export default class AutoHeightWebView extends PureComponent {
166 153
         ]}
167 154
       >
168 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 163
           ref={this.webView}
171 164
           onMessage={onMessage}
172 165
           onError={onError}
@@ -180,7 +173,6 @@ export default class AutoHeightWebView extends PureComponent {
180 173
           injectedJavaScript={script}
181 174
           source={source}
182 175
           onNavigationStateChange={this.handleNavigationStateChange}
183
-          allowsInlineMediaPlayback={allowsInlineMediaPlayback}
184 176
         />
185 177
       </Animated.View>
186 178
     );