Browse Source

add prop autoManageStatusBarEnabled

Kesha Antonov 5 years ago
parent
commit
b46144d629
5 changed files with 36 additions and 3 deletions
  1. 21
    2
      docs/Reference.md
  2. 1
    0
      ios/RNCWebView.h
  3. 5
    1
      ios/RNCWebView.m
  4. 1
    0
      ios/RNCWebViewManager.m
  5. 8
    0
      src/WebViewTypes.ts

+ 21
- 2
docs/Reference.md View File

58
 - [`allowsLinkPreview`](Reference.md#allowsLinkPreview)
58
 - [`allowsLinkPreview`](Reference.md#allowsLinkPreview)
59
 - [`sharedCookiesEnabled`](Reference.md#sharedCookiesEnabled)
59
 - [`sharedCookiesEnabled`](Reference.md#sharedCookiesEnabled)
60
 - [`textZoom`](Reference.md#textZoom)
60
 - [`textZoom`](Reference.md#textZoom)
61
+- [`autoManageStatusBarEnabled`](Reference.md#autoManageStatusBarEnabled)
61
 
62
 
62
 ## Methods Index
63
 ## Methods Index
63
 
64
 
343
 ### `onHttpError`
344
 ### `onHttpError`
344
 
345
 
345
 Function that is invoked when the `WebView` receives an http error.
346
 Function that is invoked when the `WebView` receives an http error.
347
+
346
 > **_Note_**
348
 > **_Note_**
347
 > Android API minimum level 23.
349
 > Android API minimum level 23.
348
 
350
 
357
   source={{ uri: 'https://facebook.github.io/react-native' }}
359
   source={{ uri: 'https://facebook.github.io/react-native' }}
358
   onHttpError={syntheticEvent => {
360
   onHttpError={syntheticEvent => {
359
     const { nativeEvent } = syntheticEvent;
361
     const { nativeEvent } = syntheticEvent;
360
-    console.warn('WebView received error status code: ', nativeEvent.statusCode);
362
+    console.warn(
363
+      'WebView received error status code: ',
364
+      nativeEvent.statusCode,
365
+    );
361
   }}
366
   }}
362
 />
367
 />
363
 ```
368
 ```
446
   onContentProcessDidTerminate={syntheticEvent => {
451
   onContentProcessDidTerminate={syntheticEvent => {
447
     const { nativeEvent } = syntheticEvent;
452
     const { nativeEvent } = syntheticEvent;
448
     console.warn('Content process terminated, reloading', nativeEvent);
453
     console.warn('Content process terminated, reloading', nativeEvent);
449
-    this.refs.webview.reload()
454
+    this.refs.webview.reload();
450
   }}
455
   }}
451
 />
456
 />
452
 ```
457
 ```
1005
 
1010
 
1006
 `<WebView textZoom={100} />`
1011
 `<WebView textZoom={100} />`
1007
 
1012
 
1013
+---
1014
+
1015
+### `autoManageStatusBarEnabled`
1016
+
1017
+If the user watch fullscreen video in WebView then StatusBar will be light. The default value is `true`.
1018
+
1019
+| Type   | Required | Platform |
1020
+| ------ | -------- | -------- |
1021
+| number | No       | iOS      |
1022
+
1023
+Example:
1024
+
1025
+`<WebView autoManageStatusBarEnabled={false} />`
1026
+
1008
 ## Methods
1027
 ## Methods
1009
 
1028
 
1010
 ### `extraNativeComponentConfig()`
1029
 ### `extraNativeComponentConfig()`

+ 1
- 0
ios/RNCWebView.h View File

27
 @property (nonatomic, copy) NSString * _Nullable injectedJavaScript;
27
 @property (nonatomic, copy) NSString * _Nullable injectedJavaScript;
28
 @property (nonatomic, assign) BOOL scrollEnabled;
28
 @property (nonatomic, assign) BOOL scrollEnabled;
29
 @property (nonatomic, assign) BOOL sharedCookiesEnabled;
29
 @property (nonatomic, assign) BOOL sharedCookiesEnabled;
30
+@property (nonatomic, assign) BOOL autoManageStatusBarEnabled;
30
 @property (nonatomic, assign) BOOL pagingEnabled;
31
 @property (nonatomic, assign) BOOL pagingEnabled;
31
 @property (nonatomic, assign) CGFloat decelerationRate;
32
 @property (nonatomic, assign) CGFloat decelerationRate;
32
 @property (nonatomic, assign) BOOL allowsInlineMediaPlayback;
33
 @property (nonatomic, assign) BOOL allowsInlineMediaPlayback;

+ 5
- 1
ios/RNCWebView.m View File

68
     _showsVerticalScrollIndicator = YES;
68
     _showsVerticalScrollIndicator = YES;
69
     _directionalLockEnabled = YES;
69
     _directionalLockEnabled = YES;
70
     _automaticallyAdjustContentInsets = YES;
70
     _automaticallyAdjustContentInsets = YES;
71
+    _autoManageStatusBarEnabled = YES;
71
     _contentInset = UIEdgeInsetsZero;
72
     _contentInset = UIEdgeInsetsZero;
72
     _savedKeyboardDisplayRequiresUserAction = YES;
73
     _savedKeyboardDisplayRequiresUserAction = YES;
73
     _savedStatusBarStyle = RCTSharedApplication().statusBarStyle;
74
     _savedStatusBarStyle = RCTSharedApplication().statusBarStyle;
278
 -(void)toggleFullScreenVideoStatusBars
279
 -(void)toggleFullScreenVideoStatusBars
279
 {
280
 {
280
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
281
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
282
+  if (!_autoManageStatusBarEnabled) {
283
+    return;
284
+  }
281
   if (!_isFullScreenVideoOpen) {
285
   if (!_isFullScreenVideoOpen) {
282
     _isFullScreenVideoOpen = YES;
286
     _isFullScreenVideoOpen = YES;
283
     RCTUnsafeExecuteOnMainQueueSync(^{
287
     RCTUnsafeExecuteOnMainQueueSync(^{
870
         _onHttpError(event);
874
         _onHttpError(event);
871
       }
875
       }
872
     }
876
     }
873
-  }  
877
+  }
874
 
878
 
875
   decisionHandler(WKNavigationResponsePolicyAllow);
879
   decisionHandler(WKNavigationResponsePolicyAllow);
876
 }
880
 }

+ 1
- 0
ios/RNCWebViewManager.m View File

59
 #endif
59
 #endif
60
 RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
60
 RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
61
 RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
61
 RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
62
+RCT_EXPORT_VIEW_PROPERTY(autoManageStatusBarEnabled, BOOL)
62
 RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
63
 RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
63
 RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
64
 RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
64
 RCT_EXPORT_VIEW_PROPERTY(incognito, BOOL)
65
 RCT_EXPORT_VIEW_PROPERTY(incognito, BOOL)

+ 8
- 0
src/WebViewTypes.ts View File

257
   allowsInlineMediaPlayback?: boolean;
257
   allowsInlineMediaPlayback?: boolean;
258
   allowsLinkPreview?: boolean;
258
   allowsLinkPreview?: boolean;
259
   automaticallyAdjustContentInsets?: boolean;
259
   automaticallyAdjustContentInsets?: boolean;
260
+  autoManageStatusBarEnabled?: boolean;
260
   bounces?: boolean;
261
   bounces?: boolean;
261
   contentInset?: ContentInsetProp;
262
   contentInset?: ContentInsetProp;
262
   contentInsetAdjustmentBehavior?:
263
   contentInsetAdjustmentBehavior?:
415
    */
416
    */
416
   sharedCookiesEnabled?: boolean;
417
   sharedCookiesEnabled?: boolean;
417
 
418
 
419
+  /**
420
+   * Set true if StatusBar should be light when user watch video fullscreen.
421
+   * The default value is `true`.
422
+   * @platform ios
423
+   */
424
+  autoManageStatusBarEnabled?: boolean;
425
+
418
   /**
426
   /**
419
    * A Boolean value that determines whether scrolling is disabled in a particular direction.
427
    * A Boolean value that determines whether scrolling is disabled in a particular direction.
420
    * The default value is `true`.
428
    * The default value is `true`.