Browse Source

Merge branch 'master' into android-download-try-catch

Jamon Holmgren 4 years ago
parent
commit
b03236c5ab
No account linked to committer's email address
7 changed files with 64 additions and 2 deletions
  1. 4
    0
      apple/RNCWebView.h
  2. 8
    0
      apple/RNCWebView.m
  3. 14
    0
      apple/RNCWebViewManager.m
  4. 3
    1
      docs/Debugging.md
  5. 19
    0
      docs/Reference.md
  6. 1
    1
      package.json
  7. 15
    0
      src/WebViewTypes.ts

+ 4
- 0
apple/RNCWebView.h View File

63
 @property (nonatomic, assign) BOOL ignoreSilentHardwareSwitch;
63
 @property (nonatomic, assign) BOOL ignoreSilentHardwareSwitch;
64
 @property (nonatomic, copy) NSString * _Nullable allowingReadAccessToURL;
64
 @property (nonatomic, copy) NSString * _Nullable allowingReadAccessToURL;
65
 
65
 
66
+#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* iOS 13 */
67
+@property (nonatomic, assign) WKContentMode contentMode;
68
+#endif
69
+
66
 + (void)setClientAuthenticationCredential:(nullable NSURLCredential*)credential;
70
 + (void)setClientAuthenticationCredential:(nullable NSURLCredential*)credential;
67
 + (void)setCustomCertificatesForHost:(nullable NSDictionary *)certificates;
71
 + (void)setCustomCertificatesForHost:(nullable NSDictionary *)certificates;
68
 - (void)postMessage:(NSString *_Nullable)message;
72
 - (void)postMessage:(NSString *_Nullable)message;

+ 8
- 0
apple/RNCWebView.m View File

226
   }
226
   }
227
   wkWebViewConfig.userContentController = [WKUserContentController new];
227
   wkWebViewConfig.userContentController = [WKUserContentController new];
228
 
228
 
229
+#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* iOS 13 */
230
+  if (@available(iOS 13.0, *)) {
231
+    WKWebpagePreferences *pagePrefs = [[WKWebpagePreferences alloc]init];
232
+    pagePrefs.preferredContentMode = _contentMode;
233
+    wkWebViewConfig.defaultWebpagePreferences = pagePrefs;
234
+  }
235
+#endif
236
+
229
   // Shim the HTML5 history API:
237
   // Shim the HTML5 history API:
230
   [wkWebViewConfig.userContentController addScriptMessageHandler:[[RNCWeakScriptMessageDelegate alloc] initWithDelegate:self]
238
   [wkWebViewConfig.userContentController addScriptMessageHandler:[[RNCWeakScriptMessageDelegate alloc] initWithDelegate:self]
231
                                                             name:HistoryShimName];
239
                                                             name:HistoryShimName];

+ 14
- 0
apple/RNCWebViewManager.m View File

14
 @interface RNCWebViewManager () <RNCWebViewDelegate>
14
 @interface RNCWebViewManager () <RNCWebViewDelegate>
15
 @end
15
 @end
16
 
16
 
17
+@implementation RCTConvert (WKWebView)
18
+#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* iOS 13 */
19
+RCT_ENUM_CONVERTER(WKContentMode, (@{
20
+    @"recommended": @(WKContentModeRecommended),
21
+    @"mobile": @(WKContentModeMobile),
22
+    @"desktop": @(WKContentModeDesktop),
23
+}), WKContentModeRecommended, integerValue)
24
+#endif
25
+@end
26
+
17
 @implementation RNCWebViewManager
27
 @implementation RNCWebViewManager
