Explorar el Código

WIP: iOS working

Jamon Holmgren hace 6 años
padre
commit
ee3d296d33
Se han modificado 4 ficheros con 62 adiciones y 40 borrados
  1. 2
    2
      index.js
  2. 19
    15
      src/js/WebView.android.js
  3. 40
    22
      src/js/WebView.ios.js
  4. 1
    1
      src/js/WebViewShared.js

+ 2
- 2
index.js Ver fichero

@@ -1,3 +1,3 @@
1
-import IRWebView from './src/js/IRWebView';
1
+import WebView from './src/js/WebView';
2 2
 
3
-export default IRWebView;
3
+export { WebView };

+ 19
- 15
src/js/WebView.android.js Ver fichero

@@ -9,21 +9,25 @@
9 9
 
10 10
 'use strict';
11 11
 
12
-const EdgeInsetsPropType = require('EdgeInsetsPropType');
13
-const ActivityIndicator = require('ActivityIndicator');
14
-const React = require('React');
15
-const PropTypes = require('prop-types');
16
-const ReactNative = require('ReactNative');
17
-const StyleSheet = require('StyleSheet');
18
-const UIManager = require('UIManager');
19
-const View = require('View');
20
-const ViewPropTypes = require('ViewPropTypes');
21
-const WebViewShared = require('WebViewShared');
22
-
23
-const deprecatedPropType = require('deprecatedPropType');
24
-const keyMirror = require('fbjs/lib/keyMirror');
25
-const requireNativeComponent = require('requireNativeComponent');
26
-const resolveAssetSource = require('resolveAssetSource');
12
+import React from 'React';
13
+import PropTypes from 'prop-types';
14
+
15
+import ReactNative from 'react-native';
16
+import {
17
+  ActivityIndicator,
18
+  EdgeInsetsPropType,
19
+  StyleSheet,
20
+  UIManager,
21
+  View,
22
+  ViewPropTypes,
23
+  requireNativeComponent,
24
+  resolveAssetSource
25
+} from 'react-native';
26
+
27
+import deprecatedPropType from 'deprecated-prop-type';
28
+import keyMirror from 'fbjs/lib/keyMirror';
29
+
30
+import WebViewShared from './WebViewShared';
27 31
 
28 32
 const RCT_WEBVIEW_REF = 'webview';
29 33
 

+ 40
- 22
src/js/WebView.ios.js Ver fichero

@@ -10,28 +10,46 @@
10 10
 
11 11
 'use strict';
12 12
 
13
-const ActivityIndicator = require('ActivityIndicator');
14
-const EdgeInsetsPropType = require('EdgeInsetsPropType');
15
-const Linking = require('Linking');
16
-const PropTypes = require('prop-types');
17
-const React = require('React');
18
-const ReactNative = require('ReactNative');
19
-const ScrollView = require('ScrollView');
20
-const StyleSheet = require('StyleSheet');
21
-const Text = require('Text');
22
-const UIManager = require('UIManager');
23
-const View = require('View');
24
-const ViewPropTypes = require('ViewPropTypes');
25
-const WebViewShared = require('WebViewShared');
26
-
27
-const deprecatedPropType = require('deprecatedPropType');
28
-const invariant = require('fbjs/lib/invariant');
29
-const keyMirror = require('fbjs/lib/keyMirror');
30
-const processDecelerationRate = require('processDecelerationRate');
31
-const requireNativeComponent = require('requireNativeComponent');
32
-const resolveAssetSource = require('resolveAssetSource');
33
-
34
-const RCTWebViewManager = require('NativeModules').WebViewManager;
13
+import React from 'react';
14
+import PropTypes from 'prop-types';
15
+
16
+import ReactNative from 'react-native'
17
+import {
18
+  ActivityIndicator,
19
+  EdgeInsetsPropType,
20
+  Linking,
21
+  ScrollView,
22
+  StyleSheet,
23
+  Text,
24
+  UIManager,
25
+  View,
26
+  ViewPropTypes,
27
+  requireNativeComponent,
28
+  NativeModules,
29
+  Image
30
+} from 'react-native';
31
+
32
+import invariant from 'fbjs/lib/invariant';
33
+import keyMirror from 'fbjs/lib/keyMirror';
34
+
35
+import deprecatedPropType from 'deprecated-prop-type';
36
+
37
+import WebViewShared from './WebViewShared';
38
+
39
+const resolveAssetSource = Image.resolveAssetSource;
40
+
41
+// Imported from https://github.com/facebook/react-native/blob/master/Libraries/Components/ScrollView/processDecelerationRate.js
42
+function processDecelerationRate(decelerationRate) {
43
+  if (decelerationRate === 'normal') {
44
+    decelerationRate = 0.998;
45
+  } else if (decelerationRate === 'fast') {
46
+    decelerationRate = 0.99;
47
+  }
48
+  return decelerationRate;
49
+}
50
+
51
+
52
+const RCTWebViewManager = NativeModules.WebViewManager;
35 53
 
36 54
 const BGWASH = 'rgba(255,255,255,0.8)';
37 55
 const RCT_WEBVIEW_REF = 'webview';

+ 1
- 1
src/js/WebViewShared.js Ver fichero

@@ -23,4 +23,4 @@ const WebViewShared = {
23 23
   },
24 24
 };
25 25
 
26
-module.exports = WebViewShared;
26
+export default WebViewShared;