Browse Source

upgrade dependencies & use react-native-webview

iou90 5 years ago
parent
commit
5a29a36624
3 changed files with 425 additions and 298 deletions
  1. 9
    6
      autoHeightWebView/index.ios.js
  2. 409
    286
      package-lock.json
  3. 7
    6
      package.json

+ 9
- 6
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, WebView } from 'react-native';
5
+import { Animated, StyleSheet } 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';
9
 import { commonPropTypes } from './propTypes.js';
10
 
10
 
11
+import { WebView } from 'react-native-webview';
12
+
11
 import {
13
 import {
12
   isEqual,
14
   isEqual,
13
   setState,
15
   setState,
39
 
41
 
40
   static defaultProps = {
42
   static defaultProps = {
41
     baseUrl: 'web/',
43
     baseUrl: 'web/',
42
-    scalesPageToFit: false,
43
     enableAnimation: true,
44
     enableAnimation: true,
44
     animationDuration: 255,
45
     animationDuration: 255,
45
     heightOffset: 12
46
     heightOffset: 12
133
       onLoadStart,
134
       onLoadStart,
134
       onLoadEnd,
135
       onLoadEnd,
135
       onShouldStartLoadWithRequest,
136
       onShouldStartLoadWithRequest,
136
-      scalesPageToFit,
137
       enableAnimation,
137
       enableAnimation,
138
       heightOffset,
138
       heightOffset,
139
       style,
139
       style,
169
           onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
169
           onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
170
           style={styles.webView}
170
           style={styles.webView}
171
           scrollEnabled={!!scrollEnabled}
171
           scrollEnabled={!!scrollEnabled}
172
-          scalesPageToFit={scalesPageToFit}
173
           injectedJavaScript={script}
172
           injectedJavaScript={script}
174
           source={source}
173
           source={source}
175
           onNavigationStateChange={this.handleNavigationStateChange}
174
           onNavigationStateChange={this.handleNavigationStateChange}
184
     backgroundColor: 'transparent'
183
     backgroundColor: 'transparent'
185
   },
184
   },
186
   webView: {
185
   webView: {
187
-    flex: 1,
188
-    backgroundColor: 'transparent'
186
+    backgroundColor: 'transparent',
187
+    flex: 1
189
   }
188
   }
190
 });
189
 });
191
 
190
 
191
+// add viewport setting to meta for WKWebView
192
 const commonScript = `
192
 const commonScript = `
193
+    var meta = document.createElement('meta'); 
194
+    meta.setAttribute('name', 'viewport'); 
195
+    meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);
193
     updateSize();
196
     updateSize();
194
     window.addEventListener('load', updateSize);
197
     window.addEventListener('load', updateSize);
195
     window.addEventListener('resize', updateSize);
198
     window.addEventListener('resize', updateSize);

+ 409
- 286
package-lock.json
File diff suppressed because it is too large
View File


+ 7
- 6
package.json View File

29
   "homepage": "https://github.com/iou90/react-native-autoheight-webview#readme",
29
   "homepage": "https://github.com/iou90/react-native-autoheight-webview#readme",
30
   "peerDependencies": {
30
   "peerDependencies": {
31
     "react": "*",
31
     "react": "*",
32
-    "react-native": ">= 0.56.0"
32
+    "react-native": ">= 0.57.0"
33
   },
33
   },
34
   "dependencies": {
34
   "dependencies": {
35
     "immutable": "^3.8.2",
35
     "immutable": "^3.8.2",
36
-    "prop-types": "^15.6.2"
36
+    "prop-types": "^15.7.1",
37
+    "react-native-webview": "^5.0.7"
37
   },
38
   },
38
   "devDependencies": {
39
   "devDependencies": {
39
-    "babel-eslint": "^8.2.2",
40
+    "babel-eslint": "^8.2.6",
40
     "eslint": "^4.18.1",
41
     "eslint": "^4.18.1",
41
     "eslint-plugin-jsx": "^0.0.2",
42
     "eslint-plugin-jsx": "^0.0.2",
42
-    "eslint-plugin-jsx-a11y": "^6.0.3",
43
-    "eslint-plugin-react": "^7.7.0",
44
-    "eslint-plugin-react-native": "^3.2.1"
43
+    "eslint-plugin-jsx-a11y": "^6.2.1",
44
+    "eslint-plugin-react": "^7.12.4",
45
+    "eslint-plugin-react-native": "^3.6.0"
45
   }
46
   }
46
 }
47
 }