diff --git a/status-bar/README.md b/status-bar/README.md
index 63f8b5822..8e7586905 100644
--- a/status-bar/README.md
+++ b/status-bar/README.md
@@ -57,11 +57,11 @@ const showStatusBar = async () => {
These config values are available:
-| Prop | Type | Description | Default | Since |
-| --------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------- | -------------------- | ----- |
-| **`overlaysWebView`** | boolean
| Whether the statusbar is overlaid or not. | true
| 1.0.0 |
-| **`style`** | string
| Style of the text of the status bar. | default
| 1.0.0 |
-| **`backgroundColor`** | string
| Color of the background of the statusbar in hex format, #RRGGBB. Doesn't work if `overlaysWebView` is true. | #000000
| 1.0.0 |
+| Prop | Type | Description | Default | Since |
+| --------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ----- |
+| **`overlaysWebView`** | boolean
| Whether the statusbar is overlaid or not. For applications targeting Android 15, this property has no effect unless the property windowOptOutEdgeToEdgeEnforcement is added to the application layout file. Otherwise, the application assumes always overlays as true. More details in https://developer.android.com/reference/android/R.attr#windowOptOutEdgeToEdgeEnforcement | true
| 1.0.0 |
+| **`style`** | string
| Style of the text of the status bar. | default
| 1.0.0 |
+| **`backgroundColor`** | string
| Color of the background of the statusbar in hex format, #RRGGBB. Doesn't work if `overlaysWebView` is true. | #000000
| 1.0.0 |
### Examples
diff --git a/status-bar/ios/Sources/StatusBarPlugin/CAPBridgeViewController.swift b/status-bar/ios/Sources/StatusBarPlugin/CAPBridgeViewController.swift
index 0786977bf..02cec24dd 100644
--- a/status-bar/ios/Sources/StatusBarPlugin/CAPBridgeViewController.swift
+++ b/status-bar/ios/Sources/StatusBarPlugin/CAPBridgeViewController.swift
@@ -2,12 +2,12 @@ import Capacitor
extension CAPBridgeViewController {
- open override func viewDidAppear(_ animated: Bool) {
+ override open func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
NotificationCenter.default.post(Notification(name: .capacitorViewDidAppear))
}
-
- open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
+
+ override open func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
NotificationCenter.default.post(Notification(name: .capacitorViewWillTransition))
}
diff --git a/status-bar/ios/Sources/StatusBarPlugin/StatusBar.swift b/status-bar/ios/Sources/StatusBarPlugin/StatusBar.swift
index 5d4d0bc0d..0f203f3ad 100644
--- a/status-bar/ios/Sources/StatusBarPlugin/StatusBar.swift
+++ b/status-bar/ios/Sources/StatusBarPlugin/StatusBar.swift
@@ -2,7 +2,7 @@ import Foundation
import Capacitor
public class StatusBar {
-
+
private var bridge: CAPBridgeProtocol
private var isOverlayingWebview = true
private var backgroundColor = UIColor.black
@@ -13,11 +13,11 @@ public class StatusBar {
self.bridge = bridge
setupObservers(with: config)
}
-
+
deinit {
observers.forEach { NotificationCenter.default.removeObserver($0) }
}
-
+
private func setupObservers(with config: StatusBarConfig) {
observers.append(NotificationCenter.default.addObserver(forName: .capacitorViewDidAppear, object: .none, queue: .none) { [weak self] _ in
self?.handleViewDidAppear(config: config)
@@ -29,29 +29,29 @@ public class StatusBar {
self?.handleViewWillTransition()
})
}
-
+
private func handleViewDidAppear(config: StatusBarConfig) {
setStyle(config.style)
setBackgroundColor(config.backgroundColor)
setOverlaysWebView(config.overlaysWebView)
}
-
+
private func handleViewWillTransition() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
self?.resizeStatusBarBackgroundView()
self?.resizeWebView()
}
}
-
+
func setStyle(_ style: UIStatusBarStyle) {
bridge.statusBarStyle = style
}
-
- func setBackgroundColor(_ color : UIColor) {
+
+ func setBackgroundColor(_ color: UIColor) {
backgroundColor = color
backgroundView?.backgroundColor = color
}
-
+
func setAnimation(_ animation: String) {
if animation == "SLIDE" {
bridge.statusBarAnimation = .slide
@@ -110,7 +110,7 @@ public class StatusBar {
height: getStatusBarFrame().size.height
)
}
-
+
func setOverlaysWebView(_ overlay: Bool) {
if overlay == isOverlayingWebview { return }
isOverlayingWebview = overlay
@@ -122,7 +122,7 @@ public class StatusBar {
}
resizeWebView()
}
-
+
private func resizeWebView() {
guard
let webView = bridge.webView,
@@ -130,31 +130,31 @@ public class StatusBar {
else { return }
bridge.viewController?.view.frame = bounds
webView.frame = bounds
- let statusBarHeight = getStatusBarFrame().size.height;
- var webViewFrame = webView.frame;
-
+ let statusBarHeight = getStatusBarFrame().size.height
+ var webViewFrame = webView.frame
+
if isOverlayingWebview {
- let safeAreaTop = webView.safeAreaInsets.top;
- if (statusBarHeight >= safeAreaTop && safeAreaTop > 0) {
+ let safeAreaTop = webView.safeAreaInsets.top
+ if statusBarHeight >= safeAreaTop && safeAreaTop > 0 {
webViewFrame.origin.y = safeAreaTop == 40 ? 20 : statusBarHeight - safeAreaTop
} else {
webViewFrame.origin.y = 0
}
} else {
- webViewFrame.origin.y = statusBarHeight;
+ webViewFrame.origin.y = statusBarHeight
}
webViewFrame.size.height -= webViewFrame.origin.y
webView.frame = webViewFrame
}
-
+
private func resizeStatusBarBackgroundView() {
backgroundView?.frame = getStatusBarFrame()
}
-
+
private func getStatusBarFrame() -> CGRect {
return UIApplication.shared.windows.first(where: { $0.isKeyWindow })?.windowScene?.statusBarManager?.statusBarFrame ?? .zero
}
-
+
private func initializeBackgroundViewIfNeeded() {
if backgroundView == nil {
backgroundView = UIView(frame: getStatusBarFrame())
diff --git a/status-bar/ios/Sources/StatusBarPlugin/StatusBarPlugin.swift b/status-bar/ios/Sources/StatusBarPlugin/StatusBarPlugin.swift
index d43154007..1cadf1dd1 100644
--- a/status-bar/ios/Sources/StatusBarPlugin/StatusBarPlugin.swift
+++ b/status-bar/ios/Sources/StatusBarPlugin/StatusBarPlugin.swift
@@ -15,22 +15,21 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
CAPPluginMethod(name: "show", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "hide", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "getInfo", returnType: CAPPluginReturnPromise),
- CAPPluginMethod(name: "setOverlaysWebView", returnType: CAPPluginReturnPromise),
+ CAPPluginMethod(name: "setOverlaysWebView", returnType: CAPPluginReturnPromise)
]
private var statusBar: StatusBar?
private let statusBarVisibilityChanged = "statusBarVisibilityChanged"
private let statusBarOverlayChanged = "statusBarOverlayChanged"
-
+
override public func load() {
guard let bridge = bridge else { return }
statusBar = StatusBar(bridge: bridge, config: statusBarConfig())
}
-
+
private func statusBarConfig() -> StatusBarConfig {
var config = StatusBarConfig()
config.overlaysWebView = getConfig().getBoolean("overlaysWebView", config.overlaysWebView)
- if let colorConfig = getConfig().getString("backgroundColor"), let color = UIColor.capacitor.color(fromHex: colorConfig)
- {
+ if let colorConfig = getConfig().getString("backgroundColor"), let color = UIColor.capacitor.color(fromHex: colorConfig) {
config.backgroundColor = color
}
if let configStyle = getConfig().getString("style") {
@@ -38,7 +37,7 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
}
return config
}
-
+
private func style(fromString: String) -> UIStatusBarStyle {
switch fromString.lowercased() {
case "dark", "lightcontent":
@@ -70,7 +69,7 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
}
call.resolve()
}
-
+
@objc func hide(_ call: CAPPluginCall) {
let animation = call.getString("animation", "FADE")
DispatchQueue.main.async { [weak self] in
@@ -80,7 +79,7 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
let dict = self?.toDict(info),
let event = self?.statusBarVisibilityChanged
else { return }
- self?.notifyListeners(event, data: dict);
+ self?.notifyListeners(event, data: dict)
}
call.resolve()
}
@@ -94,11 +93,11 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
let dict = self?.toDict(info),
let event = self?.statusBarVisibilityChanged
else { return }
- self?.notifyListeners(event, data: dict);
+ self?.notifyListeners(event, data: dict)
}
call.resolve()
}
-
+
@objc func getInfo(_ call: CAPPluginCall) {
DispatchQueue.main.async { [weak self] in
guard
@@ -118,11 +117,11 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
let dict = self?.toDict(info),
let event = self?.statusBarOverlayChanged
else { return }
- self?.notifyListeners(event, data: dict);
+ self?.notifyListeners(event, data: dict)
}
call.resolve()
}
-
+
private func toDict(_ info: StatusBarInfo) -> [String: Any] {
return [
"visible": info.visible!,
diff --git a/status-bar/ios/Sources/StatusBarPlugin/UIColor.swift b/status-bar/ios/Sources/StatusBarPlugin/UIColor.swift
index 584afcc4f..2b509a0b4 100644
--- a/status-bar/ios/Sources/StatusBarPlugin/UIColor.swift
+++ b/status-bar/ios/Sources/StatusBarPlugin/UIColor.swift
@@ -1,7 +1,7 @@
import Capacitor
public extension CapacitorExtensionTypeWrapper where T: UIColor {
-
+
static func hex(fromColor: UIColor) -> String? {
var red: CGFloat = 0
var green: CGFloat = 0
diff --git a/status-bar/src/definitions.ts b/status-bar/src/definitions.ts
index 9e18cb5b5..7112a4532 100644
--- a/status-bar/src/definitions.ts
+++ b/status-bar/src/definitions.ts
@@ -8,6 +8,10 @@ declare module '@capacitor/cli' {
StatusBar?: {
/**
* Whether the statusbar is overlaid or not.
+ * For applications targeting Android 15, this property has no effect unless
+ * the property windowOptOutEdgeToEdgeEnforcement is added to the application layout file.
+ * Otherwise, the application assumes always overlays as true.
+ * More details in https://developer.android.com/reference/android/R.attr#windowOptOutEdgeToEdgeEnforcement
*
* @since 1.0.0
* @default true