Browse Source

Merge branch 'master' into docs/debugging-tweak

Thibault Malbranche 6 years ago
parent
commit
e22e7e2252
No account linked to committer's email address
7 changed files with 39 additions and 12 deletions
  1. 21
    11
      docs/Reference.md
  2. 1
    0
      ios/RNCWKWebView.h
  3. 1
    0
      ios/RNCWKWebView.m
  4. 1
    0
      ios/RNCWKWebViewManager.m
  5. 9
    0
      js/WebView.ios.js
  6. 5
    0
      js/WebViewTypes.js
  7. 1
    1
      package.json

+ 21
- 11
docs/Reference.md View File

@@ -8,7 +8,6 @@ This document lays out the current public properties and methods for the React N
8 8
 
9 9
 - [`source`](Reference.md#source)
10 10
 - [`automaticallyAdjustContentInsets`](Reference.md#automaticallyadjustcontentinsets)
11
-- [`injectJavaScript`](Reference.md#injectjavascript)
12 11
 - [`injectedJavaScript`](Reference.md#injectedjavascript)
13 12
 - [`mediaPlaybackRequiresUserAction`](Reference.md#mediaplaybackrequiresuseraction)
14 13
 - [`nativeConfig`](Reference.md#nativeconfig)
@@ -44,6 +43,7 @@ This document lays out the current public properties and methods for the React N
44 43
 - [`url`](Reference.md#url)
45 44
 - [`html`](Reference.md#html)
46 45
 - [`hideKeyboardAccessoryView`](Reference.md#hidekeyboardaccessoryview)
46
+- [`allowsBackForwardNavigationGestures`](Reference.md#allowsbackforwardnavigationgestures)
47 47
 
48 48
 ## Methods Index
49 49
 
@@ -52,6 +52,7 @@ This document lays out the current public properties and methods for the React N
52 52
 - [`goBack`](Reference.md#goback)
53 53
 - [`reload`](Reference.md#reload)
54 54
 - [`stopLoading`](Reference.md#stoploading)
55
+- [`injectJavaScript`](Reference.md#injectjavascriptstr)
55 56
 
56 57
 ---
57 58
 
@@ -95,16 +96,6 @@ Controls whether to adjust the content inset for web views that are placed behin
95 96
 
96 97
 ---
97 98
 
98
-### `injectJavaScript`
99
-
100
-Function that accepts a string that will be passed to the WebView and executed immediately as JavaScript.
101
-
102
-| Type     | Required |
103
-| -------- | -------- |
104
-| function | No       |
105
-
106
----
107
-
108 99
 ### `injectedJavaScript`
109 100
 
110 101
 Set this to provide JavaScript that will be injected into the web page when the view loads.
@@ -494,6 +485,17 @@ If true, this will hide the keyboard accessory view (< > and Done) when using th
494 485
 | ------- | -------- | -------- |
495 486
 | boolean | No       | iOS      |
496 487
 
488
+---
489
+
490
+### `allowsBackForwardNavigationGestures`
491
+
492
+If true, this will be able horizontal swipe gestures when using the WKWebView. The default value is `false`.
493
+
494
+| Type    | Required | Platform |
495
+| ------- | -------- | -------- |
496
+| boolean | No       | iOS      |
497
+
498
+
497 499
 ## Methods
498 500
 
499 501
 ### `extraNativeComponentConfig()`
@@ -534,6 +536,14 @@ stopLoading();
534 536
 
535 537
 Stop loading the current page.
536 538
 
539
+### `injectJavaScript(str)`
540
+
541
+```javascript
542
+injectJavaScript("... javascript string ...");
543
+```
544
+
545
+Executes the JavaScript string.
546
+
537 547
 ## Other Docs
538 548
 
539 549
 Also check out our [Getting Started Guide](Getting-Started.md) and [In-Depth Guide](Guide.md).

+ 1
- 0
ios/RNCWKWebView.h View File

@@ -36,6 +36,7 @@ shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
36 36
 @property (nonatomic, assign) UIEdgeInsets contentInset;
37 37
 @property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
38 38
 @property (nonatomic, assign) BOOL hideKeyboardAccessoryView;
39
+@property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures;
39 40
 
40 41
 - (void)postMessage:(NSString *)message;
41 42
 - (void)injectJavaScript:(NSString *)script;

+ 1
- 0
ios/RNCWKWebView.m View File

@@ -102,6 +102,7 @@ static NSString *const MessageHanderName = @"ReactNative";
102 102
     _webView.scrollView.scrollEnabled = _scrollEnabled;
103 103
     _webView.scrollView.bounces = _bounces;
104 104
     [_webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
105
+    _webView.allowsBackForwardNavigationGestures = _allowsBackForwardNavigationGestures;
105 106
 
106 107
 #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
107 108
     if ([_webView.scrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {

+ 1
- 0
ios/RNCWKWebViewManager.m View File

@@ -44,6 +44,7 @@ RCT_EXPORT_VIEW_PROPERTY(dataDetectorTypes, WKDataDetectorTypes)
44 44
 RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
45 45
 RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
46 46
 RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
47
+RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
47 48
 
48 49
 /**
49 50
  * Expose methods to enable messaging the webview.

+ 9
- 0
js/WebView.ios.js View File

@@ -151,6 +151,14 @@ class WebView extends React.Component<WebViewSharedProps, State> {
151 151
         'The scalesPageToFit property is not supported when useWebKit = true',
152 152
       );
153 153
     }
154
+    if (
155
+      !this.props.useWebKit &&
156
+      this.props.allowsBackForwardNavigationGestures
157
+    ) {
158
+      console.warn(
159
+        'The allowsBackForwardNavigationGestures property is not supported when useWebKit = false',
160
+      );
161
+    }
154 162
   }
155 163
 
156 164
   render() {
@@ -262,6 +270,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
262 270
           this.props.automaticallyAdjustContentInsets
263 271
         }
264 272
         hideKeyboardAccessoryView={this.props.hideKeyboardAccessoryView}
273
+        allowsBackForwardNavigationGestures={this.props.allowsBackForwardNavigationGestures}
265 274
         onLoadingStart={this._onLoadingStart}
266 275
         onLoadingFinish={this._onLoadingFinish}
267 276
         onLoadingError={this._onLoadingError}

+ 5
- 0
js/WebViewTypes.js View File

@@ -224,6 +224,11 @@ export type IOSWebViewProps = $ReadOnly<{|
224 224
    * backward compatible.
225 225
    */
226 226
   hideKeyboardAccessoryView?: ?boolean,
227
+  /**
228
+   * A Boolean value indicating whether horizontal swipe gestures will trigger
229
+   * back-forward list navigations.
230
+   */
231
+  allowsBackForwardNavigationGestures?: ?boolean,
227 232
 |}>;
228 233
 
229 234
 export type AndroidWebViewProps = $ReadOnly<{|

+ 1
- 1
package.json View File

@@ -7,7 +7,7 @@
7 7
     "Thibault Malbranche <malbranche.thibault@gmail.com>"
8 8
   ],
9 9
   "license": "MIT",
10
-  "version": "2.4.3",
10
+  "version": "2.5.0",
11 11
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
12 12
   "scripts": {
13 13
     "test:ios:flow": "flow check",