capacitor-plugin-status-bar 2.0.12 → 2.0.14
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 +0 -21
- package/android/src/main/java/com/cap/plugins/statusbar/CapacitorStatusBar.java +15 -74
- package/android/src/main/java/com/cap/plugins/statusbar/CapacitorStatusBarPlugin.java +0 -17
- package/dist/docs.json +0 -40
- package/dist/esm/definitions.d.ts +0 -9
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +1 -2
- package/dist/esm/web.js +0 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +0 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +0 -3
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapacitorStatusBarPlugin/CapacitorStatusBar.swift +178 -80
- package/ios/Sources/CapacitorStatusBarPlugin/CapacitorStatusBarPlugin.swift +18 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,6 @@ No additional configuration required. The plugin works out of the box on Android
|
|
|
37
37
|
* [`show()`](#show)
|
|
38
38
|
* [`hide()`](#hide)
|
|
39
39
|
* [`setOverlaysWebView(...)`](#setoverlayswebview)
|
|
40
|
-
* [`setBackground(...)`](#setbackground)
|
|
41
40
|
* [`showNavigationBar()`](#shownavigationbar)
|
|
42
41
|
* [`hideNavigationBar()`](#hidenavigationbar)
|
|
43
42
|
* [`getSafeAreaInsets()`](#getsafeareainsets)
|
|
@@ -108,21 +107,6 @@ Set whether the status bar overlays the web view.
|
|
|
108
107
|
--------------------
|
|
109
108
|
|
|
110
109
|
|
|
111
|
-
### setBackground(...)
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
setBackground(options: StatusBarSetBackgroundOptions) => Promise<void>
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Set the window background color.
|
|
118
|
-
|
|
119
|
-
| Param | Type | Description |
|
|
120
|
-
| ------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------- |
|
|
121
|
-
| **`options`** | <code><a href="#statusbarsetbackgroundoptions">StatusBarSetBackgroundOptions</a></code> | - The options to set the window background color. |
|
|
122
|
-
|
|
123
|
-
--------------------
|
|
124
|
-
|
|
125
|
-
|
|
126
110
|
### showNavigationBar()
|
|
127
111
|
|
|
128
112
|
```typescript
|
|
@@ -194,11 +178,6 @@ Note: Short 3-digit format (#FFF) is NOT supported.
|
|
|
194
178
|
<code>{ value: boolean; }</code>
|
|
195
179
|
|
|
196
180
|
|
|
197
|
-
#### StatusBarSetBackgroundOptions
|
|
198
|
-
|
|
199
|
-
<code>{ color: <a href="#statusbarcolor">StatusBarColor</a>; }</code>
|
|
200
|
-
|
|
201
|
-
|
|
202
181
|
#### SafeAreaInsets
|
|
203
182
|
|
|
204
183
|
<code>{ top: number; bottom: number; left: number; right: number; }</code>
|
|
@@ -121,7 +121,7 @@ public class CapacitorStatusBar extends Plugin {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
return
|
|
124
|
+
return insets;
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
decorView.requestApplyInsets();
|
|
@@ -151,10 +151,8 @@ public class CapacitorStatusBar extends Plugin {
|
|
|
151
151
|
// API 30+ (Android 11+) - Use WindowInsetsController
|
|
152
152
|
WindowInsetsController controller = window.getInsetsController();
|
|
153
153
|
if (controller != null) {
|
|
154
|
-
Log.d(TAG, "showStatusBar: showing
|
|
155
|
-
|
|
156
|
-
controller.show(WindowInsets.Type.systemBars());
|
|
157
|
-
// Set behavior for transient bars (user can swipe to reveal)
|
|
154
|
+
Log.d(TAG, "showStatusBar: showing status bar (API 30+)");
|
|
155
|
+
controller.show(WindowInsets.Type.statusBars());
|
|
158
156
|
controller.setSystemBarsBehavior(
|
|
159
157
|
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
|
160
158
|
} else {
|
|
@@ -164,35 +162,27 @@ public class CapacitorStatusBar extends Plugin {
|
|
|
164
162
|
// API 29 (Android 10) - Use system UI visibility flags (deprecated but
|
|
165
163
|
// necessary)
|
|
166
164
|
Log.d(TAG, "showStatusBar: showing using system UI flags (API 29)");
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
int flags = decorView.getSystemUiVisibility();
|
|
166
|
+
flags &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
|
|
167
|
+
decorView.setSystemUiVisibility(flags);
|
|
169
168
|
}
|
|
170
169
|
|
|
171
|
-
// Reapply the stored colors and style
|
|
170
|
+
// Reapply the stored colors and style
|
|
172
171
|
reapplyCurrentStyle(activity);
|
|
173
|
-
|
|
174
|
-
// Restore the overlay backgrounds to their original colors
|
|
175
|
-
restoreStatusBarBackground(activity);
|
|
176
|
-
|
|
177
|
-
// Also show the navigation bar
|
|
178
|
-
showNavigationBar(activity, true);
|
|
179
172
|
}
|
|
180
173
|
|
|
181
174
|
public void hideStatusBar(Activity activity) {
|
|
182
175
|
Window window = activity.getWindow();
|
|
183
176
|
View decorView = window.getDecorView();
|
|
184
177
|
|
|
185
|
-
|
|
186
|
-
Log.d(TAG, "hideStatusBar: slide mode - hiding bars completely");
|
|
178
|
+
Log.d(TAG, "hideStatusBar: hiding status bar");
|
|
187
179
|
|
|
188
180
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
189
181
|
// API 30+ (Android 11+) - Use WindowInsetsController
|
|
190
182
|
WindowInsetsController controller = window.getInsetsController();
|
|
191
183
|
if (controller != null) {
|
|
192
|
-
Log.d(TAG, "hideStatusBar: hiding
|
|
193
|
-
|
|
194
|
-
controller.hide(WindowInsets.Type.systemBars());
|
|
195
|
-
// Set behavior for immersive mode (user can swipe to reveal temporarily)
|
|
184
|
+
Log.d(TAG, "hideStatusBar: hiding status bar (API 30+)");
|
|
185
|
+
controller.hide(WindowInsets.Type.statusBars());
|
|
196
186
|
controller.setSystemBarsBehavior(
|
|
197
187
|
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
|
198
188
|
} else {
|
|
@@ -202,17 +192,15 @@ public class CapacitorStatusBar extends Plugin {
|
|
|
202
192
|
// API 29 (Android 10) - Use system UI visibility flags (deprecated but
|
|
203
193
|
// necessary)
|
|
204
194
|
Log.d(TAG, "hideStatusBar: hiding using system UI flags (API 29)");
|
|
205
|
-
// Use immersive sticky mode with proper layout flags for Android 10
|
|
206
195
|
decorView.setSystemUiVisibility(
|
|
207
|
-
|
|
196
|
+
decorView.getSystemUiVisibility()
|
|
197
|
+
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
|
208
198
|
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
209
|
-
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
210
199
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
211
|
-
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
|
212
200
|
| View.SYSTEM_UI_FLAG_FULLSCREEN);
|
|
213
201
|
}
|
|
214
202
|
|
|
215
|
-
// Make the overlay
|
|
203
|
+
// Make the status bar overlay transparent so content shows through
|
|
216
204
|
makeStatusBarBackgroundTransparent(activity);
|
|
217
205
|
}
|
|
218
206
|
|
|
@@ -275,24 +263,6 @@ public class CapacitorStatusBar extends Plugin {
|
|
|
275
263
|
setLightStatusBarIcons(window, lightBackground);
|
|
276
264
|
}
|
|
277
265
|
|
|
278
|
-
/**
|
|
279
|
-
* Set the window background color.
|
|
280
|
-
*
|
|
281
|
-
* @param activity The activity to apply the background color to
|
|
282
|
-
* @param colorHex The hex color string (e.g., "#FFFFFF" or "#FF5733")
|
|
283
|
-
*/
|
|
284
|
-
public void setBackground(Activity activity, @Nullable String colorHex) {
|
|
285
|
-
Log.d(TAG, "setBackground: colorHex=" + colorHex);
|
|
286
|
-
|
|
287
|
-
if (colorHex == null) {
|
|
288
|
-
Log.w(TAG, "setBackground: colorHex is null");
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
int color = parseColorOrDefault(colorHex, Color.WHITE);
|
|
293
|
-
applyWindowBackground(activity, color);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
266
|
/**
|
|
297
267
|
* Get the safe area insets.
|
|
298
268
|
* Returns the insets for status bar, navigation bar, and notch areas.
|
|
@@ -634,12 +604,6 @@ public class CapacitorStatusBar extends Plugin {
|
|
|
634
604
|
}
|
|
635
605
|
}
|
|
636
606
|
|
|
637
|
-
private void applyWindowBackground(Activity activity, @ColorInt int color) {
|
|
638
|
-
Log.d(TAG, "applyWindowBackground: body is always transparent; status/nav bars use overlays/native APIs");
|
|
639
|
-
View decorView = activity.getWindow().getDecorView();
|
|
640
|
-
decorView.setBackgroundColor(Color.TRANSPARENT);
|
|
641
|
-
}
|
|
642
|
-
|
|
643
607
|
/**
|
|
644
608
|
* Makes the status bar and navigation bar backgrounds transparent.
|
|
645
609
|
* This allows content to show through when the bars are hidden.
|
|
@@ -650,42 +614,19 @@ public class CapacitorStatusBar extends Plugin {
|
|
|
650
614
|
ViewGroup decorView = (ViewGroup) window.getDecorView();
|
|
651
615
|
|
|
652
616
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
653
|
-
// API 31+: edge-to-edge uses overlay
|
|
617
|
+
// API 31+: edge-to-edge uses overlay view for status bar
|
|
654
618
|
View statusBarOverlay = decorView.findViewWithTag(STATUS_BAR_OVERLAY_TAG);
|
|
655
619
|
if (statusBarOverlay != null) {
|
|
656
620
|
statusBarOverlay.setBackgroundColor(Color.TRANSPARENT);
|
|
657
621
|
Log.d(TAG, "makeStatusBarBackgroundTransparent: status bar overlay made transparent");
|
|
658
622
|
}
|
|
659
|
-
View navBarOverlay = decorView.findViewWithTag(NAV_BAR_OVERLAY_TAG);
|
|
660
|
-
if (navBarOverlay != null) {
|
|
661
|
-
navBarOverlay.setBackgroundColor(Color.TRANSPARENT);
|
|
662
|
-
Log.d(TAG, "makeStatusBarBackgroundTransparent: nav bar overlay made transparent");
|
|
663
|
-
}
|
|
664
623
|
} else {
|
|
665
624
|
// API 29–30: no edge-to-edge, native window API
|
|
666
625
|
window.setStatusBarColor(Color.TRANSPARENT);
|
|
667
|
-
|
|
668
|
-
Log.d(TAG, "makeStatusBarBackgroundTransparent: set native bar colors to transparent");
|
|
626
|
+
Log.d(TAG, "makeStatusBarBackgroundTransparent: set native status bar color to transparent");
|
|
669
627
|
}
|
|
670
628
|
}
|
|
671
629
|
|
|
672
|
-
/**
|
|
673
|
-
* Restores the status bar and navigation bar backgrounds to their stored
|
|
674
|
-
* colors.
|
|
675
|
-
* Called when showing the bars after they were hidden.
|
|
676
|
-
*/
|
|
677
|
-
private void restoreStatusBarBackground(Activity activity) {
|
|
678
|
-
Log.d(TAG, "restoreStatusBarBackground: API=" + Build.VERSION.SDK_INT
|
|
679
|
-
+ ", currentStatusBarColor=#" + Integer.toHexString(currentStatusBarColor)
|
|
680
|
-
+ ", currentNavBarColor=#" + Integer.toHexString(currentNavBarColor));
|
|
681
|
-
|
|
682
|
-
// Restore all backgrounds to their stored colors
|
|
683
|
-
applyStatusBarBackground(activity, currentStatusBarColor);
|
|
684
|
-
applyNavigationBarBackground(activity, currentNavBarColor);
|
|
685
|
-
|
|
686
|
-
Log.d(TAG, "restoreStatusBarBackground: backgrounds restored");
|
|
687
|
-
}
|
|
688
|
-
|
|
689
630
|
@ColorInt
|
|
690
631
|
private int parseColorOrDefault(@Nullable String color, @ColorInt int def) {
|
|
691
632
|
if (color == null) {
|
|
@@ -80,23 +80,6 @@ public class CapacitorStatusBarPlugin extends Plugin {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
@PluginMethod
|
|
84
|
-
public void setBackground(PluginCall call) {
|
|
85
|
-
try {
|
|
86
|
-
String color = call.getString("color");
|
|
87
|
-
if (color == null) {
|
|
88
|
-
call.reject("color is required");
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
getActivity().runOnUiThread(() -> {
|
|
92
|
-
implementation.setBackground(getActivity(), color);
|
|
93
|
-
call.resolve();
|
|
94
|
-
});
|
|
95
|
-
} catch (Exception e) {
|
|
96
|
-
call.reject(e.getMessage());
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
83
|
@PluginMethod
|
|
101
84
|
public void showNavigationBar(PluginCall call) {
|
|
102
85
|
try {
|
package/dist/docs.json
CHANGED
|
@@ -83,33 +83,6 @@
|
|
|
83
83
|
],
|
|
84
84
|
"slug": "setoverlayswebview"
|
|
85
85
|
},
|
|
86
|
-
{
|
|
87
|
-
"name": "setBackground",
|
|
88
|
-
"signature": "(options: StatusBarSetBackgroundOptions) => Promise<void>",
|
|
89
|
-
"parameters": [
|
|
90
|
-
{
|
|
91
|
-
"name": "options",
|
|
92
|
-
"docs": "- The options to set the window background color.",
|
|
93
|
-
"type": "StatusBarSetBackgroundOptions"
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
"returns": "Promise<void>",
|
|
97
|
-
"tags": [
|
|
98
|
-
{
|
|
99
|
-
"name": "param",
|
|
100
|
-
"text": "options - The options to set the window background color."
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"name": "param",
|
|
104
|
-
"text": "options.color - The background color in HEX format."
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
"docs": "Set the window background color.",
|
|
108
|
-
"complexTypes": [
|
|
109
|
-
"StatusBarSetBackgroundOptions"
|
|
110
|
-
],
|
|
111
|
-
"slug": "setbackground"
|
|
112
|
-
},
|
|
113
86
|
{
|
|
114
87
|
"name": "showNavigationBar",
|
|
115
88
|
"signature": "() => Promise<void>",
|
|
@@ -241,19 +214,6 @@
|
|
|
241
214
|
}
|
|
242
215
|
]
|
|
243
216
|
},
|
|
244
|
-
{
|
|
245
|
-
"name": "StatusBarSetBackgroundOptions",
|
|
246
|
-
"slug": "statusbarsetbackgroundoptions",
|
|
247
|
-
"docs": "",
|
|
248
|
-
"types": [
|
|
249
|
-
{
|
|
250
|
-
"text": "{\n color: StatusBarColor;\n}",
|
|
251
|
-
"complexTypes": [
|
|
252
|
-
"StatusBarColor"
|
|
253
|
-
]
|
|
254
|
-
}
|
|
255
|
-
]
|
|
256
|
-
},
|
|
257
217
|
{
|
|
258
218
|
"name": "SafeAreaInsets",
|
|
259
219
|
"slug": "safeareainsets",
|
|
@@ -27,9 +27,6 @@ export declare type StatusBarOptions = StatusBarStyleOptions;
|
|
|
27
27
|
export declare type StatusBarSetOverlaysWebViewOptions = {
|
|
28
28
|
value: boolean;
|
|
29
29
|
};
|
|
30
|
-
export declare type StatusBarSetBackgroundOptions = {
|
|
31
|
-
color: StatusBarColor;
|
|
32
|
-
};
|
|
33
30
|
export declare type SafeAreaInsets = {
|
|
34
31
|
top: number;
|
|
35
32
|
bottom: number;
|
|
@@ -66,12 +63,6 @@ export interface CapacitorStatusBarPlugin {
|
|
|
66
63
|
* @param options.value - Whether the status bar overlays the web view (required).
|
|
67
64
|
*/
|
|
68
65
|
setOverlaysWebView(options: StatusBarSetOverlaysWebViewOptions): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Set the window background color.
|
|
71
|
-
* @param options - The options to set the window background color.
|
|
72
|
-
* @param options.color - The background color in HEX format.
|
|
73
|
-
*/
|
|
74
|
-
setBackground(options: StatusBarSetBackgroundOptions): Promise<void>;
|
|
75
66
|
/**
|
|
76
67
|
* Show the navigation bar.
|
|
77
68
|
*/
|
|
@@ -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 StatusBarSetOverlaysWebViewOptions = {\n value: boolean;\n};\n\nexport type
|
|
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 StatusBarSetOverlaysWebViewOptions = {\n value: boolean;\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 and navigation bar.\n */\n show(): Promise<void>;\n /**\n * Hide the status bar and navigation bar with a slide animation.\n */\n hide(): 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 * Show the navigation bar.\n */\n showNavigationBar(): Promise<void>;\n /**\n * Hide the navigation bar with a slide animation (hides completely from screen).\n */\n hideNavigationBar(): 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,11 +1,10 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { StatusBarOptions, CapacitorStatusBarPlugin, StatusBarSetOverlaysWebViewOptions,
|
|
2
|
+
import type { StatusBarOptions, CapacitorStatusBarPlugin, StatusBarSetOverlaysWebViewOptions, SafeAreaInsets } from './definitions';
|
|
3
3
|
export declare class CapacitorStatusBarWeb extends WebPlugin implements CapacitorStatusBarPlugin {
|
|
4
4
|
setStyle(options: StatusBarOptions): Promise<void>;
|
|
5
5
|
show(): Promise<void>;
|
|
6
6
|
hide(): Promise<void>;
|
|
7
7
|
setOverlaysWebView(options: StatusBarSetOverlaysWebViewOptions): Promise<void>;
|
|
8
|
-
setBackground(options: StatusBarSetBackgroundOptions): Promise<void>;
|
|
9
8
|
showNavigationBar(): Promise<void>;
|
|
10
9
|
hideNavigationBar(): Promise<void>;
|
|
11
10
|
getSafeAreaInsets(): Promise<SafeAreaInsets>;
|
package/dist/esm/web.js
CHANGED
|
@@ -12,9 +12,6 @@ export class CapacitorStatusBarWeb extends WebPlugin {
|
|
|
12
12
|
async setOverlaysWebView(options) {
|
|
13
13
|
console.log('setOverlaysWebView', options);
|
|
14
14
|
}
|
|
15
|
-
async setBackground(options) {
|
|
16
|
-
console.log('setBackground', options);
|
|
17
|
-
}
|
|
18
15
|
async showNavigationBar() {
|
|
19
16
|
console.log('showNavigationBar');
|
|
20
17
|
}
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,qBAAsB,SAAQ,SAAS;IAClD,KAAK,CAAC,QAAQ,CAAC,OAAyB;QACtC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,OAA2C;QAClE,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,uEAAuE;QACvE,6DAA6D;QAC7D,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAU,EAAE;YACjD,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;YAC3F,OAAO,KAAK,CAAC,CAAC,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 SafeAreaInsets,\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(): Promise<void> {\n console.log('show');\n }\n\n async hide(): Promise<void> {\n console.log('hide');\n }\n\n async setOverlaysWebView(options: StatusBarSetOverlaysWebViewOptions): Promise<void> {\n console.log('setOverlaysWebView', options);\n }\n\n async showNavigationBar(): Promise<void> {\n console.log('showNavigationBar');\n }\n\n async hideNavigationBar(): Promise<void> {\n console.log('hideNavigationBar');\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
|
@@ -32,9 +32,6 @@ class CapacitorStatusBarWeb extends core.WebPlugin {
|
|
|
32
32
|
async setOverlaysWebView(options) {
|
|
33
33
|
console.log('setOverlaysWebView', options);
|
|
34
34
|
}
|
|
35
|
-
async setBackground(options) {
|
|
36
|
-
console.log('setBackground', options);
|
|
37
|
-
}
|
|
38
35
|
async showNavigationBar() {
|
|
39
36
|
console.log('showNavigationBar');
|
|
40
37
|
}
|
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() {\n console.log('show');\n }\n async hide() {\n console.log('hide');\n }\n async setOverlaysWebView(options) {\n console.log('setOverlaysWebView', options);\n }\n async
|
|
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() {\n console.log('show');\n }\n async hide() {\n console.log('hide');\n }\n async setOverlaysWebView(options) {\n console.log('setOverlaysWebView', options);\n }\n async showNavigationBar() {\n console.log('showNavigationBar');\n }\n async hideNavigationBar() {\n console.log('hideNavigationBar');\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/B,IAAI,kBAAkB,CAAC,MAAM,CAAC,GAAG,MAAM;AACvC,IAAI,kBAAkB,CAAC,MAAM,CAAC,GAAG,MAAM;AACvC,IAAI,kBAAkB,CAAC,OAAO,CAAC,GAAG,OAAO;AACzC,CAAC,EAAEA,0BAAkB,KAAKA,0BAAkB,GAAG,EAAE,CAAC,CAAC;;ACV9C,MAAC,kBAAkB,GAAGC,mBAAc,CAAC,oBAAoB,EAAE;AAChE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,qBAAqB,EAAE,CAAC;AACzE,CAAC;;ACFM,MAAM,qBAAqB,SAASC,cAAS,CAAC;AACrD,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;AAC5B,QAAQ,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC;AACxC,IAAI;AACJ,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;AAC3B,IAAI;AACJ,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;AAC3B,IAAI;AACJ,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE;AACtC,QAAQ,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC;AAClD,IAAI;AACJ,IAAI,MAAM,iBAAiB,GAAG;AAC9B,QAAQ,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;AACxC,IAAI;AACJ,IAAI,MAAM,iBAAiB,GAAG;AAC9B,QAAQ,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;AACxC,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
|
@@ -31,9 +31,6 @@ var capStatusBar = (function (exports, core) {
|
|
|
31
31
|
async setOverlaysWebView(options) {
|
|
32
32
|
console.log('setOverlaysWebView', options);
|
|
33
33
|
}
|
|
34
|
-
async setBackground(options) {
|
|
35
|
-
console.log('setBackground', options);
|
|
36
|
-
}
|
|
37
34
|
async showNavigationBar() {
|
|
38
35
|
console.log('showNavigationBar');
|
|
39
36
|
}
|
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() {\n console.log('show');\n }\n async hide() {\n console.log('hide');\n }\n async setOverlaysWebView(options) {\n console.log('setOverlaysWebView', options);\n }\n async
|
|
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() {\n console.log('show');\n }\n async hide() {\n console.log('hide');\n }\n async setOverlaysWebView(options) {\n console.log('setOverlaysWebView', options);\n }\n async showNavigationBar() {\n console.log('showNavigationBar');\n }\n async hideNavigationBar() {\n console.log('hideNavigationBar');\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,GAAG;IACjB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;IAC3B,IAAI;IACJ,IAAI,MAAM,IAAI,GAAG;IACjB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;IAC3B,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE;IACtC,QAAQ,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC;IAClD,IAAI;IACJ,IAAI,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IACxC,IAAI;IACJ,IAAI,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IACxC,IAAI;IACJ,IAAI,MAAM,iBAAiB,GAAG;IAC9B;IACA;IACA,QAAQ,MAAM,aAAa,GAAG,CAAC,QAAQ,KAAK;IAC5C,YAAY,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE;IACtG,YAAY,OAAO,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC;IAClD,QAAQ,CAAC;IACT,QAAQ,MAAM,MAAM,GAAG;IACvB,YAAY,GAAG,EAAE,aAAa,CAAC,0BAA0B,CAAC,IAAI,aAAa,CAAC,+BAA+B,CAAC,IAAI,CAAC;IACjH,YAAY,MAAM,EAAE,aAAa,CAAC,6BAA6B,CAAC,IAAI,aAAa,CAAC,kCAAkC,CAAC,IAAI,CAAC;IAC1H,YAAY,IAAI,EAAE,aAAa,CAAC,2BAA2B,CAAC,IAAI,aAAa,CAAC,gCAAgC,CAAC,IAAI,CAAC;IACpH,YAAY,KAAK,EAAE,aAAa,CAAC,4BAA4B,CAAC,IAAI,aAAa,CAAC,iCAAiC,CAAC,IAAI,CAAC;IACvH,SAAS;IACT,QAAQ,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC;IAChD,QAAQ,OAAO,MAAM;IACrB,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -9,6 +9,12 @@ import Capacitor
|
|
|
9
9
|
private var currentBackgroundColor: UIColor?
|
|
10
10
|
// Track whether overlays web view mode is active
|
|
11
11
|
private var isOverlayMode = false
|
|
12
|
+
// Keep a weak reference to the Capacitor WKWebView for layout updates
|
|
13
|
+
private weak var webView: UIView?
|
|
14
|
+
|
|
15
|
+
@objc public func setWebView(_ webView: UIView?) {
|
|
16
|
+
self.webView = webView
|
|
17
|
+
}
|
|
12
18
|
|
|
13
19
|
@objc public func applyDefaultStyle() {
|
|
14
20
|
DispatchQueue.main.async {
|
|
@@ -19,11 +25,14 @@ import Capacitor
|
|
|
19
25
|
}
|
|
20
26
|
}
|
|
21
27
|
|
|
22
|
-
@objc public func setStyle(style: String, colorHex: String?) {
|
|
28
|
+
@objc public func setStyle(style: String, colorHex: String?, completion: (() -> Void)? = nil) {
|
|
23
29
|
DispatchQueue.main.async {
|
|
30
|
+
defer { completion?() }
|
|
31
|
+
|
|
24
32
|
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else { return }
|
|
25
33
|
guard let window = windowScene.windows.first else { return }
|
|
26
34
|
guard let statusBarManager = windowScene.statusBarManager else { return }
|
|
35
|
+
guard let rootVC = window.rootViewController else { return }
|
|
27
36
|
|
|
28
37
|
let upperStyle = style.uppercased()
|
|
29
38
|
var backgroundColor: UIColor?
|
|
@@ -31,33 +40,29 @@ import Capacitor
|
|
|
31
40
|
|
|
32
41
|
// Determine the status bar style and background color
|
|
33
42
|
if upperStyle == "LIGHT" {
|
|
34
|
-
// Light style: light background with dark content
|
|
35
43
|
statusBarStyle = .darkContent
|
|
36
44
|
backgroundColor = .white
|
|
37
45
|
} else if upperStyle == "DARK" {
|
|
38
|
-
// Dark style: dark background with light content
|
|
39
46
|
statusBarStyle = .lightContent
|
|
40
47
|
backgroundColor = .black
|
|
41
48
|
} else if upperStyle == "CUSTOM" {
|
|
42
|
-
// Custom style: use provided color and determine content style based on brightness
|
|
43
49
|
if let colorHex = colorHex, let color = self.colorFromHex(colorHex) {
|
|
44
50
|
backgroundColor = color
|
|
45
51
|
let brightness = self.getColorBrightness(color)
|
|
46
|
-
// If background is light, use dark content; if dark, use light content
|
|
47
52
|
statusBarStyle = brightness > 0.5 ? .darkContent : .lightContent
|
|
48
53
|
} else {
|
|
49
|
-
// No color provided, use system default
|
|
50
54
|
statusBarStyle = .default
|
|
51
55
|
backgroundColor = nil
|
|
52
56
|
}
|
|
53
57
|
} else {
|
|
54
|
-
// Default: use system default
|
|
55
58
|
statusBarStyle = .default
|
|
56
59
|
backgroundColor = nil
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
// Set the status bar style
|
|
60
|
-
|
|
62
|
+
// Set the status bar style via swizzled preferredStatusBarStyle
|
|
63
|
+
CapacitorStatusBar.swizzleStatusBarStyleIfNeeded()
|
|
64
|
+
CapacitorStatusBar.currentStatusBarStyle = statusBarStyle
|
|
65
|
+
rootVC.setNeedsStatusBarAppearanceUpdate()
|
|
61
66
|
|
|
62
67
|
// Store the background color for later restoration
|
|
63
68
|
self.currentBackgroundColor = backgroundColor
|
|
@@ -66,7 +71,6 @@ import Capacitor
|
|
|
66
71
|
if self.isOverlayMode {
|
|
67
72
|
print("CapacitorStatusBar: setStyle - overlay mode active, skipping background color")
|
|
68
73
|
} else {
|
|
69
|
-
// Create or update the status bar background view
|
|
70
74
|
self.updateStatusBarBackgroundView(in: window,
|
|
71
75
|
height: statusBarManager.statusBarFrame.height,
|
|
72
76
|
color: backgroundColor)
|
|
@@ -76,78 +80,78 @@ import Capacitor
|
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
@objc public func show(animated: Bool) {
|
|
83
|
+
@objc public func show(animated: Bool, completion: (() -> Void)? = nil) {
|
|
80
84
|
DispatchQueue.main.async {
|
|
81
|
-
|
|
82
|
-
// This plugin requires UIViewControllerBasedStatusBarAppearance to be set to NO
|
|
83
|
-
// in the app's Info.plist for programmatic show/hide to work.
|
|
85
|
+
defer { completion?() }
|
|
84
86
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
88
|
+
let window = windowScene.windows.first,
|
|
89
|
+
let rootVC = window.rootViewController else { return }
|
|
90
|
+
|
|
91
|
+
if let statusBarManager = windowScene.statusBarManager {
|
|
88
92
|
print("CapacitorStatusBar: show() - Current hidden state: \(statusBarManager.isStatusBarHidden)")
|
|
89
93
|
}
|
|
90
94
|
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
// Show status bar via swizzled prefersStatusBarHidden
|
|
96
|
+
CapacitorStatusBar.swizzleStatusBarVisibilityIfNeeded()
|
|
97
|
+
CapacitorStatusBar.currentStatusBarHidden = false
|
|
98
|
+
rootVC.setNeedsStatusBarAppearanceUpdate()
|
|
94
99
|
|
|
95
100
|
// Restore the background view color when showing (unless overlay mode is active)
|
|
96
101
|
if !self.isOverlayMode {
|
|
97
102
|
self.restoreStatusBarBackgroundColor()
|
|
98
103
|
}
|
|
99
104
|
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
self.updateWebViewLayout()
|
|
106
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
|
107
|
+
self.updateWebViewLayout()
|
|
108
|
+
}
|
|
102
109
|
}
|
|
103
110
|
}
|
|
104
111
|
|
|
105
|
-
@objc public func hide(animation: String) {
|
|
112
|
+
@objc public func hide(animation: String, completion: (() -> Void)? = nil) {
|
|
106
113
|
DispatchQueue.main.async {
|
|
114
|
+
defer { completion?() }
|
|
115
|
+
|
|
107
116
|
let animationType = animation.lowercased()
|
|
108
117
|
|
|
109
|
-
// Log current status bar state via status bar manager
|
|
110
118
|
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
111
119
|
let statusBarManager = windowScene.statusBarManager {
|
|
112
120
|
print("CapacitorStatusBar: hide() - animation=\(animationType), Current hidden state: \(statusBarManager.isStatusBarHidden)")
|
|
113
121
|
}
|
|
114
122
|
|
|
115
123
|
if animationType == "fade" {
|
|
116
|
-
// Fade mode: Make background transparent without
|
|
124
|
+
// Fade mode: Make background transparent without hiding status bar
|
|
117
125
|
print("CapacitorStatusBar: hide() - fade mode: making background transparent")
|
|
118
126
|
self.makeStatusBarBackgroundTransparent()
|
|
119
|
-
self.hideNavigationBar(animation: "fade")
|
|
120
|
-
} else if animationType == "slide" {
|
|
121
|
-
// Slide mode: Hide the status bar completely (current behavior)
|
|
122
|
-
print("CapacitorStatusBar: hide() - slide mode: hiding bars completely")
|
|
123
|
-
// Note: Status bar visibility is controlled through view controllers in modern iOS.
|
|
124
|
-
// This plugin requires UIViewControllerBasedStatusBarAppearance to be set to NO
|
|
125
|
-
// in the app's Info.plist for programmatic show/hide to work.
|
|
126
|
-
self.setStatusBarVisibility(hidden: true, animated: true)
|
|
127
|
-
// Also make the background view transparent when hiding
|
|
128
|
-
self.makeStatusBarBackgroundTransparent()
|
|
129
|
-
self.hideNavigationBar(animation: "slide")
|
|
130
127
|
} else {
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
// Slide mode (default): Hide the status bar completely
|
|
129
|
+
if animationType != "slide" {
|
|
130
|
+
print("CapacitorStatusBar: hide() - unknown animation '\(animationType)', defaulting to slide")
|
|
131
|
+
} else {
|
|
132
|
+
print("CapacitorStatusBar: hide() - slide mode: hiding status bar")
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
136
|
+
let window = windowScene.windows.first,
|
|
137
|
+
let rootVC = window.rootViewController else { return }
|
|
138
|
+
|
|
139
|
+
CapacitorStatusBar.swizzleStatusBarVisibilityIfNeeded()
|
|
140
|
+
CapacitorStatusBar.currentStatusBarHidden = true
|
|
141
|
+
rootVC.setNeedsStatusBarAppearanceUpdate()
|
|
142
|
+
|
|
133
143
|
self.makeStatusBarBackgroundTransparent()
|
|
134
|
-
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
self.updateWebViewLayout()
|
|
147
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
|
148
|
+
self.updateWebViewLayout()
|
|
135
149
|
}
|
|
136
150
|
}
|
|
137
151
|
}
|
|
138
152
|
|
|
139
153
|
// MARK: - Private Methods
|
|
140
154
|
|
|
141
|
-
/// Sets the status bar visibility.
|
|
142
|
-
/// - Parameters:
|
|
143
|
-
/// - hidden: Whether the status bar should be hidden
|
|
144
|
-
/// - animated: Whether the change should be animated
|
|
145
|
-
private func setStatusBarVisibility(hidden: Bool, animated: Bool) {
|
|
146
|
-
// Use KVC to set status bar state without triggering deprecation warnings
|
|
147
|
-
// This approach is necessary when UIViewControllerBasedStatusBarAppearance is NO
|
|
148
|
-
UIApplication.shared.setValue(hidden, forKey: "statusBarHidden")
|
|
149
|
-
}
|
|
150
|
-
|
|
151
155
|
/// Updates or creates the status bar background view with the specified color.
|
|
152
156
|
/// - Parameters:
|
|
153
157
|
/// - window: The window where the status bar view will be added
|
|
@@ -182,8 +186,10 @@ import Capacitor
|
|
|
182
186
|
}
|
|
183
187
|
}
|
|
184
188
|
|
|
185
|
-
@objc public func setOverlaysWebView(value: Bool) {
|
|
189
|
+
@objc public func setOverlaysWebView(value: Bool, completion: (() -> Void)? = nil) {
|
|
186
190
|
DispatchQueue.main.async {
|
|
191
|
+
defer { completion?() }
|
|
192
|
+
|
|
187
193
|
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
188
194
|
let window = windowScene.windows.first,
|
|
189
195
|
let statusBarManager = windowScene.statusBarManager else {
|
|
@@ -194,41 +200,25 @@ import Capacitor
|
|
|
194
200
|
self.isOverlayMode = value
|
|
195
201
|
|
|
196
202
|
if value {
|
|
197
|
-
// Overlay mode: make the status bar background transparent so web content shows through
|
|
198
203
|
let statusBarView = window.viewWithTag(CapacitorStatusBar.statusBarViewTag)
|
|
199
204
|
statusBarView?.backgroundColor = .clear
|
|
200
205
|
print("CapacitorStatusBar: setOverlaysWebView(true) - content extends behind status bar")
|
|
201
206
|
} else {
|
|
202
|
-
// Non-overlay mode: restore the status bar background from the current style
|
|
203
207
|
if let color = self.currentBackgroundColor {
|
|
204
208
|
self.updateStatusBarBackgroundView(in: window,
|
|
205
209
|
height: statusBarManager.statusBarFrame.height,
|
|
206
210
|
color: color)
|
|
207
211
|
print("CapacitorStatusBar: setOverlaysWebView(false) - restored background color")
|
|
208
212
|
} else {
|
|
209
|
-
// No style was set; apply default style based on system theme
|
|
210
213
|
self.applyDefaultStyle()
|
|
211
214
|
print("CapacitorStatusBar: setOverlaysWebView(false) - applied default style from config")
|
|
212
215
|
}
|
|
213
216
|
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
@objc public func setBackground(colorHex: String?) {
|
|
218
|
-
DispatchQueue.main.async {
|
|
219
|
-
guard let colorHex = colorHex, let color = self.colorFromHex(colorHex) else {
|
|
220
|
-
print("CapacitorStatusBar: setBackground - Invalid color or nil")
|
|
221
|
-
return
|
|
222
|
-
}
|
|
223
217
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
return
|
|
218
|
+
self.updateWebViewLayout()
|
|
219
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
|
220
|
+
self.updateWebViewLayout()
|
|
228
221
|
}
|
|
229
|
-
|
|
230
|
-
window.backgroundColor = .clear
|
|
231
|
-
print("CapacitorStatusBar: setBackground - Body is always transparent; status/nav bars use overlays/native APIs")
|
|
232
222
|
}
|
|
233
223
|
}
|
|
234
224
|
|
|
@@ -241,11 +231,14 @@ import Capacitor
|
|
|
241
231
|
let safeAreaInsets = window.safeAreaInsets
|
|
242
232
|
|
|
243
233
|
insets["top"] = self.sanitizedInsetValue(safeAreaInsets.top)
|
|
244
|
-
|
|
234
|
+
let homeIndicatorHeight: CGFloat = safeAreaInsets.bottom > 0
|
|
235
|
+
? min(13.0, safeAreaInsets.bottom)
|
|
236
|
+
: 0
|
|
237
|
+
insets["bottom"] = self.sanitizedInsetValue(homeIndicatorHeight)
|
|
245
238
|
insets["left"] = 0
|
|
246
239
|
insets["right"] = 0
|
|
247
240
|
|
|
248
|
-
print("CapacitorStatusBar: getSafeAreaInsets - top=\(safeAreaInsets.top), bottom=\(safeAreaInsets.bottom), left=\(safeAreaInsets.left), right=\(safeAreaInsets.right)")
|
|
241
|
+
print("CapacitorStatusBar: getSafeAreaInsets - top=\(safeAreaInsets.top), bottom=\(homeIndicatorHeight) (raw: \(safeAreaInsets.bottom)), left=\(safeAreaInsets.left), right=\(safeAreaInsets.right)")
|
|
249
242
|
} else {
|
|
250
243
|
print("CapacitorStatusBar: getSafeAreaInsets - Unable to get window, returning zero insets")
|
|
251
244
|
}
|
|
@@ -259,8 +252,10 @@ import Capacitor
|
|
|
259
252
|
/// Shared flag read by the swizzled `prefersHomeIndicatorAutoHidden` override.
|
|
260
253
|
static var homeIndicatorHidden = false
|
|
261
254
|
|
|
262
|
-
@objc public func showNavigationBar(animated: Bool) {
|
|
255
|
+
@objc public func showNavigationBar(animated: Bool, completion: (() -> Void)? = nil) {
|
|
263
256
|
DispatchQueue.main.async {
|
|
257
|
+
defer { completion?() }
|
|
258
|
+
|
|
264
259
|
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
265
260
|
let window = windowScene.windows.first,
|
|
266
261
|
let rootVC = window.rootViewController else {
|
|
@@ -273,11 +268,17 @@ import Capacitor
|
|
|
273
268
|
rootVC.setNeedsUpdateOfHomeIndicatorAutoHidden()
|
|
274
269
|
|
|
275
270
|
print("CapacitorStatusBar: showNavigationBar - animated=\(animated)")
|
|
271
|
+
self.updateWebViewLayout()
|
|
272
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
|
273
|
+
self.updateWebViewLayout()
|
|
274
|
+
}
|
|
276
275
|
}
|
|
277
276
|
}
|
|
278
277
|
|
|
279
|
-
@objc public func hideNavigationBar(animation: String) {
|
|
278
|
+
@objc public func hideNavigationBar(animation: String, completion: (() -> Void)? = nil) {
|
|
280
279
|
DispatchQueue.main.async {
|
|
280
|
+
defer { completion?() }
|
|
281
|
+
|
|
281
282
|
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
282
283
|
let window = windowScene.windows.first,
|
|
283
284
|
let rootVC = window.rootViewController else {
|
|
@@ -291,24 +292,82 @@ import Capacitor
|
|
|
291
292
|
rootVC.setNeedsUpdateOfHomeIndicatorAutoHidden()
|
|
292
293
|
|
|
293
294
|
print("CapacitorStatusBar: hideNavigationBar - animation=\(animationType)")
|
|
295
|
+
self.updateWebViewLayout()
|
|
296
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
|
297
|
+
self.updateWebViewLayout()
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// MARK: - Swizzling
|
|
303
|
+
|
|
304
|
+
private static var hasSwizzledHomeIndicator = false
|
|
305
|
+
private static var hasSwizzledStatusBarStyle = false
|
|
306
|
+
private static var hasSwizzledStatusBarVisibility = false
|
|
307
|
+
|
|
308
|
+
/// Current status bar style, read by the swizzled `preferredStatusBarStyle` override.
|
|
309
|
+
static var currentStatusBarStyle: UIStatusBarStyle = .default
|
|
310
|
+
|
|
311
|
+
/// Current status bar hidden state, read by the swizzled `prefersStatusBarHidden` override.
|
|
312
|
+
static var currentStatusBarHidden = false
|
|
313
|
+
|
|
314
|
+
/// Swizzle `preferredStatusBarStyle` so we can control status bar appearance
|
|
315
|
+
/// without using private KVC APIs. Requires UIViewControllerBasedStatusBarAppearance = YES (default).
|
|
316
|
+
static func swizzleStatusBarStyleIfNeeded() {
|
|
317
|
+
guard !hasSwizzledStatusBarStyle else { return }
|
|
318
|
+
hasSwizzledStatusBarStyle = true
|
|
319
|
+
|
|
320
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
321
|
+
let window = windowScene.windows.first,
|
|
322
|
+
let rootVC = window.rootViewController else { return }
|
|
323
|
+
|
|
324
|
+
let vcClass: AnyClass = type(of: rootVC)
|
|
325
|
+
let originalSelector = #selector(getter: UIViewController.preferredStatusBarStyle)
|
|
326
|
+
let swizzledSelector = #selector(UIViewController.capsb_preferredStatusBarStyle)
|
|
327
|
+
|
|
328
|
+
guard let originalMethod = class_getInstanceMethod(vcClass, originalSelector),
|
|
329
|
+
let swizzledMethod = class_getInstanceMethod(UIViewController.self, swizzledSelector) else {
|
|
330
|
+
print("CapacitorStatusBar: Failed to swizzle preferredStatusBarStyle")
|
|
331
|
+
return
|
|
294
332
|
}
|
|
333
|
+
|
|
334
|
+
method_exchangeImplementations(originalMethod, swizzledMethod)
|
|
335
|
+
print("CapacitorStatusBar: Swizzled preferredStatusBarStyle on \(vcClass)")
|
|
295
336
|
}
|
|
296
337
|
|
|
297
|
-
|
|
338
|
+
/// Swizzle `prefersStatusBarHidden` so we can control status bar visibility
|
|
339
|
+
/// without using private KVC APIs. Requires UIViewControllerBasedStatusBarAppearance = YES (default).
|
|
340
|
+
static func swizzleStatusBarVisibilityIfNeeded() {
|
|
341
|
+
guard !hasSwizzledStatusBarVisibility else { return }
|
|
342
|
+
hasSwizzledStatusBarVisibility = true
|
|
343
|
+
|
|
344
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
345
|
+
let window = windowScene.windows.first,
|
|
346
|
+
let rootVC = window.rootViewController else { return }
|
|
347
|
+
|
|
348
|
+
let vcClass: AnyClass = type(of: rootVC)
|
|
349
|
+
let originalSelector = #selector(getter: UIViewController.prefersStatusBarHidden)
|
|
350
|
+
let swizzledSelector = #selector(UIViewController.capsb_prefersStatusBarHidden)
|
|
298
351
|
|
|
299
|
-
|
|
352
|
+
guard let originalMethod = class_getInstanceMethod(vcClass, originalSelector),
|
|
353
|
+
let swizzledMethod = class_getInstanceMethod(UIViewController.self, swizzledSelector) else {
|
|
354
|
+
print("CapacitorStatusBar: Failed to swizzle prefersStatusBarHidden")
|
|
355
|
+
return
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
method_exchangeImplementations(originalMethod, swizzledMethod)
|
|
359
|
+
print("CapacitorStatusBar: Swizzled prefersStatusBarHidden on \(vcClass)")
|
|
360
|
+
}
|
|
300
361
|
|
|
301
362
|
/// Swizzle `prefersHomeIndicatorAutoHidden` on the root view controller so we
|
|
302
363
|
/// can control the home indicator visibility from the plugin.
|
|
303
364
|
static func swizzleHomeIndicatorIfNeeded() {
|
|
304
|
-
guard !
|
|
305
|
-
|
|
365
|
+
guard !hasSwizzledHomeIndicator else { return }
|
|
366
|
+
hasSwizzledHomeIndicator = true
|
|
306
367
|
|
|
307
368
|
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
308
369
|
let window = windowScene.windows.first,
|
|
309
|
-
let rootVC = window.rootViewController else {
|
|
310
|
-
return
|
|
311
|
-
}
|
|
370
|
+
let rootVC = window.rootViewController else { return }
|
|
312
371
|
|
|
313
372
|
let vcClass: AnyClass = type(of: rootVC)
|
|
314
373
|
let originalSelector = #selector(getter: UIViewController.prefersHomeIndicatorAutoHidden)
|
|
@@ -336,6 +395,37 @@ import Capacitor
|
|
|
336
395
|
print("CapacitorStatusBar: Made background transparent")
|
|
337
396
|
}
|
|
338
397
|
|
|
398
|
+
/// Updates WebView frame to respect overlay mode behavior.
|
|
399
|
+
/// - overlay mode true: content extends edge-to-edge (no reserved top/bottom)
|
|
400
|
+
/// - overlay mode false: content is inset away from status/home-indicator areas
|
|
401
|
+
private func updateWebViewLayout() {
|
|
402
|
+
guard let webView = self.webView else {
|
|
403
|
+
print("CapacitorStatusBar: updateWebViewLayout - WebView unavailable")
|
|
404
|
+
return
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
guard let window = webView.window
|
|
408
|
+
?? (UIApplication.shared.connectedScenes.first as? UIWindowScene)?
|
|
409
|
+
.windows.first(where: { $0.isKeyWindow })
|
|
410
|
+
?? (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.windows.first else {
|
|
411
|
+
print("CapacitorStatusBar: updateWebViewLayout - Unable to resolve window")
|
|
412
|
+
return
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
let safeAreaInsets = window.safeAreaInsets
|
|
416
|
+
let topInset: CGFloat = isOverlayMode ? 0 : sanitizedInsetValue(safeAreaInsets.top)
|
|
417
|
+
let bottomInset: CGFloat = isOverlayMode ? 0 : sanitizedInsetValue(safeAreaInsets.bottom)
|
|
418
|
+
|
|
419
|
+
var frame = window.bounds
|
|
420
|
+
frame.origin.y = topInset
|
|
421
|
+
frame.size.height = max(0, frame.size.height - topInset - bottomInset)
|
|
422
|
+
|
|
423
|
+
if webView.frame != frame {
|
|
424
|
+
webView.frame = frame
|
|
425
|
+
print("CapacitorStatusBar: updateWebViewLayout - topInset=\(topInset), bottomInset=\(bottomInset), frame=\(frame)")
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
339
429
|
/// Restores the status bar background view to its original color
|
|
340
430
|
private func restoreStatusBarBackgroundColor() {
|
|
341
431
|
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
@@ -412,6 +502,14 @@ import Capacitor
|
|
|
412
502
|
// MARK: - UIViewController extension for home indicator swizzling
|
|
413
503
|
|
|
414
504
|
extension UIViewController {
|
|
505
|
+
@objc func capsb_preferredStatusBarStyle() -> UIStatusBarStyle {
|
|
506
|
+
return CapacitorStatusBar.currentStatusBarStyle
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
@objc func capsb_prefersStatusBarHidden() -> Bool {
|
|
510
|
+
return CapacitorStatusBar.currentStatusBarHidden
|
|
511
|
+
}
|
|
512
|
+
|
|
415
513
|
@objc func capsb_prefersHomeIndicatorAutoHidden() -> Bool {
|
|
416
514
|
return CapacitorStatusBar.homeIndicatorHidden
|
|
417
515
|
}
|
|
@@ -14,7 +14,6 @@ public class CapacitorStatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
14
14
|
CAPPluginMethod(name: "show", returnType: CAPPluginReturnPromise),
|
|
15
15
|
CAPPluginMethod(name: "hide", returnType: CAPPluginReturnPromise),
|
|
16
16
|
CAPPluginMethod(name: "setOverlaysWebView", returnType: CAPPluginReturnPromise),
|
|
17
|
-
CAPPluginMethod(name: "setBackground", returnType: CAPPluginReturnPromise),
|
|
18
17
|
CAPPluginMethod(name: "showNavigationBar", returnType: CAPPluginReturnPromise),
|
|
19
18
|
CAPPluginMethod(name: "hideNavigationBar", returnType: CAPPluginReturnPromise),
|
|
20
19
|
CAPPluginMethod(name: "getSafeAreaInsets", returnType: CAPPluginReturnPromise)
|
|
@@ -23,6 +22,7 @@ public class CapacitorStatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
23
22
|
|
|
24
23
|
override public func load() {
|
|
25
24
|
super.load()
|
|
25
|
+
implementation.setWebView(bridge?.webView)
|
|
26
26
|
// Apply default style based on system theme on plugin load
|
|
27
27
|
implementation.applyDefaultStyle()
|
|
28
28
|
}
|
|
@@ -33,18 +33,21 @@ public class CapacitorStatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
33
33
|
return
|
|
34
34
|
}
|
|
35
35
|
let color = call.getString("color")
|
|
36
|
-
implementation.setStyle(style: style, colorHex: color)
|
|
37
|
-
|
|
36
|
+
implementation.setStyle(style: style, colorHex: color) {
|
|
37
|
+
call.resolve()
|
|
38
|
+
}
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
@objc func show(_ call: CAPPluginCall) {
|
|
41
|
-
implementation.show(animated: true)
|
|
42
|
-
|
|
42
|
+
implementation.show(animated: true) {
|
|
43
|
+
call.resolve()
|
|
44
|
+
}
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
@objc func hide(_ call: CAPPluginCall) {
|
|
46
|
-
implementation.hide(animation: "slide")
|
|
47
|
-
|
|
48
|
+
implementation.hide(animation: "slide") {
|
|
49
|
+
call.resolve()
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
@objc func setOverlaysWebView(_ call: CAPPluginCall) {
|
|
@@ -52,27 +55,21 @@ public class CapacitorStatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
52
55
|
call.reject("value is required")
|
|
53
56
|
return
|
|
54
57
|
}
|
|
55
|
-
implementation.setOverlaysWebView(value: value)
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@objc func setBackground(_ call: CAPPluginCall) {
|
|
60
|
-
guard let color = call.getString("color") else {
|
|
61
|
-
call.reject("color is required")
|
|
62
|
-
return
|
|
58
|
+
implementation.setOverlaysWebView(value: value) {
|
|
59
|
+
call.resolve()
|
|
63
60
|
}
|
|
64
|
-
implementation.setBackground(colorHex: color)
|
|
65
|
-
call.resolve()
|
|
66
61
|
}
|
|
67
62
|
|
|
68
63
|
@objc func showNavigationBar(_ call: CAPPluginCall) {
|
|
69
|
-
implementation.showNavigationBar(animated: true)
|
|
70
|
-
|
|
64
|
+
implementation.showNavigationBar(animated: true) {
|
|
65
|
+
call.resolve()
|
|
66
|
+
}
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
@objc func hideNavigationBar(_ call: CAPPluginCall) {
|
|
74
|
-
implementation.hideNavigationBar(animation: "slide")
|
|
75
|
-
|
|
70
|
+
implementation.hideNavigationBar(animation: "slide") {
|
|
71
|
+
call.resolve()
|
|
72
|
+
}
|
|
76
73
|
}
|
|
77
74
|
|
|
78
75
|
@objc func getSafeAreaInsets(_ call: CAPPluginCall) {
|
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.14",
|
|
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",
|