capacitor-plugin-status-bar 2.0.4 → 2.0.6
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 +42 -0
- package/android/src/main/java/com/cap/plugins/statusbar/CapacitorStatusBar.java +102 -0
- package/android/src/main/java/com/cap/plugins/statusbar/CapacitorStatusBarPlugin.java +48 -0
- package/dist/docs.json +78 -0
- package/dist/esm/definitions.d.ts +23 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -1
- package/dist/esm/web.js +6 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +6 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +6 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapacitorStatusBarPlugin/CapacitorStatusBar.swift +82 -2
- package/ios/Sources/CapacitorStatusBarPlugin/CapacitorStatusBarPlugin.swift +17 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,8 @@ No additional configuration required. The plugin works out of the box on Android
|
|
|
38
38
|
* [`hide(...)`](#hide)
|
|
39
39
|
* [`setOverlaysWebView(...)`](#setoverlayswebview)
|
|
40
40
|
* [`setBackground(...)`](#setbackground)
|
|
41
|
+
* [`showNavigationBar(...)`](#shownavigationbar)
|
|
42
|
+
* [`hideNavigationBar(...)`](#hidenavigationbar)
|
|
41
43
|
* [`getSafeAreaInsets()`](#getsafeareainsets)
|
|
42
44
|
* [Type Aliases](#type-aliases)
|
|
43
45
|
* [Enums](#enums)
|
|
@@ -129,6 +131,36 @@ Set the window background color.
|
|
|
129
131
|
--------------------
|
|
130
132
|
|
|
131
133
|
|
|
134
|
+
### showNavigationBar(...)
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
showNavigationBar(options: NavigationBarShowOptions) => Promise<void>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Show the navigation bar.
|
|
141
|
+
|
|
142
|
+
| Param | Type | Description |
|
|
143
|
+
| ------------- | ----------------------------------------------------------------------------- | ----------------------------------------- |
|
|
144
|
+
| **`options`** | <code><a href="#navigationbarshowoptions">NavigationBarShowOptions</a></code> | - The options to show the navigation bar. |
|
|
145
|
+
|
|
146
|
+
--------------------
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
### hideNavigationBar(...)
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
hideNavigationBar(options: NavigationBarHideOptions) => Promise<void>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Hide the navigation bar.
|
|
156
|
+
|
|
157
|
+
| Param | Type | Description |
|
|
158
|
+
| ------------- | ----------------------------------------------------------------------------- | ----------------------------------------- |
|
|
159
|
+
| **`options`** | <code><a href="#navigationbarhideoptions">NavigationBarHideOptions</a></code> | - The options to hide the navigation bar. |
|
|
160
|
+
|
|
161
|
+
--------------------
|
|
162
|
+
|
|
163
|
+
|
|
132
164
|
### getSafeAreaInsets()
|
|
133
165
|
|
|
134
166
|
```typescript
|
|
@@ -193,6 +225,16 @@ Note: Short 3-digit format (#FFF) is NOT supported.
|
|
|
193
225
|
<code>{ color: <a href="#statusbarcolor">StatusBarColor</a>; }</code>
|
|
194
226
|
|
|
195
227
|
|
|
228
|
+
#### NavigationBarShowOptions
|
|
229
|
+
|
|
230
|
+
<code>{ animated: boolean; }</code>
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
#### NavigationBarHideOptions
|
|
234
|
+
|
|
235
|
+
<code>{ /** * The animation type for hiding the navigation bar. * - 'fade': Makes the background transparent without removing the navigation bar. * - 'slide': Hides the navigation bar completely (default behavior). */ animation: <a href="#statusbaranimation">StatusBarAnimation</a>; }</code>
|
|
236
|
+
|
|
237
|
+
|
|
196
238
|
#### SafeAreaInsets
|
|
197
239
|
|
|
198
240
|
<code>{ top: number; bottom: number; left: number; right: number; }</code>
|
|
@@ -328,6 +328,108 @@ public class CapacitorStatusBar extends Plugin {
|
|
|
328
328
|
return insets;
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
+
public void showNavigationBar(Activity activity, boolean animated) {
|
|
332
|
+
Log.d(TAG, "showNavigationBar: animated=" + animated + ", API=" + Build.VERSION.SDK_INT);
|
|
333
|
+
Window window = activity.getWindow();
|
|
334
|
+
View decorView = window.getDecorView();
|
|
335
|
+
|
|
336
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
337
|
+
WindowInsetsController controller = window.getInsetsController();
|
|
338
|
+
if (controller != null) {
|
|
339
|
+
Log.d(TAG, "showNavigationBar: showing navigation bar (API 30+)");
|
|
340
|
+
controller.show(WindowInsets.Type.navigationBars());
|
|
341
|
+
controller.setSystemBarsBehavior(
|
|
342
|
+
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
|
343
|
+
} else {
|
|
344
|
+
Log.w(TAG, "showNavigationBar: WindowInsetsController is null");
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
Log.d(TAG, "showNavigationBar: showing using system UI flags (API 29)");
|
|
348
|
+
int flags = decorView.getSystemUiVisibility();
|
|
349
|
+
flags &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
|
350
|
+
flags &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
|
351
|
+
decorView.setSystemUiVisibility(flags);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Restore navigation bar background color
|
|
355
|
+
applyNavigationBarBackground(activity, currentNavBarColor);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
public void hideNavigationBar(Activity activity, String animation) {
|
|
359
|
+
Log.d(TAG, "hideNavigationBar: animation=" + animation + ", API=" + Build.VERSION.SDK_INT);
|
|
360
|
+
Window window = activity.getWindow();
|
|
361
|
+
View decorView = window.getDecorView();
|
|
362
|
+
|
|
363
|
+
String animationType = animation != null ? animation.toLowerCase() : "slide";
|
|
364
|
+
|
|
365
|
+
if ("fade".equals(animationType)) {
|
|
366
|
+
Log.d(TAG, "hideNavigationBar: fade mode - hiding navigation bar with transparent background");
|
|
367
|
+
|
|
368
|
+
// Hide the navigation bar icons
|
|
369
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
370
|
+
WindowInsetsController controller = window.getInsetsController();
|
|
371
|
+
if (controller != null) {
|
|
372
|
+
controller.hide(WindowInsets.Type.navigationBars());
|
|
373
|
+
controller.setSystemBarsBehavior(
|
|
374
|
+
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
|
375
|
+
}
|
|
376
|
+
} else {
|
|
377
|
+
decorView.setSystemUiVisibility(
|
|
378
|
+
decorView.getSystemUiVisibility()
|
|
379
|
+
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
|
380
|
+
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
|
381
|
+
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
382
|
+
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// Make background transparent
|
|
386
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
|
387
|
+
ViewGroup dv = (ViewGroup) decorView;
|
|
388
|
+
View navOverlay = dv.findViewWithTag(NAV_BAR_OVERLAY_TAG);
|
|
389
|
+
if (navOverlay != null) {
|
|
390
|
+
navOverlay.setBackgroundColor(Color.TRANSPARENT);
|
|
391
|
+
}
|
|
392
|
+
} else {
|
|
393
|
+
window.setNavigationBarColor(Color.TRANSPARENT);
|
|
394
|
+
}
|
|
395
|
+
} else if ("slide".equals(animationType)) {
|
|
396
|
+
Log.d(TAG, "hideNavigationBar: slide mode - hiding navigation bar completely");
|
|
397
|
+
|
|
398
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
399
|
+
WindowInsetsController controller = window.getInsetsController();
|
|
400
|
+
if (controller != null) {
|
|
401
|
+
controller.hide(WindowInsets.Type.navigationBars());
|
|
402
|
+
controller.setSystemBarsBehavior(
|
|
403
|
+
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
|
404
|
+
} else {
|
|
405
|
+
Log.w(TAG, "hideNavigationBar: WindowInsetsController is null");
|
|
406
|
+
}
|
|
407
|
+
} else {
|
|
408
|
+
Log.d(TAG, "hideNavigationBar: hiding using system UI flags (API 29)");
|
|
409
|
+
decorView.setSystemUiVisibility(
|
|
410
|
+
decorView.getSystemUiVisibility()
|
|
411
|
+
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
|
412
|
+
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
|
413
|
+
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
414
|
+
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Make navigation bar overlay transparent
|
|
418
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
|
419
|
+
ViewGroup dv = (ViewGroup) decorView;
|
|
420
|
+
View navOverlay = dv.findViewWithTag(NAV_BAR_OVERLAY_TAG);
|
|
421
|
+
if (navOverlay != null) {
|
|
422
|
+
navOverlay.setBackgroundColor(Color.TRANSPARENT);
|
|
423
|
+
}
|
|
424
|
+
} else {
|
|
425
|
+
window.setNavigationBarColor(Color.TRANSPARENT);
|
|
426
|
+
}
|
|
427
|
+
} else {
|
|
428
|
+
Log.w(TAG, "hideNavigationBar: unknown animation type '" + animationType + "', defaulting to slide");
|
|
429
|
+
hideNavigationBar(activity, "slide");
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
331
433
|
/**
|
|
332
434
|
* Reapply the current style and colors after showing bars.
|
|
333
435
|
* This ensures colors are preserved when hiding and then showing.
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
package com.cap.plugins.statusbar;
|
|
2
2
|
|
|
3
|
+
import android.os.Build;
|
|
4
|
+
import android.view.View;
|
|
5
|
+
|
|
6
|
+
import androidx.core.graphics.Insets;
|
|
7
|
+
import androidx.core.view.ViewCompat;
|
|
8
|
+
import androidx.core.view.WindowInsetsCompat;
|
|
9
|
+
|
|
3
10
|
import com.getcapacitor.Plugin;
|
|
4
11
|
import com.getcapacitor.PluginCall;
|
|
5
12
|
import com.getcapacitor.PluginMethod;
|
|
@@ -16,6 +23,17 @@ public class CapacitorStatusBarPlugin extends Plugin {
|
|
|
16
23
|
getActivity().runOnUiThread(() -> {
|
|
17
24
|
implementation.ensureEdgeToEdgeConfigured(getActivity());
|
|
18
25
|
implementation.applyDefaultStyle(getActivity());
|
|
26
|
+
|
|
27
|
+
// On Android 15+ (API 35+), edge-to-edge is enforced and the WebView content
|
|
28
|
+
// extends under system bars. Apply padding so Ionic content stays in the safe area.
|
|
29
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
|
30
|
+
View webView = getBridge().getWebView();
|
|
31
|
+
ViewCompat.setOnApplyWindowInsetsListener(webView, (v, insets) -> {
|
|
32
|
+
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
|
33
|
+
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
|
34
|
+
return insets;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
19
37
|
});
|
|
20
38
|
}
|
|
21
39
|
|
|
@@ -101,6 +119,36 @@ public class CapacitorStatusBarPlugin extends Plugin {
|
|
|
101
119
|
}
|
|
102
120
|
}
|
|
103
121
|
|
|
122
|
+
@PluginMethod
|
|
123
|
+
public void showNavigationBar(PluginCall call) {
|
|
124
|
+
try {
|
|
125
|
+
boolean animated = Boolean.TRUE.equals(call.getBoolean("animated", true));
|
|
126
|
+
getActivity().runOnUiThread(() -> {
|
|
127
|
+
implementation.showNavigationBar(getActivity(), animated);
|
|
128
|
+
call.resolve();
|
|
129
|
+
});
|
|
130
|
+
} catch (Exception e) {
|
|
131
|
+
call.reject(e.getMessage());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@PluginMethod
|
|
136
|
+
public void hideNavigationBar(PluginCall call) {
|
|
137
|
+
try {
|
|
138
|
+
String animation = call.getString("animation");
|
|
139
|
+
if (animation == null) {
|
|
140
|
+
call.reject("animation is required");
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
getActivity().runOnUiThread(() -> {
|
|
144
|
+
implementation.hideNavigationBar(getActivity(), animation);
|
|
145
|
+
call.resolve();
|
|
146
|
+
});
|
|
147
|
+
} catch (Exception e) {
|
|
148
|
+
call.reject(e.getMessage());
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
104
152
|
@PluginMethod
|
|
105
153
|
public void getSafeAreaInsets(PluginCall call) {
|
|
106
154
|
try {
|
package/dist/docs.json
CHANGED
|
@@ -144,6 +144,60 @@
|
|
|
144
144
|
],
|
|
145
145
|
"slug": "setbackground"
|
|
146
146
|
},
|
|
147
|
+
{
|
|
148
|
+
"name": "showNavigationBar",
|
|
149
|
+
"signature": "(options: NavigationBarShowOptions) => Promise<void>",
|
|
150
|
+
"parameters": [
|
|
151
|
+
{
|
|
152
|
+
"name": "options",
|
|
153
|
+
"docs": "- The options to show the navigation bar.",
|
|
154
|
+
"type": "NavigationBarShowOptions"
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"returns": "Promise<void>",
|
|
158
|
+
"tags": [
|
|
159
|
+
{
|
|
160
|
+
"name": "param",
|
|
161
|
+
"text": "options - The options to show the navigation bar."
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "param",
|
|
165
|
+
"text": "options.animated - Whether to animate the navigation bar."
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
"docs": "Show the navigation bar.",
|
|
169
|
+
"complexTypes": [
|
|
170
|
+
"NavigationBarShowOptions"
|
|
171
|
+
],
|
|
172
|
+
"slug": "shownavigationbar"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"name": "hideNavigationBar",
|
|
176
|
+
"signature": "(options: NavigationBarHideOptions) => Promise<void>",
|
|
177
|
+
"parameters": [
|
|
178
|
+
{
|
|
179
|
+
"name": "options",
|
|
180
|
+
"docs": "- The options to hide the navigation bar.",
|
|
181
|
+
"type": "NavigationBarHideOptions"
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
"returns": "Promise<void>",
|
|
185
|
+
"tags": [
|
|
186
|
+
{
|
|
187
|
+
"name": "param",
|
|
188
|
+
"text": "options - The options to hide the navigation bar."
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"name": "param",
|
|
192
|
+
"text": "options.animation - The animation type: 'fade' makes background transparent, 'slide' hides bar completely."
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"docs": "Hide the navigation bar.",
|
|
196
|
+
"complexTypes": [
|
|
197
|
+
"NavigationBarHideOptions"
|
|
198
|
+
],
|
|
199
|
+
"slug": "hidenavigationbar"
|
|
200
|
+
},
|
|
147
201
|
{
|
|
148
202
|
"name": "getSafeAreaInsets",
|
|
149
203
|
"signature": "() => Promise<SafeAreaInsets>",
|
|
@@ -316,6 +370,30 @@
|
|
|
316
370
|
}
|
|
317
371
|
]
|
|
318
372
|
},
|
|
373
|
+
{
|
|
374
|
+
"name": "NavigationBarShowOptions",
|
|
375
|
+
"slug": "navigationbarshowoptions",
|
|
376
|
+
"docs": "",
|
|
377
|
+
"types": [
|
|
378
|
+
{
|
|
379
|
+
"text": "{\n animated: boolean;\n}",
|
|
380
|
+
"complexTypes": []
|
|
381
|
+
}
|
|
382
|
+
]
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"name": "NavigationBarHideOptions",
|
|
386
|
+
"slug": "navigationbarhideoptions",
|
|
387
|
+
"docs": "",
|
|
388
|
+
"types": [
|
|
389
|
+
{
|
|
390
|
+
"text": "{\n /**\n * The animation type for hiding the navigation bar.\n * - 'fade': Makes the background transparent without removing the navigation bar.\n * - 'slide': Hides the navigation bar completely (default behavior).\n */\n animation: StatusBarAnimation;\n}",
|
|
391
|
+
"complexTypes": [
|
|
392
|
+
"StatusBarAnimation"
|
|
393
|
+
]
|
|
394
|
+
}
|
|
395
|
+
]
|
|
396
|
+
},
|
|
319
397
|
{
|
|
320
398
|
"name": "SafeAreaInsets",
|
|
321
399
|
"slug": "safeareainsets",
|
|
@@ -41,6 +41,17 @@ export declare type StatusBarSetOverlaysWebViewOptions = {
|
|
|
41
41
|
export declare type StatusBarSetBackgroundOptions = {
|
|
42
42
|
color: StatusBarColor;
|
|
43
43
|
};
|
|
44
|
+
export declare type NavigationBarShowOptions = {
|
|
45
|
+
animated: boolean;
|
|
46
|
+
};
|
|
47
|
+
export declare type NavigationBarHideOptions = {
|
|
48
|
+
/**
|
|
49
|
+
* The animation type for hiding the navigation bar.
|
|
50
|
+
* - 'fade': Makes the background transparent without removing the navigation bar.
|
|
51
|
+
* - 'slide': Hides the navigation bar completely (default behavior).
|
|
52
|
+
*/
|
|
53
|
+
animation: StatusBarAnimation;
|
|
54
|
+
};
|
|
44
55
|
export declare type SafeAreaInsets = {
|
|
45
56
|
top: number;
|
|
46
57
|
bottom: number;
|
|
@@ -87,6 +98,18 @@ export interface CapacitorStatusBarPlugin {
|
|
|
87
98
|
* @param options.color - The background color in HEX format.
|
|
88
99
|
*/
|
|
89
100
|
setBackground(options: StatusBarSetBackgroundOptions): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Show the navigation bar.
|
|
103
|
+
* @param options - The options to show the navigation bar.
|
|
104
|
+
* @param options.animated - Whether to animate the navigation bar.
|
|
105
|
+
*/
|
|
106
|
+
showNavigationBar(options: NavigationBarShowOptions): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Hide the navigation bar.
|
|
109
|
+
* @param options - The options to hide the navigation bar.
|
|
110
|
+
* @param options.animation - The animation type: 'fade' makes background transparent, 'slide' hides bar completely.
|
|
111
|
+
*/
|
|
112
|
+
hideNavigationBar(options: NavigationBarHideOptions): Promise<void>;
|
|
90
113
|
/**
|
|
91
114
|
* Get the safe area insets.
|
|
92
115
|
* Returns the insets for status bar, navigation bar, and notch areas.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,KAIX;AAJD,WAAY,KAAK;IACf,wBAAe,CAAA;IACf,sBAAa,CAAA;IACb,0BAAiB,CAAA;AACnB,CAAC,EAJW,KAAK,KAAL,KAAK,QAIhB;AAWD,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,mCAAa,CAAA;IACb,mCAAa,CAAA;IACb,qCAAe,CAAA;AACjB,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B","sourcesContent":["export enum Style {\n LIGHT = 'LIGHT',\n DARK = 'DARK',\n CUSTOM = 'CUSTOM',\n}\n\n/**\n * Full HEX color format only (6 or 8 digits).\n * - 6 digits: #RRGGBB (e.g., #FFFFFF, #000000, #FF5733)\n * - 8 digits: #RRGGBBAA with alpha channel (e.g., #FFFFFF00, #FF5733CC)\n *\n * Note: Short 3-digit format (#FFF) is NOT supported.\n */\nexport type StatusBarColor = `#${string}`;\n\nexport enum StatusBarAnimation {\n NONE = 'none',\n FADE = 'fade',\n SLIDE = 'slide',\n}\n\ntype StatusBarStyleNoDefaultOptions = {\n style: Style;\n};\n\ntype StatusBarStyleOptions =\n | StatusBarStyleNoDefaultOptions\n | {\n style: Style.CUSTOM;\n color: StatusBarColor;\n };\n\nexport type StatusBarOptions = StatusBarStyleOptions;\n\nexport type StatusBarShowOptions = {\n animated: boolean;\n};\n\nexport type StatusBarHideOptions = {\n /**\n * The animation type for hiding the status bar.\n * - 'fade': Makes the background transparent without removing the status bar and navigation bar.\n * - 'slide': Hides the status bar and navigation bar completely (default behavior).\n */\n animation: StatusBarAnimation;\n};\n\nexport type StatusBarSetOverlaysWebViewOptions = {\n value: boolean;\n};\n\nexport type StatusBarSetBackgroundOptions = {\n color: StatusBarColor;\n};\n\nexport type SafeAreaInsets = {\n top: number;\n bottom: number;\n left: number;\n right: number;\n};\n\nexport interface CapacitorStatusBarPlugin {\n /**\n * Set the status bar and navigation bar style and color.\n * @param options - The options to set the status bar style and color.\n * @param options.style - The style of the status bar.\n * @param options.color - The color of the status bar.\n */\n setStyle(options: StatusBarOptions): Promise<void>;\n /**\n * Show the status bar.\n * @param options - The options to show the status bar.\n * @param options.animated - Whether to animate the status bar.\n */\n show(options: StatusBarShowOptions): Promise<void>;\n /**\n * Hide the status bar.\n * @param options - The options to hide the status bar.\n * @param options.animation - The animation type: 'fade' makes background transparent, 'slide' hides bars completely.\n */\n hide(options: StatusBarHideOptions): Promise<void>;\n /**\n * Set whether the status bar overlays the web view.\n *\n * **iOS only** - On Android this is a no-op (resolves without error).\n *\n * - `true`: Web content extends behind the status bar (transparent background),\n * allowing content to be visible through the status bar area on scroll.\n * - `false`: Restores the status bar background to the color set by `setStyle`\n * or falls back to the default style from Capacitor config.\n *\n * @param options - The options to set the status bar overlays web view.\n * @param options.value - Whether the status bar overlays the web view (required).\n */\n setOverlaysWebView(options: StatusBarSetOverlaysWebViewOptions): Promise<void>;\n /**\n * Set the window background color.\n * @param options - The options to set the window background color.\n * @param options.color - The background color in HEX format.\n */\n setBackground(options: StatusBarSetBackgroundOptions): Promise<void>;\n /**\n * Get the safe area insets.\n * Returns the insets for status bar, navigation bar, and notch areas.\n * Values are in CSS pixels (dp) on all platforms.\n */\n getSafeAreaInsets(): Promise<SafeAreaInsets>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,KAIX;AAJD,WAAY,KAAK;IACf,wBAAe,CAAA;IACf,sBAAa,CAAA;IACb,0BAAiB,CAAA;AACnB,CAAC,EAJW,KAAK,KAAL,KAAK,QAIhB;AAWD,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,mCAAa,CAAA;IACb,mCAAa,CAAA;IACb,qCAAe,CAAA;AACjB,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B","sourcesContent":["export enum Style {\n LIGHT = 'LIGHT',\n DARK = 'DARK',\n CUSTOM = 'CUSTOM',\n}\n\n/**\n * Full HEX color format only (6 or 8 digits).\n * - 6 digits: #RRGGBB (e.g., #FFFFFF, #000000, #FF5733)\n * - 8 digits: #RRGGBBAA with alpha channel (e.g., #FFFFFF00, #FF5733CC)\n *\n * Note: Short 3-digit format (#FFF) is NOT supported.\n */\nexport type StatusBarColor = `#${string}`;\n\nexport enum StatusBarAnimation {\n NONE = 'none',\n FADE = 'fade',\n SLIDE = 'slide',\n}\n\ntype StatusBarStyleNoDefaultOptions = {\n style: Style;\n};\n\ntype StatusBarStyleOptions =\n | StatusBarStyleNoDefaultOptions\n | {\n style: Style.CUSTOM;\n color: StatusBarColor;\n };\n\nexport type StatusBarOptions = StatusBarStyleOptions;\n\nexport type StatusBarShowOptions = {\n animated: boolean;\n};\n\nexport type StatusBarHideOptions = {\n /**\n * The animation type for hiding the status bar.\n * - 'fade': Makes the background transparent without removing the status bar and navigation bar.\n * - 'slide': Hides the status bar and navigation bar completely (default behavior).\n */\n animation: StatusBarAnimation;\n};\n\nexport type StatusBarSetOverlaysWebViewOptions = {\n value: boolean;\n};\n\nexport type StatusBarSetBackgroundOptions = {\n color: StatusBarColor;\n};\n\nexport type NavigationBarShowOptions = {\n animated: boolean;\n};\n\nexport type NavigationBarHideOptions = {\n /**\n * The animation type for hiding the navigation bar.\n * - 'fade': Makes the background transparent without removing the navigation bar.\n * - 'slide': Hides the navigation bar completely (default behavior).\n */\n animation: StatusBarAnimation;\n};\n\nexport type SafeAreaInsets = {\n top: number;\n bottom: number;\n left: number;\n right: number;\n};\n\nexport interface CapacitorStatusBarPlugin {\n /**\n * Set the status bar and navigation bar style and color.\n * @param options - The options to set the status bar style and color.\n * @param options.style - The style of the status bar.\n * @param options.color - The color of the status bar.\n */\n setStyle(options: StatusBarOptions): Promise<void>;\n /**\n * Show the status bar.\n * @param options - The options to show the status bar.\n * @param options.animated - Whether to animate the status bar.\n */\n show(options: StatusBarShowOptions): Promise<void>;\n /**\n * Hide the status bar.\n * @param options - The options to hide the status bar.\n * @param options.animation - The animation type: 'fade' makes background transparent, 'slide' hides bars completely.\n */\n hide(options: StatusBarHideOptions): Promise<void>;\n /**\n * Set whether the status bar overlays the web view.\n *\n * **iOS only** - On Android this is a no-op (resolves without error).\n *\n * - `true`: Web content extends behind the status bar (transparent background),\n * allowing content to be visible through the status bar area on scroll.\n * - `false`: Restores the status bar background to the color set by `setStyle`\n * or falls back to the default style from Capacitor config.\n *\n * @param options - The options to set the status bar overlays web view.\n * @param options.value - Whether the status bar overlays the web view (required).\n */\n setOverlaysWebView(options: StatusBarSetOverlaysWebViewOptions): Promise<void>;\n /**\n * Set the window background color.\n * @param options - The options to set the window background color.\n * @param options.color - The background color in HEX format.\n */\n setBackground(options: StatusBarSetBackgroundOptions): Promise<void>;\n /**\n * Show the navigation bar.\n * @param options - The options to show the navigation bar.\n * @param options.animated - Whether to animate the navigation bar.\n */\n showNavigationBar(options: NavigationBarShowOptions): Promise<void>;\n /**\n * Hide the navigation bar.\n * @param options - The options to hide the navigation bar.\n * @param options.animation - The animation type: 'fade' makes background transparent, 'slide' hides bar completely.\n */\n hideNavigationBar(options: NavigationBarHideOptions): Promise<void>;\n /**\n * Get the safe area insets.\n * Returns the insets for status bar, navigation bar, and notch areas.\n * Values are in CSS pixels (dp) on all platforms.\n */\n getSafeAreaInsets(): Promise<SafeAreaInsets>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { StatusBarOptions, CapacitorStatusBarPlugin, StatusBarSetOverlaysWebViewOptions, StatusBarShowOptions, StatusBarHideOptions, StatusBarSetBackgroundOptions, SafeAreaInsets } from './definitions';
|
|
2
|
+
import type { StatusBarOptions, CapacitorStatusBarPlugin, StatusBarSetOverlaysWebViewOptions, StatusBarShowOptions, StatusBarHideOptions, StatusBarSetBackgroundOptions, SafeAreaInsets, NavigationBarShowOptions, NavigationBarHideOptions } from './definitions';
|
|
3
3
|
export declare class CapacitorStatusBarWeb extends WebPlugin implements CapacitorStatusBarPlugin {
|
|
4
4
|
setStyle(options: StatusBarOptions): Promise<void>;
|
|
5
5
|
show(options: StatusBarShowOptions): Promise<void>;
|
|
6
6
|
hide(options: StatusBarHideOptions): Promise<void>;
|
|
7
7
|
setOverlaysWebView(options: StatusBarSetOverlaysWebViewOptions): Promise<void>;
|
|
8
8
|
setBackground(options: StatusBarSetBackgroundOptions): Promise<void>;
|
|
9
|
+
showNavigationBar(options: NavigationBarShowOptions): Promise<void>;
|
|
10
|
+
hideNavigationBar(options: NavigationBarHideOptions): Promise<void>;
|
|
9
11
|
getSafeAreaInsets(): Promise<SafeAreaInsets>;
|
|
10
12
|
}
|
package/dist/esm/web.js
CHANGED
|
@@ -15,6 +15,12 @@ export class CapacitorStatusBarWeb extends WebPlugin {
|
|
|
15
15
|
async setBackground(options) {
|
|
16
16
|
console.log('setBackground', options);
|
|
17
17
|
}
|
|
18
|
+
async showNavigationBar(options) {
|
|
19
|
+
console.log('showNavigationBar', options);
|
|
20
|
+
}
|
|
21
|
+
async hideNavigationBar(options) {
|
|
22
|
+
console.log('hideNavigationBar', options);
|
|
23
|
+
}
|
|
18
24
|
async getSafeAreaInsets() {
|
|
19
25
|
// On web, we can use CSS environment variables to get safe area insets
|
|
20
26
|
// These are set by the browser on devices with notches, etc.
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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AC,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC;QAEF,MAAM,MAAM,GAAmB;YAC7B,GAAG,EAAE,aAAa,CAAC,0BAA0B,CAAC,IAAI,aAAa,CAAC,+BAA+B,CAAC,IAAI,CAAC;YACrG,MAAM,EAAE,aAAa,CAAC,6BAA6B,CAAC,IAAI,aAAa,CAAC,kCAAkC,CAAC,IAAI,CAAC;YAC9G,IAAI,EAAE,aAAa,CAAC,2BAA2B,CAAC,IAAI,aAAa,CAAC,gCAAgC,CAAC,IAAI,CAAC;YACxG,KAAK,EAAE,aAAa,CAAC,4BAA4B,CAAC,IAAI,aAAa,CAAC,iCAAiC,CAAC,IAAI,CAAC;SAC5G,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;QACzC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n StatusBarOptions,\n CapacitorStatusBarPlugin,\n StatusBarSetOverlaysWebViewOptions,\n StatusBarShowOptions,\n StatusBarHideOptions,\n StatusBarSetBackgroundOptions,\n SafeAreaInsets,\n NavigationBarShowOptions,\n NavigationBarHideOptions,\n} from './definitions';\n\nexport class CapacitorStatusBarWeb extends WebPlugin implements CapacitorStatusBarPlugin {\n async setStyle(options: StatusBarOptions): Promise<void> {\n console.log('setStyle', options);\n }\n\n async show(options: StatusBarShowOptions): Promise<void> {\n console.log('show', options);\n }\n\n async hide(options: StatusBarHideOptions): Promise<void> {\n console.log('hide', options);\n }\n\n async setOverlaysWebView(options: StatusBarSetOverlaysWebViewOptions): Promise<void> {\n console.log('setOverlaysWebView', options);\n }\n\n async setBackground(options: StatusBarSetBackgroundOptions): Promise<void> {\n console.log('setBackground', options);\n }\n\n async showNavigationBar(options: NavigationBarShowOptions): Promise<void> {\n console.log('showNavigationBar', options);\n }\n\n async hideNavigationBar(options: NavigationBarHideOptions): Promise<void> {\n console.log('hideNavigationBar', options);\n }\n\n async getSafeAreaInsets(): Promise<SafeAreaInsets> {\n // On web, we can use CSS environment variables to get safe area insets\n // These are set by the browser on devices with notches, etc.\n const getInsetValue = (variable: string): number => {\n const value = getComputedStyle(document.documentElement).getPropertyValue(variable).trim();\n return value ? parseInt(value, 10) : 0;\n };\n\n const insets: SafeAreaInsets = {\n top: getInsetValue('env(safe-area-inset-top)') || getInsetValue('constant(safe-area-inset-top)') || 0,\n bottom: getInsetValue('env(safe-area-inset-bottom)') || getInsetValue('constant(safe-area-inset-bottom)') || 0,\n left: getInsetValue('env(safe-area-inset-left)') || getInsetValue('constant(safe-area-inset-left)') || 0,\n right: getInsetValue('env(safe-area-inset-right)') || getInsetValue('constant(safe-area-inset-right)') || 0,\n };\n\n console.log('getSafeAreaInsets', insets);\n return insets;\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -35,6 +35,12 @@ class CapacitorStatusBarWeb extends core.WebPlugin {
|
|
|
35
35
|
async setBackground(options) {
|
|
36
36
|
console.log('setBackground', options);
|
|
37
37
|
}
|
|
38
|
+
async showNavigationBar(options) {
|
|
39
|
+
console.log('showNavigationBar', options);
|
|
40
|
+
}
|
|
41
|
+
async hideNavigationBar(options) {
|
|
42
|
+
console.log('hideNavigationBar', options);
|
|
43
|
+
}
|
|
38
44
|
async getSafeAreaInsets() {
|
|
39
45
|
// On web, we can use CSS environment variables to get safe area insets
|
|
40
46
|
// These are set by the browser on devices with notches, etc.
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var Style;\n(function (Style) {\n Style[\"LIGHT\"] = \"LIGHT\";\n Style[\"DARK\"] = \"DARK\";\n Style[\"CUSTOM\"] = \"CUSTOM\";\n})(Style || (Style = {}));\nexport var StatusBarAnimation;\n(function (StatusBarAnimation) {\n StatusBarAnimation[\"NONE\"] = \"none\";\n StatusBarAnimation[\"FADE\"] = \"fade\";\n StatusBarAnimation[\"SLIDE\"] = \"slide\";\n})(StatusBarAnimation || (StatusBarAnimation = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorStatusBar = registerPlugin('CapacitorStatusBar', {\n web: () => import('./web').then((m) => new m.CapacitorStatusBarWeb()),\n});\nexport * from './definitions';\nexport { CapacitorStatusBar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorStatusBarWeb extends WebPlugin {\n async setStyle(options) {\n console.log('setStyle', options);\n }\n async show(options) {\n console.log('show', options);\n }\n async hide(options) {\n console.log('hide', options);\n }\n async setOverlaysWebView(options) {\n console.log('setOverlaysWebView', options);\n }\n async setBackground(options) {\n console.log('setBackground', options);\n }\n async getSafeAreaInsets() {\n // On web, we can use CSS environment variables to get safe area insets\n // These are set by the browser on devices with notches, etc.\n const getInsetValue = (variable) => {\n const value = getComputedStyle(document.documentElement).getPropertyValue(variable).trim();\n return value ? parseInt(value, 10) : 0;\n };\n const insets = {\n top: getInsetValue('env(safe-area-inset-top)') || getInsetValue('constant(safe-area-inset-top)') || 0,\n bottom: getInsetValue('env(safe-area-inset-bottom)') || getInsetValue('constant(safe-area-inset-bottom)') || 0,\n left: getInsetValue('env(safe-area-inset-left)') || getInsetValue('constant(safe-area-inset-left)') || 0,\n right: getInsetValue('env(safe-area-inset-right)') || getInsetValue('constant(safe-area-inset-right)') || 0,\n };\n console.log('getSafeAreaInsets', insets);\n return insets;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["Style","StatusBarAnimation","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA;AACX,CAAC,UAAU,KAAK,EAAE;AAClB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO;AAC5B,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM;AAC1B,IAAI,KAAK,CA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,CAAC,QAAQ,KAAK;AAC5C,YAAY,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE;AACtG,YAAY,OAAO,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC;AAClD,QAAQ,CAAC;AACT,QAAQ,MAAM,MAAM,GAAG;AACvB,YAAY,GAAG,EAAE,aAAa,CAAC,0BAA0B,CAAC,IAAI,aAAa,CAAC,+BAA+B,CAAC,IAAI,CAAC;AACjH,YAAY,MAAM,EAAE,aAAa,CAAC,6BAA6B,CAAC,IAAI,aAAa,CAAC,kCAAkC,CAAC,IAAI,CAAC;AAC1H,YAAY,IAAI,EAAE,aAAa,CAAC,2BAA2B,CAAC,IAAI,aAAa,CAAC,gCAAgC,CAAC,IAAI,CAAC;AACpH,YAAY,KAAK,EAAE,aAAa,CAAC,4BAA4B,CAAC,IAAI,aAAa,CAAC,iCAAiC,CAAC,IAAI,CAAC;AACvH,SAAS;AACT,QAAQ,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC;AAChD,QAAQ,OAAO,MAAM;AACrB,IAAI;AACJ;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var Style;\n(function (Style) {\n Style[\"LIGHT\"] = \"LIGHT\";\n Style[\"DARK\"] = \"DARK\";\n Style[\"CUSTOM\"] = \"CUSTOM\";\n})(Style || (Style = {}));\nexport var StatusBarAnimation;\n(function (StatusBarAnimation) {\n StatusBarAnimation[\"NONE\"] = \"none\";\n StatusBarAnimation[\"FADE\"] = \"fade\";\n StatusBarAnimation[\"SLIDE\"] = \"slide\";\n})(StatusBarAnimation || (StatusBarAnimation = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorStatusBar = registerPlugin('CapacitorStatusBar', {\n web: () => import('./web').then((m) => new m.CapacitorStatusBarWeb()),\n});\nexport * from './definitions';\nexport { CapacitorStatusBar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorStatusBarWeb extends WebPlugin {\n async setStyle(options) {\n console.log('setStyle', options);\n }\n async show(options) {\n console.log('show', options);\n }\n async hide(options) {\n console.log('hide', options);\n }\n async setOverlaysWebView(options) {\n console.log('setOverlaysWebView', options);\n }\n async setBackground(options) {\n console.log('setBackground', options);\n }\n async showNavigationBar(options) {\n console.log('showNavigationBar', options);\n }\n async hideNavigationBar(options) {\n console.log('hideNavigationBar', options);\n }\n async getSafeAreaInsets() {\n // On web, we can use CSS environment variables to get safe area insets\n // These are set by the browser on devices with notches, etc.\n const getInsetValue = (variable) => {\n const value = getComputedStyle(document.documentElement).getPropertyValue(variable).trim();\n return value ? parseInt(value, 10) : 0;\n };\n const insets = {\n top: getInsetValue('env(safe-area-inset-top)') || getInsetValue('constant(safe-area-inset-top)') || 0,\n bottom: getInsetValue('env(safe-area-inset-bottom)') || getInsetValue('constant(safe-area-inset-bottom)') || 0,\n left: getInsetValue('env(safe-area-inset-left)') || getInsetValue('constant(safe-area-inset-left)') || 0,\n right: getInsetValue('env(safe-area-inset-right)') || getInsetValue('constant(safe-area-inset-right)') || 0,\n };\n console.log('getSafeAreaInsets', insets);\n return insets;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["Style","StatusBarAnimation","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA;AACX,CAAC,UAAU,KAAK,EAAE;AAClB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO;AAC5B,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM;AAC1B,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,QAAQ;AAC9B,CAAC,EAAEA,aAAK,KAAKA,aAAK,GAAG,EAAE,CAAC,CAAC;AACdC;AACX,CAAC,UAAU,kBAAkB,EAAE;AAC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B,EAAE,OAAO,CAAC;AACjD,IAAI;AACJ,IAAI,MAAM,iBAAiB,GAAG;AAC9B;AACA;AACA,QAAQ,MAAM,aAAa,GAAG,CAAC,QAAQ,KAAK;AAC5C,YAAY,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE;AACtG,YAAY,OAAO,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC;AAClD,QAAQ,CAAC;AACT,QAAQ,MAAM,MAAM,GAAG;AACvB,YAAY,GAAG,EAAE,aAAa,CAAC,0BAA0B,CAAC,IAAI,aAAa,CAAC,+BAA+B,CAAC,IAAI,CAAC;AACjH,YAAY,MAAM,EAAE,aAAa,CAAC,6BAA6B,CAAC,IAAI,aAAa,CAAC,kCAAkC,CAAC,IAAI,CAAC;AAC1H,YAAY,IAAI,EAAE,aAAa,CAAC,2BAA2B,CAAC,IAAI,aAAa,CAAC,gCAAgC,CAAC,IAAI,CAAC;AACpH,YAAY,KAAK,EAAE,aAAa,CAAC,4BAA4B,CAAC,IAAI,aAAa,CAAC,iCAAiC,CAAC,IAAI,CAAC;AACvH,SAAS;AACT,QAAQ,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC;AAChD,QAAQ,OAAO,MAAM;AACrB,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -34,6 +34,12 @@ var capStatusBar = (function (exports, core) {
|
|
|
34
34
|
async setBackground(options) {
|
|
35
35
|
console.log('setBackground', options);
|
|
36
36
|
}
|
|
37
|
+
async showNavigationBar(options) {
|
|
38
|
+
console.log('showNavigationBar', options);
|
|
39
|
+
}
|
|
40
|
+
async hideNavigationBar(options) {
|
|
41
|
+
console.log('hideNavigationBar', options);
|
|
42
|
+
}
|
|
37
43
|
async getSafeAreaInsets() {
|
|
38
44
|
// On web, we can use CSS environment variables to get safe area insets
|
|
39
45
|
// These are set by the browser on devices with notches, etc.
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var Style;\n(function (Style) {\n Style[\"LIGHT\"] = \"LIGHT\";\n Style[\"DARK\"] = \"DARK\";\n Style[\"CUSTOM\"] = \"CUSTOM\";\n})(Style || (Style = {}));\nexport var StatusBarAnimation;\n(function (StatusBarAnimation) {\n StatusBarAnimation[\"NONE\"] = \"none\";\n StatusBarAnimation[\"FADE\"] = \"fade\";\n StatusBarAnimation[\"SLIDE\"] = \"slide\";\n})(StatusBarAnimation || (StatusBarAnimation = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorStatusBar = registerPlugin('CapacitorStatusBar', {\n web: () => import('./web').then((m) => new m.CapacitorStatusBarWeb()),\n});\nexport * from './definitions';\nexport { CapacitorStatusBar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorStatusBarWeb extends WebPlugin {\n async setStyle(options) {\n console.log('setStyle', options);\n }\n async show(options) {\n console.log('show', options);\n }\n async hide(options) {\n console.log('hide', options);\n }\n async setOverlaysWebView(options) {\n console.log('setOverlaysWebView', options);\n }\n async setBackground(options) {\n console.log('setBackground', options);\n }\n async getSafeAreaInsets() {\n // On web, we can use CSS environment variables to get safe area insets\n // These are set by the browser on devices with notches, etc.\n const getInsetValue = (variable) => {\n const value = getComputedStyle(document.documentElement).getPropertyValue(variable).trim();\n return value ? parseInt(value, 10) : 0;\n };\n const insets = {\n top: getInsetValue('env(safe-area-inset-top)') || getInsetValue('constant(safe-area-inset-top)') || 0,\n bottom: getInsetValue('env(safe-area-inset-bottom)') || getInsetValue('constant(safe-area-inset-bottom)') || 0,\n left: getInsetValue('env(safe-area-inset-left)') || getInsetValue('constant(safe-area-inset-left)') || 0,\n right: getInsetValue('env(safe-area-inset-right)') || getInsetValue('constant(safe-area-inset-right)') || 0,\n };\n console.log('getSafeAreaInsets', insets);\n return insets;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["Style","StatusBarAnimation","registerPlugin","WebPlugin"],"mappings":";;;AAAWA;IACX,CAAC,UAAU,KAAK,EAAE;IAClB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO;IAC5B,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM;IAC1B,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,QAAQ;IAC9B,CAAC,EAAEA,aAAK,KAAKA,aAAK,GAAG,EAAE,CAAC,CAAC;AACdC;IACX,CAAC,UAAU,kBAAkB,EAAE;IAC/B,IAAI,kBAAkB,CAAC,MAAM,CAAC,GAAG,MAAM;IACvC,IAAI,kBAAkB,CAAC,MAAM,CAAC,GAAG,MAAM;IACvC,IAAI,kBAAkB,CAAC,OAAO,CAAC,GAAG,OAAO;IACzC,CAAC,EAAEA,0BAAkB,KAAKA,0BAAkB,GAAG,EAAE,CAAC,CAAC;;ACV9C,UAAC,kBAAkB,GAAGC,mBAAc,CAAC,oBAAoB,EAAE;IAChE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,qBAAqB,EAAE,CAAC;IACzE,CAAC;;ICFM,MAAM,qBAAqB,SAASC,cAAS,CAAC;IACrD,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;IAC5B,QAAQ,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC;IACxC,IAAI;IACJ,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IACpC,IAAI;IACJ,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IACpC,IAAI;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"DARK\"] = \"DARK\";\n Style[\"CUSTOM\"] = \"CUSTOM\";\n})(Style || (Style = {}));\nexport var StatusBarAnimation;\n(function (StatusBarAnimation) {\n StatusBarAnimation[\"NONE\"] = \"none\";\n StatusBarAnimation[\"FADE\"] = \"fade\";\n StatusBarAnimation[\"SLIDE\"] = \"slide\";\n})(StatusBarAnimation || (StatusBarAnimation = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorStatusBar = registerPlugin('CapacitorStatusBar', {\n web: () => import('./web').then((m) => new m.CapacitorStatusBarWeb()),\n});\nexport * from './definitions';\nexport { CapacitorStatusBar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorStatusBarWeb extends WebPlugin {\n async setStyle(options) {\n console.log('setStyle', options);\n }\n async show(options) {\n console.log('show', options);\n }\n async hide(options) {\n console.log('hide', options);\n }\n async setOverlaysWebView(options) {\n console.log('setOverlaysWebView', options);\n }\n async setBackground(options) {\n console.log('setBackground', options);\n }\n async showNavigationBar(options) {\n console.log('showNavigationBar', options);\n }\n async hideNavigationBar(options) {\n console.log('hideNavigationBar', options);\n }\n async getSafeAreaInsets() {\n // On web, we can use CSS environment variables to get safe area insets\n // These are set by the browser on devices with notches, etc.\n const getInsetValue = (variable) => {\n const value = getComputedStyle(document.documentElement).getPropertyValue(variable).trim();\n return value ? parseInt(value, 10) : 0;\n };\n const insets = {\n top: getInsetValue('env(safe-area-inset-top)') || getInsetValue('constant(safe-area-inset-top)') || 0,\n bottom: getInsetValue('env(safe-area-inset-bottom)') || getInsetValue('constant(safe-area-inset-bottom)') || 0,\n left: getInsetValue('env(safe-area-inset-left)') || getInsetValue('constant(safe-area-inset-left)') || 0,\n right: getInsetValue('env(safe-area-inset-right)') || getInsetValue('constant(safe-area-inset-right)') || 0,\n };\n console.log('getSafeAreaInsets', insets);\n return insets;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["Style","StatusBarAnimation","registerPlug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 import Capacitor
|
|
|
92
92
|
// Note: This requires UIViewControllerBasedStatusBarAppearance = NO
|
|
93
93
|
self.setStatusBarVisibility(hidden: false, animated: animated)
|
|
94
94
|
|
|
95
|
-
// Restore the background view color when showing
|
|
96
|
-
self.
|
|
95
|
+
// Restore the background view color when showing (unless overlay mode is active)
|
|
96
|
+
if !self.isOverlayMode {
|
|
97
|
+
self.restoreStatusBarBackgroundColor()
|
|
98
|
+
}
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
|
|
@@ -251,6 +253,76 @@ import Capacitor
|
|
|
251
253
|
}
|
|
252
254
|
}
|
|
253
255
|
|
|
256
|
+
// MARK: - Navigation Bar (Home Indicator)
|
|
257
|
+
|
|
258
|
+
/// Shared flag read by the swizzled `prefersHomeIndicatorAutoHidden` override.
|
|
259
|
+
static var homeIndicatorHidden = false
|
|
260
|
+
|
|
261
|
+
@objc public func showNavigationBar(animated: Bool) {
|
|
262
|
+
DispatchQueue.main.async {
|
|
263
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
264
|
+
let window = windowScene.windows.first,
|
|
265
|
+
let rootVC = window.rootViewController else {
|
|
266
|
+
print("CapacitorStatusBar: showNavigationBar - Unable to get root view controller")
|
|
267
|
+
return
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
CapacitorStatusBar.homeIndicatorHidden = false
|
|
271
|
+
CapacitorStatusBar.swizzleHomeIndicatorIfNeeded()
|
|
272
|
+
rootVC.setNeedsUpdateOfHomeIndicatorAutoHidden()
|
|
273
|
+
|
|
274
|
+
print("CapacitorStatusBar: showNavigationBar - animated=\(animated)")
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
@objc public func hideNavigationBar(animation: String) {
|
|
279
|
+
DispatchQueue.main.async {
|
|
280
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
281
|
+
let window = windowScene.windows.first,
|
|
282
|
+
let rootVC = window.rootViewController else {
|
|
283
|
+
print("CapacitorStatusBar: hideNavigationBar - Unable to get root view controller")
|
|
284
|
+
return
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
let animationType = animation.lowercased()
|
|
288
|
+
CapacitorStatusBar.homeIndicatorHidden = true
|
|
289
|
+
CapacitorStatusBar.swizzleHomeIndicatorIfNeeded()
|
|
290
|
+
rootVC.setNeedsUpdateOfHomeIndicatorAutoHidden()
|
|
291
|
+
|
|
292
|
+
print("CapacitorStatusBar: hideNavigationBar - animation=\(animationType)")
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// MARK: - Home Indicator Swizzling
|
|
297
|
+
|
|
298
|
+
private static var hasSwizzled = false
|
|
299
|
+
|
|
300
|
+
/// Swizzle `prefersHomeIndicatorAutoHidden` on the root view controller so we
|
|
301
|
+
/// can control the home indicator visibility from the plugin.
|
|
302
|
+
static func swizzleHomeIndicatorIfNeeded() {
|
|
303
|
+
guard !hasSwizzled else { return }
|
|
304
|
+
hasSwizzled = true
|
|
305
|
+
|
|
306
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
307
|
+
let window = windowScene.windows.first,
|
|
308
|
+
let rootVC = window.rootViewController else {
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
let vcClass: AnyClass = type(of: rootVC)
|
|
313
|
+
let originalSelector = #selector(getter: UIViewController.prefersHomeIndicatorAutoHidden)
|
|
314
|
+
let swizzledSelector = #selector(UIViewController.capsb_prefersHomeIndicatorAutoHidden)
|
|
315
|
+
|
|
316
|
+
guard let originalMethod = class_getInstanceMethod(vcClass, originalSelector),
|
|
317
|
+
let swizzledMethod = class_getInstanceMethod(UIViewController.self, swizzledSelector) else {
|
|
318
|
+
print("CapacitorStatusBar: Failed to swizzle prefersHomeIndicatorAutoHidden")
|
|
319
|
+
return
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
method_exchangeImplementations(originalMethod, swizzledMethod)
|
|
323
|
+
print("CapacitorStatusBar: Swizzled prefersHomeIndicatorAutoHidden on \(vcClass)")
|
|
324
|
+
}
|
|
325
|
+
|
|
254
326
|
/// Makes the status bar background view transparent
|
|
255
327
|
private func makeStatusBarBackgroundTransparent() {
|
|
256
328
|
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
@@ -329,3 +401,11 @@ import Capacitor
|
|
|
329
401
|
return window.traitCollection.userInterfaceStyle == .dark
|
|
330
402
|
}
|
|
331
403
|
}
|
|
404
|
+
|
|
405
|
+
// MARK: - UIViewController extension for home indicator swizzling
|
|
406
|
+
|
|
407
|
+
extension UIViewController {
|
|
408
|
+
@objc func capsb_prefersHomeIndicatorAutoHidden() -> Bool {
|
|
409
|
+
return CapacitorStatusBar.homeIndicatorHidden
|
|
410
|
+
}
|
|
411
|
+
}
|
|
@@ -15,6 +15,8 @@ public class CapacitorStatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
15
15
|
CAPPluginMethod(name: "hide", returnType: CAPPluginReturnPromise),
|
|
16
16
|
CAPPluginMethod(name: "setOverlaysWebView", returnType: CAPPluginReturnPromise),
|
|
17
17
|
CAPPluginMethod(name: "setBackground", returnType: CAPPluginReturnPromise),
|
|
18
|
+
CAPPluginMethod(name: "showNavigationBar", returnType: CAPPluginReturnPromise),
|
|
19
|
+
CAPPluginMethod(name: "hideNavigationBar", returnType: CAPPluginReturnPromise),
|
|
18
20
|
CAPPluginMethod(name: "getSafeAreaInsets", returnType: CAPPluginReturnPromise)
|
|
19
21
|
]
|
|
20
22
|
private let implementation = CapacitorStatusBar()
|
|
@@ -68,6 +70,21 @@ public class CapacitorStatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
68
70
|
call.resolve()
|
|
69
71
|
}
|
|
70
72
|
|
|
73
|
+
@objc func showNavigationBar(_ call: CAPPluginCall) {
|
|
74
|
+
let animated = call.getBool("animated") ?? true
|
|
75
|
+
implementation.showNavigationBar(animated: animated)
|
|
76
|
+
call.resolve()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@objc func hideNavigationBar(_ call: CAPPluginCall) {
|
|
80
|
+
guard let animation = call.getString("animation") else {
|
|
81
|
+
call.reject("animation is required")
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
implementation.hideNavigationBar(animation: animation)
|
|
85
|
+
call.resolve()
|
|
86
|
+
}
|
|
87
|
+
|
|
71
88
|
@objc func getSafeAreaInsets(_ call: CAPPluginCall) {
|
|
72
89
|
implementation.getSafeAreaInsets { insets in
|
|
73
90
|
call.resolve([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "capacitor-plugin-status-bar",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Capacitor plugin for managing the status bar style, visibility, and color on iOS and Android. Control overlay modes, background colors, and appearance for native mobile applications.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|