Преглед изворни кода

feat(WKWebView): [ios] Add allowsLinkPreview property to WKWebView (#170)

* [ios] Add ‘allowsLinkPreview’ property to iOS WKWebView.

* Add divider in docs

* Typo: add hyphen -> _allowsLinkPreview
Jermaine Oosterling пре 5 година
родитељ
комит
731dd03fc6
7 измењених фајлова са 37 додато и 1 уклоњено
  1. 11
    0
      docs/Reference.md
  2. 1
    0
      ios/RNCWKWebView.h
  3. 2
    0
      ios/RNCWKWebView.m
  4. 1
    0
      ios/RNCWKWebViewManager.m
  5. 1
    0
      js/WebView.ios.js
  6. 10
    0
      js/WebViewTypes.js
  7. 11
    1
      typings/index.d.ts

+ 11
- 0
docs/Reference.md Прегледај датотеку

47
 - [`allowFileAccess`](Reference.md#allowFileAccess)
47
 - [`allowFileAccess`](Reference.md#allowFileAccess)
48
 - [`saveFormDataDisabled`](Reference.md#saveFormDataDisabled)
48
 - [`saveFormDataDisabled`](Reference.md#saveFormDataDisabled)
49
 - [`pagingEnabled`](Reference.md#pagingEnabled)
49
 - [`pagingEnabled`](Reference.md#pagingEnabled)
50
+- [`allowsLinkPreview`](Reference.md#allowsLinkPreview)
50
 
51
 
51
 ## Methods Index
52
 ## Methods Index
52
 
53
 
528
 | ------- | -------- | -------- |
529
 | ------- | -------- | -------- |
529
 | boolean | No       | iOS      |
530
 | boolean | No       | iOS      |
530
 
531
 
532
+---
533
+
534
+### `allowsLinkPreview`
535
+
536
+A Boolean value that determines whether pressing on a link displays a preview of the destination for the link. In iOS this property is available on devices that support 3D Touch. In iOS 10 and later, the default value is true; before that, the default value is false.
537
+
538
+| Type    | Required | Platform |
539
+| ------- | -------- | -------- |
540
+| boolean | No       | iOS      |
541
+
531
 ## Methods
542
 ## Methods
532
 
543
 
533
 ### `extraNativeComponentConfig()`
544
 ### `extraNativeComponentConfig()`

+ 1
- 0
ios/RNCWKWebView.h Прегледај датотеку

39
 @property (nonatomic, assign) BOOL hideKeyboardAccessoryView;
39
 @property (nonatomic, assign) BOOL hideKeyboardAccessoryView;
40
 @property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures;
40
 @property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures;
41
 @property (nonatomic, copy) NSString *userAgent;
41
 @property (nonatomic, copy) NSString *userAgent;
42
+@property (nonatomic, assign) BOOL allowsLinkPreview;
42
 
43
 
43
 - (void)postMessage:(NSString *)message;
44
 - (void)postMessage:(NSString *)message;
44
 - (void)injectJavaScript:(NSString *)script;
45
 - (void)injectJavaScript:(NSString *)script;

+ 2
- 0
ios/RNCWKWebView.m Прегледај датотеку

113
     _webView.scrollView.scrollEnabled = _scrollEnabled;
113
     _webView.scrollView.scrollEnabled = _scrollEnabled;
114
     _webView.scrollView.pagingEnabled = _pagingEnabled;
114
     _webView.scrollView.pagingEnabled = _pagingEnabled;
115
     _webView.scrollView.bounces = _bounces;
115
     _webView.scrollView.bounces = _bounces;
116
+    _webView.allowsLinkPreview = _allowsLinkPreview;
116
     [_webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
117
     [_webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
117
     _webView.allowsBackForwardNavigationGestures = _allowsBackForwardNavigationGestures;
118
     _webView.allowsBackForwardNavigationGestures = _allowsBackForwardNavigationGestures;
119
+
118
     if (_userAgent) {
120
     if (_userAgent) {
119
       _webView.customUserAgent = _userAgent;
121
       _webView.customUserAgent = _userAgent;
120
     }
122
     }

+ 1
- 0
ios/RNCWKWebViewManager.m Прегледај датотеку

47
 RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
47
 RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
48
 RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
48
 RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
49
 RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
49
 RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
50
+RCT_EXPORT_VIEW_PROPERTY(allowsLinkPreview, BOOL)
50
 
51
 
51
 /**
52
 /**
52
  * Expose methods to enable messaging the webview.
53
  * Expose methods to enable messaging the webview.

+ 1
- 0
js/WebView.ios.js Прегледај датотеку

291
           this.props.mediaPlaybackRequiresUserAction
291
           this.props.mediaPlaybackRequiresUserAction
292
         }
292
         }
293
         dataDetectorTypes={this.props.dataDetectorTypes}
293
         dataDetectorTypes={this.props.dataDetectorTypes}
294
+        allowsLinkPreview={this.props.allowsLinkPreview}
294
         {...nativeConfig.props}
295
         {...nativeConfig.props}
295
       />
296
       />
296
     );
297
     );

+ 10
- 0
js/WebViewTypes.js Прегледај датотеку

241
    * The custom user agent string.
241
    * The custom user agent string.
242
    */
242
    */
243
   userAgent?: ?string,
243
   userAgent?: ?string,
244
+
245
+  /**
246
+   * A Boolean value that determines whether pressing on a link
247
+   * displays a preview of the destination for the link.
248
+   *
249
+   * This property is available on devices that support 3D Touch.
250
+   * In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
251
+   * @platform ios
252
+   */
253
+  allowsLinkPreview?: ?boolean,
244
 |}>;
254
 |}>;
245
 
255
 
246
 export type AndroidWebViewProps = $ReadOnly<{|
256
 export type AndroidWebViewProps = $ReadOnly<{|

+ 11
- 1
typings/index.d.ts Прегледај датотеку

216
   /**
216
   /**
217
    * If true, this will be able horizontal swipe gestures when using the WKWebView. The default value is `false`.
217
    * If true, this will be able horizontal swipe gestures when using the WKWebView. The default value is `false`.
218
    */
218
    */
219
-  allowsBackForwardNavigationGestures?: boolean
219
+  allowsBackForwardNavigationGestures?: boolean;
220
+
221
+  /**
222
+   * A Boolean value that determines whether pressing on a link
223
+   * displays a preview of the destination for the link.
224
+   *
225
+   * This property is available on devices that support 3D Touch.
226
+   * In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
227
+   * @platform ios
228
+   */
229
+  allowsLinkPreview?: boolean;
220
 }
230
 }
221
 
231
 
222
 export interface AndroidWebViewProps {
232
 export interface AndroidWebViewProps {