This is an automated email from the ASF dual-hosted git repository.

GitToTheHub pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-ios.git


The following commit(s) were added to refs/heads/master by this push:
     new 3b3c7578 refactor(statusbar): Refactor the status bar hiding code 
(#1701)
3b3c7578 is described below

commit 3b3c7578725795f3e1bd0dc7c40af9508d64214c
Author: Darryl Pogue <[email protected]>
AuthorDate: Thu Aug 27 23:46:31 2026 -0700

    refactor(statusbar): Refactor the status bar hiding code (#1701)
---
 CordovaLib/Classes/Public/CDVViewController.m | 15 +++++++++++---
 tests/CordovaLibTests/CDVStatusBarTests.m     | 30 ++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/CordovaLib/Classes/Public/CDVViewController.m 
b/CordovaLib/Classes/Public/CDVViewController.m
index 17695756..071a1983 100644
--- a/CordovaLib/Classes/Public/CDVViewController.m
+++ b/CordovaLib/Classes/Public/CDVViewController.m
@@ -45,6 +45,7 @@ static UIColor *defaultBackgroundColor(void) {
     UIColor *_statusBarBackgroundColor;
     UIColor *_statusBarWebViewColor;
     UIColor *_statusBarDefaultColor;
+    BOOL _statusBarHidden;
     CDVSettingsDictionary* _settings;
 }
 
@@ -598,7 +599,11 @@ static UIColor *defaultBackgroundColor(void) {
     // On Mac Catalyst, Cordova may manually constrain the web view below the 
title bar.
     // In that case automatic scroll-view inset adjustment is disabled, so the 
synthetic
     // status bar view should be hidden.
-    self.statusBarBackground.hidden = 
(scrollView.contentInsetAdjustmentBehavior == 
UIScrollViewContentInsetAdjustmentNever);
+    if (_statusBarHidden) {
+        self.statusBarBackground.hidden = true;
+    } else {
+        self.statusBarBackground.hidden = 
(scrollView.contentInsetAdjustmentBehavior == 
UIScrollViewContentInsetAdjustmentNever);
+    }
 #endif
 }
 
@@ -607,7 +612,7 @@ static UIColor *defaultBackgroundColor(void) {
 {
     // The CDVStatusBar plugin overrides this in a category extension, and
     // should bypass this implementation entirely
-    return self.statusBarBackground.alpha < 0.0001f;
+    return _statusBarHidden;
 }
 #endif
 
@@ -905,7 +910,11 @@ static UIColor *defaultBackgroundColor(void) {
 - (void)showStatusBar:(BOOL)visible
 {
 #if !defined(TARGET_OS_VISION) || !TARGET_OS_VISION
-    [self.statusBarBackground setAlpha:(visible ? 1 : 0)];
+    _statusBarHidden = !visible;
+
+    UIScrollView *scrollView = [self.webView 
performSelector:@selector(scrollView)];
+    [self scrollViewDidChangeAdjustedContentInset:scrollView];
+
     [self setNeedsStatusBarAppearanceUpdate];
 #endif
 }
diff --git a/tests/CordovaLibTests/CDVStatusBarTests.m 
b/tests/CordovaLibTests/CDVStatusBarTests.m
index 880967c8..1733181e 100644
--- a/tests/CordovaLibTests/CDVStatusBarTests.m
+++ b/tests/CordovaLibTests/CDVStatusBarTests.m
@@ -170,7 +170,7 @@ andWaitForCordovaCommandQueueWithWebViewEngine:self.plugin
     [self evaluateJavaScript:@"window.statusbar.setBackgroundColor('#ffffff');"
 andWaitForCordovaCommandQueueWithWebViewEngine:self.plugin
                      timeout:5];
-    
+
     // Since iOS 18.5, the system automatically determines the status bar 
style based on the background color of the status bar
     // Check this
     if (@available(iOS 18.5, *)) {
@@ -187,4 +187,32 @@ andWaitForCordovaCommandQueueWithWebViewEngine:self.plugin
     XCTAssertEqual(self.viewController.preferredStatusBarStyle, 
UIStatusBarStyleLightContent);
 }
 
+#if !defined(TARGET_OS_VISION) || !TARGET_OS_VISION
+- (void) testStatusBarHidden {
+    XCTestExpectation *loadExpectation = [[XCTNSNotificationExpectation alloc] 
initWithName:CDVTestingDeviceReadyFired];
+    [self.viewController loadStartPage];
+    [self waitForExpectations:@[loadExpectation] timeout:5];
+
+    XCTAssertEqual([self.viewController prefersStatusBarHidden], false);
+
+    [self evaluateJavaScript:@"window.statusbar.visible = false;"
+andWaitForCordovaCommandQueueWithWebViewEngine:self.plugin
+                     timeout:5];
+
+    XCTAssertEqual([self.viewController prefersStatusBarHidden], true);
+}
+
+- (void) testTransparentStatusBarBackgroundIsNotHidden {
+    XCTestExpectation *loadExpectation = [[XCTNSNotificationExpectation alloc] 
initWithName:CDVTestingDeviceReadyFired];
+    [self.viewController loadStartPage];
+    [self waitForExpectations:@[loadExpectation] timeout:5];
+
+    [self 
evaluateJavaScript:@"window.statusbar.setBackgroundColor('transparent');"
+andWaitForCordovaCommandQueueWithWebViewEngine:self.plugin
+                     timeout:5];
+
+    XCTAssertEqual([self.viewController prefersStatusBarHidden], false);
+}
+#endif
+
 @end


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to