Skip to content

Commit

Permalink
feat(iOS): Add prop autoManageStatusBarEnabled (react-native-webview#914
Browse files Browse the repository at this point in the history
)

Co-authored-by: Jamon Holmgren <[email protected]>
Co-authored-by: Jamon Holmgren <[email protected]>
Co-authored-by: Thibault Malbranche <[email protected]>
  • Loading branch information
4 people authored Sep 15, 2020
1 parent 4081410 commit 22a60fd
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 54 deletions.
1 change: 1 addition & 0 deletions apple/RNCWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@property (nonatomic, assign) BOOL injectedJavaScriptBeforeContentLoadedForMainFrameOnly;
@property (nonatomic, assign) BOOL scrollEnabled;
@property (nonatomic, assign) BOOL sharedCookiesEnabled;
@property (nonatomic, assign) BOOL autoManageStatusBarEnabled;
@property (nonatomic, assign) BOOL pagingEnabled;
@property (nonatomic, assign) CGFloat decelerationRate;
@property (nonatomic, assign) BOOL allowsInlineMediaPlayback;
Expand Down
12 changes: 10 additions & 2 deletions apple/RNCWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ - (instancetype)initWithFrame:(CGRect)frame
_showsVerticalScrollIndicator = YES;
_directionalLockEnabled = YES;
_automaticallyAdjustContentInsets = YES;
_autoManageStatusBarEnabled = YES;
_contentInset = UIEdgeInsetsZero;
_savedKeyboardDisplayRequiresUserAction = YES;
#if !TARGET_OS_OSX
Expand Down Expand Up @@ -335,16 +336,24 @@ - (void)removeFromSuperview
-(void)showFullScreenVideoStatusBars
{
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (!_autoManageStatusBarEnabled) {
return;
}

_isFullScreenVideoOpen = YES;
RCTUnsafeExecuteOnMainQueueSync(^{
[RCTSharedApplication() setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
[RCTSharedApplication() setStatusBarStyle:self->_savedStatusBarStyle animated:YES];
});
#pragma clang diagnostic pop
}

-(void)hideFullScreenVideoStatusBars
{
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (!_autoManageStatusBarEnabled) {
return;
}

_isFullScreenVideoOpen = NO;
RCTUnsafeExecuteOnMainQueueSync(^{
[RCTSharedApplication() setStatusBarHidden:self->_savedStatusBarHidden animated:YES];
Expand Down Expand Up @@ -1375,4 +1384,3 @@ - (void)userContentController:(WKUserContentController *)userContentController d
}

@end

1 change: 1 addition & 0 deletions apple/RNCWebViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ - (RCTUIView *)view
#endif
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
RCT_EXPORT_VIEW_PROPERTY(autoManageStatusBarEnabled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
RCT_EXPORT_VIEW_PROPERTY(incognito, BOOL)
Expand Down
Loading

0 comments on commit 22a60fd

Please sign in to comment.