@capacitor/status-bar 7.0.0-nightly-20241105T150527.0 → 7.0.0-nightly-20241107T150511.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/docs.json +1 -1
- package/dist/esm/definitions.d.ts +4 -0
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/StatusBarPlugin/CAPBridgeViewController.swift +3 -3
- package/ios/Sources/StatusBarPlugin/StatusBar.swift +20 -20
- package/ios/Sources/StatusBarPlugin/StatusBarPlugin.swift +11 -12
- package/ios/Sources/StatusBarPlugin/UIColor.swift +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -57,11 +57,11 @@ const showStatusBar = async () => {
|
|
|
57
57
|
|
|
58
58
|
These config values are available:
|
|
59
59
|
|
|
60
|
-
| Prop | Type | Description
|
|
61
|
-
| --------------------- | -------------------- |
|
|
62
|
-
| **`overlaysWebView`** | <code>boolean</code> | Whether the statusbar is overlaid or not.
|
|
63
|
-
| **`style`** | <code>string</code> | <a href="#style">Style</a> of the text of the status bar.
|
|
64
|
-
| **`backgroundColor`** | <code>string</code> | Color of the background of the statusbar in hex format, #RRGGBB. Doesn't work if `overlaysWebView` is true.
|
|
60
|
+
| Prop | Type | Description | Default | Since |
|
|
61
|
+
| --------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ----- |
|
|
62
|
+
| **`overlaysWebView`** | <code>boolean</code> | 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 | <code>true</code> | 1.0.0 |
|
|
63
|
+
| **`style`** | <code>string</code> | <a href="#style">Style</a> of the text of the status bar. | <code>default</code> | 1.0.0 |
|
|
64
|
+
| **`backgroundColor`** | <code>string</code> | Color of the background of the statusbar in hex format, #RRGGBB. Doesn't work if `overlaysWebView` is true. | <code>#000000</code> | 1.0.0 |
|
|
65
65
|
|
|
66
66
|
### Examples
|
|
67
67
|
|
package/dist/docs.json
CHANGED
|
@@ -399,7 +399,7 @@
|
|
|
399
399
|
"name": "example"
|
|
400
400
|
}
|
|
401
401
|
],
|
|
402
|
-
"docs": "Whether the statusbar is overlaid or not.",
|
|
402
|
+
"docs": "Whether the statusbar is overlaid or not.\nFor applications targeting Android 15, this property has no effect unless\nthe property windowOptOutEdgeToEdgeEnforcement is added to the application layout file.\nOtherwise, the application assumes always overlays as true.\nMore details in https://developer.android.com/reference/android/R.attr#windowOptOutEdgeToEdgeEnforcement",
|
|
403
403
|
"complexTypes": [],
|
|
404
404
|
"type": "boolean | undefined"
|
|
405
405
|
},
|
|
@@ -6,6 +6,10 @@ declare module '@capacitor/cli' {
|
|
|
6
6
|
StatusBar?: {
|
|
7
7
|
/**
|
|
8
8
|
* Whether the statusbar is overlaid or not.
|
|
9
|
+
* For applications targeting Android 15, this property has no effect unless
|
|
10
|
+
* the property windowOptOutEdgeToEdgeEnforcement is added to the application layout file.
|
|
11
|
+
* Otherwise, the application assumes always overlays as true.
|
|
12
|
+
* More details in https://developer.android.com/reference/android/R.attr#windowOptOutEdgeToEdgeEnforcement
|
|
9
13
|
*
|
|
10
14
|
* @since 1.0.0
|
|
11
15
|
* @default true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC;
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAoDxC,MAAM,CAAN,IAAY,KAwBX;AAxBD,WAAY,KAAK;IACf;;;;OAIG;IACH,sBAAa,CAAA;IAEb;;;;OAIG;IACH,wBAAe,CAAA;IAEf;;;;;;;OAOG;IACH,4BAAmB,CAAA;AACrB,CAAC,EAxBW,KAAK,KAAL,KAAK,QAwBhB;AAeD,MAAM,CAAN,IAAY,SAwBX;AAxBD,WAAY,SAAS;IACnB;;;;OAIG;IACH,0BAAa,CAAA;IAEb;;;;;;;OAOG;IACH,4BAAe,CAAA;IAEf;;;;OAIG;IACH,0BAAa,CAAA;AACf,CAAC,EAxBW,SAAS,KAAT,SAAS,QAwBpB;AAiID;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * These config values are available:\n */\n StatusBar?: {\n /**\n * Whether the statusbar is overlaid or not.\n * For applications targeting Android 15, this property has no effect unless\n * the property windowOptOutEdgeToEdgeEnforcement is added to the application layout file.\n * Otherwise, the application assumes always overlays as true.\n * More details in https://developer.android.com/reference/android/R.attr#windowOptOutEdgeToEdgeEnforcement\n *\n * @since 1.0.0\n * @default true\n * @example false\n */\n overlaysWebView?: boolean;\n\n /**\n * Style of the text of the status bar.\n *\n * @since 1.0.0\n * @default default\n * @example \"DARK\"\n */\n style?: string;\n\n /**\n * Color of the background of the statusbar in hex format, #RRGGBB.\n * Doesn't work if `overlaysWebView` is true.\n *\n * @since 1.0.0\n * @default #000000\n * @example \"#ffffffff\"\n */\n backgroundColor?: string;\n };\n }\n}\n\nexport interface StyleOptions {\n /**\n * Style of the text of the status bar.\n *\n * @since 1.0.0\n */\n style: Style;\n}\n\nexport enum Style {\n /**\n * Light text for dark backgrounds.\n *\n * @since 1.0.0\n */\n Dark = 'DARK',\n\n /**\n * Dark text for light backgrounds.\n *\n * @since 1.0.0\n */\n Light = 'LIGHT',\n\n /**\n * The style is based on the device appearance.\n * If the device is using Dark mode, the statusbar text will be light.\n * If the device is using Light mode, the statusbar text will be dark.\n * On Android the default will be the one the app was launched with.\n *\n * @since 1.0.0\n */\n Default = 'DEFAULT',\n}\n\nexport interface AnimationOptions {\n /**\n * The type of status bar animation used when showing or hiding.\n *\n * This option is only supported on iOS.\n *\n * @default Animation.Fade\n *\n * @since 1.0.0\n */\n animation: Animation;\n}\n\nexport enum Animation {\n /**\n * No animation during show/hide.\n *\n * @since 1.0.0\n */\n None = 'NONE',\n\n /**\n * Slide animation during show/hide.\n * It doesn't work on iOS 15+.\n *\n * @deprecated Use Animation.Fade or Animation.None instead.\n *\n * @since 1.0.0\n */\n Slide = 'SLIDE',\n\n /**\n * Fade animation during show/hide.\n *\n * @since 1.0.0\n */\n Fade = 'FADE',\n}\n\nexport interface BackgroundColorOptions {\n /**\n * A hex color to which the status bar color is set.\n *\n * @since 1.0.0\n */\n color: string;\n}\n\nexport interface StatusBarInfo {\n /**\n * Whether the status bar is visible or not.\n *\n * @since 1.0.0\n */\n visible: boolean;\n\n /**\n * The current status bar style.\n *\n * @since 1.0.0\n */\n style: Style;\n\n /**\n * The current status bar color.\n *\n * @since 1.0.0\n */\n color?: string;\n\n /**\n * Whether the statusbar is overlaid or not.\n *\n * @since 1.0.0\n */\n overlays?: boolean;\n}\n\nexport interface SetOverlaysWebViewOptions {\n /**\n * Whether to overlay the status bar or not.\n *\n * @since 1.0.0\n */\n overlay: boolean;\n}\n\nexport interface StatusBarPlugin {\n /**\n * Set the current style of the status bar.\n *\n * @since 1.0.0\n */\n setStyle(options: StyleOptions): Promise<void>;\n\n /**\n * Set the background color of the status bar.\n *\n * @since 1.0.0\n */\n setBackgroundColor(options: BackgroundColorOptions): Promise<void>;\n\n /**\n * Show the status bar.\n * On iOS, if the status bar is initially hidden and the initial style is set to\n * `UIStatusBarStyleLightContent`, first show call might present a glitch on the\n * animation showing the text as dark and then transition to light. It's recommended\n * to use `Animation.None` as the animation on the first call.\n *\n * @since 1.0.0\n */\n show(options?: AnimationOptions): Promise<void>;\n\n /**\n * Hide the status bar.\n *\n * @since 1.0.0\n */\n hide(options?: AnimationOptions): Promise<void>;\n\n /**\n * Get info about the current state of the status bar.\n *\n * @since 1.0.0\n */\n getInfo(): Promise<StatusBarInfo>;\n\n /**\n * Set whether or not the status bar should overlay the webview to allow usage\n * of the space underneath it.\n *\n * @since 1.0.0\n */\n setOverlaysWebView(options: SetOverlaysWebViewOptions): Promise<void>;\n}\n\n/**\n * @deprecated Use `StyleOptions`.\n * @since 1.0.0\n */\nexport type StatusBarStyleOptions = StyleOptions;\n\n/**\n * @deprecated Use `BackgroundColorOptions`.\n * @since 1.0.0\n */\nexport type StatusBarBackgroundColorOptions = BackgroundColorOptions;\n\n/**\n * @deprecated Use `SetOverlaysWebViewOptions`.\n * @since 1.0.0\n */\nexport type StatusBarOverlaysWebviewOptions = SetOverlaysWebViewOptions;\n\n/**\n * @deprecated Use `StatusBarInfo`.\n * @since 1.0.0\n */\nexport type StatusBarInfoResult = StatusBarInfo;\n\n/**\n * @deprecated Use `AnimationOptions`.\n * @since 1.0.0\n */\nexport type StatusBarAnimationOptions = AnimationOptions;\n\n/**\n * @deprecated Use `Animation`.\n * @since 1.0.0\n */\nexport const StatusBarAnimation = Animation;\n\n/**\n * @deprecated Use `Style`.\n * @since 1.0.0\n */\nexport const StatusBarStyle = Style;\n"]}
|
|
@@ -2,12 +2,12 @@ import Capacitor
|
|
|
2
2
|
|
|
3
3
|
extension CAPBridgeViewController {
|
|
4
4
|
|
|
5
|
-
open
|
|
5
|
+
override open func viewDidAppear(_ animated: Bool) {
|
|
6
6
|
super.viewDidAppear(animated)
|
|
7
7
|
NotificationCenter.default.post(Notification(name: .capacitorViewDidAppear))
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
open
|
|
9
|
+
|
|
10
|
+
override open func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
|
11
11
|
super.viewWillTransition(to: size, with: coordinator)
|
|
12
12
|
NotificationCenter.default.post(Notification(name: .capacitorViewWillTransition))
|
|
13
13
|
}
|
|
@@ -2,7 +2,7 @@ import Foundation
|
|
|
2
2
|
import Capacitor
|
|
3
3
|
|
|
4
4
|
public class StatusBar {
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
private var bridge: CAPBridgeProtocol
|
|
7
7
|
private var isOverlayingWebview = true
|
|
8
8
|
private var backgroundColor = UIColor.black
|
|
@@ -13,11 +13,11 @@ public class StatusBar {
|
|
|
13
13
|
self.bridge = bridge
|
|
14
14
|
setupObservers(with: config)
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
deinit {
|
|
18
18
|
observers.forEach { NotificationCenter.default.removeObserver($0) }
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
private func setupObservers(with config: StatusBarConfig) {
|
|
22
22
|
observers.append(NotificationCenter.default.addObserver(forName: .capacitorViewDidAppear, object: .none, queue: .none) { [weak self] _ in
|
|
23
23
|
self?.handleViewDidAppear(config: config)
|
|
@@ -29,29 +29,29 @@ public class StatusBar {
|
|
|
29
29
|
self?.handleViewWillTransition()
|
|
30
30
|
})
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
private func handleViewDidAppear(config: StatusBarConfig) {
|
|
34
34
|
setStyle(config.style)
|
|
35
35
|
setBackgroundColor(config.backgroundColor)
|
|
36
36
|
setOverlaysWebView(config.overlaysWebView)
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
private func handleViewWillTransition() {
|
|
40
40
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
|
|
41
41
|
self?.resizeStatusBarBackgroundView()
|
|
42
42
|
self?.resizeWebView()
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
func setStyle(_ style: UIStatusBarStyle) {
|
|
47
47
|
bridge.statusBarStyle = style
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
func setBackgroundColor(_ color
|
|
49
|
+
|
|
50
|
+
func setBackgroundColor(_ color: UIColor) {
|
|
51
51
|
backgroundColor = color
|
|
52
52
|
backgroundView?.backgroundColor = color
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
func setAnimation(_ animation: String) {
|
|
56
56
|
if animation == "SLIDE" {
|
|
57
57
|
bridge.statusBarAnimation = .slide
|
|
@@ -110,7 +110,7 @@ public class StatusBar {
|
|
|
110
110
|
height: getStatusBarFrame().size.height
|
|
111
111
|
)
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
func setOverlaysWebView(_ overlay: Bool) {
|
|
115
115
|
if overlay == isOverlayingWebview { return }
|
|
116
116
|
isOverlayingWebview = overlay
|
|
@@ -122,7 +122,7 @@ public class StatusBar {
|
|
|
122
122
|
}
|
|
123
123
|
resizeWebView()
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
private func resizeWebView() {
|
|
127
127
|
guard
|
|
128
128
|
let webView = bridge.webView,
|
|
@@ -130,31 +130,31 @@ public class StatusBar {
|
|
|
130
130
|
else { return }
|
|
131
131
|
bridge.viewController?.view.frame = bounds
|
|
132
132
|
webView.frame = bounds
|
|
133
|
-
let statusBarHeight = getStatusBarFrame().size.height
|
|
134
|
-
var webViewFrame = webView.frame
|
|
135
|
-
|
|
133
|
+
let statusBarHeight = getStatusBarFrame().size.height
|
|
134
|
+
var webViewFrame = webView.frame
|
|
135
|
+
|
|
136
136
|
if isOverlayingWebview {
|
|
137
|
-
let safeAreaTop = webView.safeAreaInsets.top
|
|
138
|
-
if
|
|
137
|
+
let safeAreaTop = webView.safeAreaInsets.top
|
|
138
|
+
if statusBarHeight >= safeAreaTop && safeAreaTop > 0 {
|
|
139
139
|
webViewFrame.origin.y = safeAreaTop == 40 ? 20 : statusBarHeight - safeAreaTop
|
|
140
140
|
} else {
|
|
141
141
|
webViewFrame.origin.y = 0
|
|
142
142
|
}
|
|
143
143
|
} else {
|
|
144
|
-
webViewFrame.origin.y = statusBarHeight
|
|
144
|
+
webViewFrame.origin.y = statusBarHeight
|
|
145
145
|
}
|
|
146
146
|
webViewFrame.size.height -= webViewFrame.origin.y
|
|
147
147
|
webView.frame = webViewFrame
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
|
|
150
150
|
private func resizeStatusBarBackgroundView() {
|
|
151
151
|
backgroundView?.frame = getStatusBarFrame()
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
private func getStatusBarFrame() -> CGRect {
|
|
155
155
|
return UIApplication.shared.windows.first(where: { $0.isKeyWindow })?.windowScene?.statusBarManager?.statusBarFrame ?? .zero
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
private func initializeBackgroundViewIfNeeded() {
|
|
159
159
|
if backgroundView == nil {
|
|
160
160
|
backgroundView = UIView(frame: getStatusBarFrame())
|
|
@@ -15,22 +15,21 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
15
15
|
CAPPluginMethod(name: "show", returnType: CAPPluginReturnPromise),
|
|
16
16
|
CAPPluginMethod(name: "hide", returnType: CAPPluginReturnPromise),
|
|
17
17
|
CAPPluginMethod(name: "getInfo", returnType: CAPPluginReturnPromise),
|
|
18
|
-
CAPPluginMethod(name: "setOverlaysWebView", returnType: CAPPluginReturnPromise)
|
|
18
|
+
CAPPluginMethod(name: "setOverlaysWebView", returnType: CAPPluginReturnPromise)
|
|
19
19
|
]
|
|
20
20
|
private var statusBar: StatusBar?
|
|
21
21
|
private let statusBarVisibilityChanged = "statusBarVisibilityChanged"
|
|
22
22
|
private let statusBarOverlayChanged = "statusBarOverlayChanged"
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
override public func load() {
|
|
25
25
|
guard let bridge = bridge else { return }
|
|
26
26
|
statusBar = StatusBar(bridge: bridge, config: statusBarConfig())
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
private func statusBarConfig() -> StatusBarConfig {
|
|
30
30
|
var config = StatusBarConfig()
|
|
31
31
|
config.overlaysWebView = getConfig().getBoolean("overlaysWebView", config.overlaysWebView)
|
|
32
|
-
if let colorConfig = getConfig().getString("backgroundColor"), let color = UIColor.capacitor.color(fromHex: colorConfig)
|
|
33
|
-
{
|
|
32
|
+
if let colorConfig = getConfig().getString("backgroundColor"), let color = UIColor.capacitor.color(fromHex: colorConfig) {
|
|
34
33
|
config.backgroundColor = color
|
|
35
34
|
}
|
|
36
35
|
if let configStyle = getConfig().getString("style") {
|
|
@@ -38,7 +37,7 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
38
37
|
}
|
|
39
38
|
return config
|
|
40
39
|
}
|
|
41
|
-
|
|
40
|
+
|
|
42
41
|
private func style(fromString: String) -> UIStatusBarStyle {
|
|
43
42
|
switch fromString.lowercased() {
|
|
44
43
|
case "dark", "lightcontent":
|
|
@@ -70,7 +69,7 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
70
69
|
}
|
|
71
70
|
call.resolve()
|
|
72
71
|
}
|
|
73
|
-
|
|
72
|
+
|
|
74
73
|
@objc func hide(_ call: CAPPluginCall) {
|
|
75
74
|
let animation = call.getString("animation", "FADE")
|
|
76
75
|
DispatchQueue.main.async { [weak self] in
|
|
@@ -80,7 +79,7 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
80
79
|
let dict = self?.toDict(info),
|
|
81
80
|
let event = self?.statusBarVisibilityChanged
|
|
82
81
|
else { return }
|
|
83
|
-
self?.notifyListeners(event, data: dict)
|
|
82
|
+
self?.notifyListeners(event, data: dict)
|
|
84
83
|
}
|
|
85
84
|
call.resolve()
|
|
86
85
|
}
|
|
@@ -94,11 +93,11 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
94
93
|
let dict = self?.toDict(info),
|
|
95
94
|
let event = self?.statusBarVisibilityChanged
|
|
96
95
|
else { return }
|
|
97
|
-
self?.notifyListeners(event, data: dict)
|
|
96
|
+
self?.notifyListeners(event, data: dict)
|
|
98
97
|
}
|
|
99
98
|
call.resolve()
|
|
100
99
|
}
|
|
101
|
-
|
|
100
|
+
|
|
102
101
|
@objc func getInfo(_ call: CAPPluginCall) {
|
|
103
102
|
DispatchQueue.main.async { [weak self] in
|
|
104
103
|
guard
|
|
@@ -118,11 +117,11 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
118
117
|
let dict = self?.toDict(info),
|
|
119
118
|
let event = self?.statusBarOverlayChanged
|
|
120
119
|
else { return }
|
|
121
|
-
self?.notifyListeners(event, data: dict)
|
|
120
|
+
self?.notifyListeners(event, data: dict)
|
|
122
121
|
}
|
|
123
122
|
call.resolve()
|
|
124
123
|
}
|
|
125
|
-
|
|
124
|
+
|
|
126
125
|
private func toDict(_ info: StatusBarInfo) -> [String: Any] {
|
|
127
126
|
return [
|
|
128
127
|
"visible": info.visible!,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/status-bar",
|
|
3
|
-
"version": "7.0.0-nightly-
|
|
3
|
+
"version": "7.0.0-nightly-20241107T150511.0",
|
|
4
4
|
"description": "The StatusBar API Provides methods for configuring the style of the Status Bar, along with showing or hiding it.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "e12dd0f0969700709258d775a1fe52dce4d5a122"
|
|
85
85
|
}
|