Skip to content

[Bug]: status bar is gone after the camera is dismissed (iOS only) #2310 #2347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions status-bar/ios/Sources/StatusBarPlugin/StatusBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import Capacitor
public class StatusBar {

private var bridge: CAPBridgeProtocol
private var isOverlayingWebview = true
private var backgroundColor = UIColor.black
private var isOverlayingWebview: Bool!
private var backgroundColor: UIColor!
private var style: UIStatusBarStyle!
private var backgroundView: UIView?
private var observers: [NSObjectProtocol] = []

Expand All @@ -31,9 +32,9 @@ public class StatusBar {
}

private func handleViewDidAppear(config: StatusBarConfig) {
setStyle(config.style)
setBackgroundColor(config.backgroundColor)
setOverlaysWebView(config.overlaysWebView)
setStyle(self.style ?? config.style)
setBackgroundColor(self.backgroundColor ?? config.backgroundColor)
setOverlaysWebView(self.isOverlayingWebview ?? config.overlaysWebView)
}

private func handleViewWillTransition() {
Expand All @@ -44,12 +45,13 @@ public class StatusBar {
}

func setStyle(_ style: UIStatusBarStyle) {
bridge.statusBarStyle = style
self.style = style
bridge.statusBarStyle = self.style
}

func setBackgroundColor(_ color: UIColor) {
backgroundColor = color
backgroundView?.backgroundColor = color
self.backgroundColor = color
backgroundView?.backgroundColor = self.backgroundColor
}

func setAnimation(_ animation: String) {
Expand Down Expand Up @@ -112,7 +114,10 @@ public class StatusBar {
}

func setOverlaysWebView(_ overlay: Bool) {
if overlay == isOverlayingWebview { return }
if overlay == isOverlayingWebview {
resizeWebView()
return
}
isOverlayingWebview = overlay
if overlay {
backgroundView?.removeFromSuperview()
Expand Down