18
 {
28
 {
19
   NSConditionLock *_shouldStartLoadLock;
29
   NSConditionLock *_shouldStartLoadLock;
70
 RCT_EXPORT_VIEW_PROPERTY(contentInsetAdjustmentBehavior, UIScrollViewContentInsetAdjustmentBehavior)
80
 RCT_EXPORT_VIEW_PROPERTY(contentInsetAdjustmentBehavior, UIScrollViewContentInsetAdjustmentBehavior)
71
 #endif
81
 #endif
72
 
82
 
83
+#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* iOS 13 */
84
+RCT_EXPORT_VIEW_PROPERTY(contentMode, WKContentMode)
85
+#endif
86
+
73
 /**
87
 /**
74
  * Expose methods to enable messaging the webview.
88
  * Expose methods to enable messaging the webview.
75
  */
89
  */

+ 3
- 1
docs/Debugging.md View File

15
 3. Safari -> Develop -> [device name] -> [app name] -> [url - title]
15
 3. Safari -> Develop -> [device name] -> [app name] -> [url - title]
16
 4. You can now debug the WebView contents just as you would on the web
16
 4. You can now debug the WebView contents just as you would on the web
17
 
17
 
18
-##### Note:
18
+##### Notes:
19
 
19
 
20
 When debugging on device you must enable Web Inspector in your device settings:
20
 When debugging on device you must enable Web Inspector in your device settings:
21
 
21
 
22
 Settings -> Safari -> Advanced -> Web Inspector
22
 Settings -> Safari -> Advanced -> Web Inspector
23
 
23
 
24
+Also, if you don't see your device in the Develop menu, and you started Safari before you started your simulator, try restarting Safari.
25
+
24
 ### Android & Chrome
26
 ### Android & Chrome
25
 
27
 
26
 It's possible to debug WebView contents in the Android emulator or on a device using Chrome DevTools.
28
 It's possible to debug WebView contents in the Android emulator or on a device using Chrome DevTools.

+ 19
- 0
docs/Reference.md View File

45
 - [`overScrollMode`](Reference.md#overscrollmode)
45
 - [`overScrollMode`](Reference.md#overscrollmode)
46
 - [`contentInset`](Reference.md#contentinset)
46
 - [`contentInset`](Reference.md#contentinset)
47
 - [`contentInsetAdjustmentBehavior`](Reference.md#contentInsetAdjustmentBehavior)
47
 - [`contentInsetAdjustmentBehavior`](Reference.md#contentInsetAdjustmentBehavior)
48
+- [`contentMode`](Reference.md#contentMode)
48
 - [`dataDetectorTypes`](Reference.md#datadetectortypes)
49
 - [`dataDetectorTypes`](Reference.md#datadetectortypes)
49
 - [`scrollEnabled`](Reference.md#scrollenabled)
50
 - [`scrollEnabled`](Reference.md#scrollenabled)
50
 - [`directionalLockEnabled`](Reference.md#directionalLockEnabled)
51
 - [`directionalLockEnabled`](Reference.md#directionalLockEnabled)
917
 
918
 
918
 ---
919
 ---
919
 
920
 
921
+### `contentMode`[⬆](#props-index)<!-- Link generated with jump2header -->
922
+
923
+Controls the type of content to load. Available on iOS 13 and later. Defaults to `recommended`, which loads mobile content on iPhone & iPad Mini but desktop content on larger iPads.
924
+
925
+See [Introducing Desktop-class Browsing on iPad](https://developer.apple.com/videos/play/wwdc2019/203/) for more.
926
+
927
+Possible values:
928
+
929
+- `recommended`
930
+- `mobile`
931
+- `desktop`
932
+
933
+| Type   | Required | Platform |
934
+| ------ | -------- | -------- |
935
+| string | No       | iOS      |
936
+
937
+---
938
+
920
 ### `dataDetectorTypes`[⬆](#props-index)<!-- Link generated with jump2header -->
939
 ### `dataDetectorTypes`[⬆](#props-index)<!-- Link generated with jump2header -->
921
 
940
 
922
 Determines the types of data converted to clickable URLs in the web view's content. By default only phone numbers are detected.
941
 Determines the types of data converted to clickable URLs in the web view's content. By default only phone numbers are detected.

+ 1
- 1
package.json View File

8
     "Thibault Malbranche <malbranche.thibault@gmail.com>"
8
     "Thibault Malbranche <malbranche.thibault@gmail.com>"
9
   ],
9
   ],
10
   "license": "MIT",
10
   "license": "MIT",
11
-  "version": "10.4.1",
11
+  "version": "10.5.0",
12
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
12
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
13
   "scripts": {
13
   "scripts": {
14
     "start": "node node_modules/react-native/local-cli/cli.js start",
14
     "start": "node node_modules/react-native/local-cli/cli.js start",

+ 15
- 0
src/WebViewTypes.ts View File

299
   always = 'always'
299
   always = 'always'
300
 };
300
 };
301
 
301
 
302
+export declare type ContentMode = 'recommended' | 'mobile' | 'desktop';
303
+
302
 export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
304
 export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
303
   allowingReadAccessToURL?: string;
305
   allowingReadAccessToURL?: string;
304
   allowsBackForwardNavigationGestures?: boolean;
306
   allowsBackForwardNavigationGestures?: boolean;
308
   bounces?: boolean;
310
   bounces?: boolean;
309
   contentInset?: ContentInsetProp;
311
   contentInset?: ContentInsetProp;
310
   contentInsetAdjustmentBehavior?: ContentInsetAdjustmentBehavior;
312
   contentInsetAdjustmentBehavior?: ContentInsetAdjustmentBehavior;
313
+  contentMode?: ContentMode;
311
   readonly dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[];
314
   readonly dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[];
312
   decelerationRate?: number;
315
   decelerationRate?: number;
313
   directionalLockEnabled?: boolean;
316
   directionalLockEnabled?: boolean;
405
    */
408
    */
406
   contentInset?: ContentInsetProp;
409
   contentInset?: ContentInsetProp;
407
 
410
 
411
+  /**
412
+   * Defaults to `recommended`, which loads mobile content on iPhone
413
+   * and iPad Mini but desktop content on other iPads.
414
+   * 
415
+   * Possible values are:
416
+   * - `'recommended'`
417
+   * - `'mobile'`
418
+   * - `'desktop'`
419
+   * @platform ios
420
+   */
421
+  contentMode?: ContentMode;
422
+
408
   /**
423
   /**
409
    * Determines the types of data converted to clickable URLs in the web view's content.
424
    * Determines the types of data converted to clickable URLs in the web view's content.
410
    * By default only phone numbers are detected.
425
    * By default only phone numbers are detected.