Bläddra i källkod

upgrade dependencies & use react-native-webview

iou90 5 år sedan
förälder
incheckning
5a29a36624
3 ändrade filer med 425 tillägg och 298 borttagningar
  1. 9
    6
      autoHeightWebView/index.ios.js
  2. 409
    286
      package-lock.json
  3. 7
    6
      package.json

+ 9
- 6
autoHeightWebView/index.ios.js Visa fil

@@ -2,12 +2,14 @@
2 2
 
3 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 7
 import PropTypes from 'prop-types';
8 8
 
9 9
 import { commonPropTypes } from './propTypes.js';
10 10
 
11
+import { WebView } from 'react-native-webview';
12
+
11 13
 import {
12 14
   isEqual,
13 15
   setState,
@@ -39,7 +41,6 @@ export default class AutoHeightWebView extends PureComponent {
39 41
 
40 42
   static defaultProps = {
41 43
     baseUrl: 'web/',
42
-    scalesPageToFit: false,
43 44
     enableAnimation: true,
44 45
     animationDuration: 255,
45 46
     heightOffset: 12
@@ -133,7 +134,6 @@ export default class AutoHeightWebView extends PureComponent {
133 134
       onLoadStart,
134 135
       onLoadEnd,
135 136
       onShouldStartLoadWithRequest,
136
-      scalesPageToFit,
137 137
       enableAnimation,
138 138
       heightOffset,
139 139
       style,
@@ -169,7 +169,6 @@ export default class AutoHeightWebView extends PureComponent {
169 169
           onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
170 170
           style={styles.webView}
171 171
           scrollEnabled={!!scrollEnabled}
172
-          scalesPageToFit={scalesPageToFit}
173 172
           injectedJavaScript={script}
174 173
           source={source}
175 174
           onNavigationStateChange={this.handleNavigationStateChange}
@@ -184,12 +183,16 @@ const styles = StyleSheet.create({
184 183
     backgroundColor: 'transparent'
185 184
   },
186 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 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 196
     updateSize();
194 197
     window.addEventListener('load', updateSize);
195 198
     window.addEventListener('resize', updateSize);

+ 409
- 286
package-lock.json
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 7
- 6
package.json Visa fil

@@ -29,18 +29,19 @@
29 29
   "homepage": "https://github.com/iou90/react-native-autoheight-webview#readme",
30 30
   "peerDependencies": {
31 31
     "react": "*",
32
-    "react-native": ">= 0.56.0"
32
+    "react-native": ">= 0.57.0"
33 33
   },
34 34
   "dependencies": {
35 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 39
   "devDependencies": {
39
-    "babel-eslint": "^8.2.2",
40
+    "babel-eslint": "^8.2.6",
40 41
     "eslint": "^4.18.1",
41 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
 }