Skip to content
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