capacitor-plugin-status-bar 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorPluginStatusBar.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +221 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/cap/plugins/statusbar/StatusBar.java +691 -0
- package/android/src/main/java/com/cap/plugins/statusbar/StatusBarPlugin.java +120 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +332 -0
- package/dist/esm/definitions.d.ts +97 -0
- package/dist/esm/definitions.js +13 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +10 -0
- package/dist/esm/web.js +35 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +62 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +65 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/StatusBarPlugin/StatusBar.swift +325 -0
- package/ios/Sources/StatusBarPlugin/StatusBarPlugin.swift +81 -0
- package/ios/Tests/StatusBarPluginTests/StatusBarPluginTests.swift +15 -0
- package/package.json +99 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
package com.cap.plugins.statusbar;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.Plugin;
|
|
4
|
+
import com.getcapacitor.PluginCall;
|
|
5
|
+
import com.getcapacitor.PluginMethod;
|
|
6
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
7
|
+
|
|
8
|
+
@CapacitorPlugin(name = "StatusBar")
|
|
9
|
+
public class StatusBarPlugin extends Plugin {
|
|
10
|
+
private final StatusBar implementation = new StatusBar();
|
|
11
|
+
|
|
12
|
+
@Override
|
|
13
|
+
public void load() {
|
|
14
|
+
super.load();
|
|
15
|
+
// Apply default style based on system theme on plugin load
|
|
16
|
+
getActivity().runOnUiThread(() -> {
|
|
17
|
+
implementation.ensureEdgeToEdgeConfigured(getActivity());
|
|
18
|
+
implementation.applyDefaultStyle(getActivity());
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@PluginMethod
|
|
23
|
+
public void setStyle(PluginCall call) {
|
|
24
|
+
try {
|
|
25
|
+
String style = call.getString("style");
|
|
26
|
+
String color = call.getString("color");
|
|
27
|
+
if (style == null) {
|
|
28
|
+
call.reject("style is required");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
getActivity().runOnUiThread(() -> {
|
|
32
|
+
implementation.setStyle(getActivity(), style, color);
|
|
33
|
+
call.resolve();
|
|
34
|
+
});
|
|
35
|
+
} catch (Exception e) {
|
|
36
|
+
call.reject(e.getMessage());
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@PluginMethod
|
|
41
|
+
public void show(PluginCall call) {
|
|
42
|
+
try {
|
|
43
|
+
boolean animated = Boolean.TRUE.equals(call.getBoolean("animated", true));
|
|
44
|
+
getActivity().runOnUiThread(() -> {
|
|
45
|
+
implementation.showStatusBar(getActivity(), animated);
|
|
46
|
+
call.resolve();
|
|
47
|
+
});
|
|
48
|
+
} catch (Exception e) {
|
|
49
|
+
call.reject(e.getMessage());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@PluginMethod
|
|
54
|
+
public void hide(PluginCall call) {
|
|
55
|
+
try {
|
|
56
|
+
String animation = call.getString("animation");
|
|
57
|
+
if (animation == null) {
|
|
58
|
+
call.reject("animation is required");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
getActivity().runOnUiThread(() -> {
|
|
62
|
+
implementation.hideStatusBar(getActivity(), animation);
|
|
63
|
+
call.resolve();
|
|
64
|
+
});
|
|
65
|
+
} catch (Exception e) {
|
|
66
|
+
call.reject(e.getMessage());
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@PluginMethod
|
|
71
|
+
public void setOverlaysWebView(PluginCall call) {
|
|
72
|
+
try {
|
|
73
|
+
Boolean value = call.getBoolean("value");
|
|
74
|
+
if (value == null) {
|
|
75
|
+
call.reject("value is required");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
getActivity().runOnUiThread(() -> {
|
|
79
|
+
implementation.setOverlaysWebView(getActivity(), value);
|
|
80
|
+
call.resolve();
|
|
81
|
+
});
|
|
82
|
+
} catch (Exception e) {
|
|
83
|
+
call.reject(e.getMessage());
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@PluginMethod
|
|
88
|
+
public void setBackground(PluginCall call) {
|
|
89
|
+
try {
|
|
90
|
+
String color = call.getString("color");
|
|
91
|
+
if (color == null) {
|
|
92
|
+
call.reject("color is required");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
getActivity().runOnUiThread(() -> {
|
|
96
|
+
implementation.setBackground(getActivity(), color);
|
|
97
|
+
call.resolve();
|
|
98
|
+
});
|
|
99
|
+
} catch (Exception e) {
|
|
100
|
+
call.reject(e.getMessage());
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@PluginMethod
|
|
105
|
+
public void getSafeAreaInsets(PluginCall call) {
|
|
106
|
+
try {
|
|
107
|
+
getActivity().runOnUiThread(() -> {
|
|
108
|
+
java.util.Map<String, Integer> insets = implementation.getSafeAreaInsets(getActivity());
|
|
109
|
+
com.getcapacitor.JSObject result = new com.getcapacitor.JSObject();
|
|
110
|
+
result.put("top", insets.get("top"));
|
|
111
|
+
result.put("bottom", insets.get("bottom"));
|
|
112
|
+
result.put("left", insets.get("left"));
|
|
113
|
+
result.put("right", insets.get("right"));
|
|
114
|
+
call.resolve(result);
|
|
115
|
+
});
|
|
116
|
+
} catch (Exception e) {
|
|
117
|
+
call.reject(e.getMessage());
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "StatusBarPlugin",
|
|
4
|
+
"slug": "statusbarplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "setStyle",
|
|
10
|
+
"signature": "(options: StatusBarOptions) => Promise<void>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "- The options to set the status bar style and color.",
|
|
15
|
+
"type": "StatusBarStyleOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<void>",
|
|
19
|
+
"tags": [
|
|
20
|
+
{
|
|
21
|
+
"name": "param",
|
|
22
|
+
"text": "options - The options to set the status bar style and color."
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "param",
|
|
26
|
+
"text": "options.style - The style of the status bar."
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "param",
|
|
30
|
+
"text": "options.color - The color of the status bar."
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"docs": "Set the status bar and navigation bar style and color.",
|
|
34
|
+
"complexTypes": [
|
|
35
|
+
"StatusBarOptions"
|
|
36
|
+
],
|
|
37
|
+
"slug": "setstyle"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "show",
|
|
41
|
+
"signature": "(options: StatusBarShowOptions) => Promise<void>",
|
|
42
|
+
"parameters": [
|
|
43
|
+
{
|
|
44
|
+
"name": "options",
|
|
45
|
+
"docs": "- The options to show the status bar.",
|
|
46
|
+
"type": "StatusBarShowOptions"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"returns": "Promise<void>",
|
|
50
|
+
"tags": [
|
|
51
|
+
{
|
|
52
|
+
"name": "param",
|
|
53
|
+
"text": "options - The options to show the status bar."
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "param",
|
|
57
|
+
"text": "options.animated - Whether to animate the status bar."
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"docs": "Show the status bar.",
|
|
61
|
+
"complexTypes": [
|
|
62
|
+
"StatusBarShowOptions"
|
|
63
|
+
],
|
|
64
|
+
"slug": "show"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "hide",
|
|
68
|
+
"signature": "(options: StatusBarHideOptions) => Promise<void>",
|
|
69
|
+
"parameters": [
|
|
70
|
+
{
|
|
71
|
+
"name": "options",
|
|
72
|
+
"docs": "- The options to hide the status bar.",
|
|
73
|
+
"type": "StatusBarHideOptions"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"returns": "Promise<void>",
|
|
77
|
+
"tags": [
|
|
78
|
+
{
|
|
79
|
+
"name": "param",
|
|
80
|
+
"text": "options - The options to hide the status bar."
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "param",
|
|
84
|
+
"text": "options.animation - The animation type: 'fade' makes background transparent, 'slide' hides bars completely."
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"docs": "Hide the status bar.",
|
|
88
|
+
"complexTypes": [
|
|
89
|
+
"StatusBarHideOptions"
|
|
90
|
+
],
|
|
91
|
+
"slug": "hide"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "setOverlaysWebView",
|
|
95
|
+
"signature": "(options: StatusBarSetOverlaysWebViewOptions) => Promise<void>",
|
|
96
|
+
"parameters": [
|
|
97
|
+
{
|
|
98
|
+
"name": "options",
|
|
99
|
+
"docs": "- The options to set the status bar overlays web view.",
|
|
100
|
+
"type": "StatusBarSetOverlaysWebViewOptions"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"returns": "Promise<void>",
|
|
104
|
+
"tags": [
|
|
105
|
+
{
|
|
106
|
+
"name": "param",
|
|
107
|
+
"text": "options - The options to set the status bar overlays web view."
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "param",
|
|
111
|
+
"text": "options.value - Whether the status bar overlays the web view (required)."
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"docs": "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.",
|
|
115
|
+
"complexTypes": [
|
|
116
|
+
"StatusBarSetOverlaysWebViewOptions"
|
|
117
|
+
],
|
|
118
|
+
"slug": "setoverlayswebview"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "setBackground",
|
|
122
|
+
"signature": "(options: StatusBarSetBackgroundOptions) => Promise<void>",
|
|
123
|
+
"parameters": [
|
|
124
|
+
{
|
|
125
|
+
"name": "options",
|
|
126
|
+
"docs": "- The options to set the window background color.",
|
|
127
|
+
"type": "StatusBarSetBackgroundOptions"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"returns": "Promise<void>",
|
|
131
|
+
"tags": [
|
|
132
|
+
{
|
|
133
|
+
"name": "param",
|
|
134
|
+
"text": "options - The options to set the window background color."
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "param",
|
|
138
|
+
"text": "options.color - The background color in HEX format."
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"docs": "Set the window background color.",
|
|
142
|
+
"complexTypes": [
|
|
143
|
+
"StatusBarSetBackgroundOptions"
|
|
144
|
+
],
|
|
145
|
+
"slug": "setbackground"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"name": "getSafeAreaInsets",
|
|
149
|
+
"signature": "() => Promise<SafeAreaInsets>",
|
|
150
|
+
"parameters": [],
|
|
151
|
+
"returns": "Promise<SafeAreaInsets>",
|
|
152
|
+
"tags": [],
|
|
153
|
+
"docs": "Get the safe area insets.\nReturns the insets for status bar, navigation bar, and notch areas.\nValues are in pixels on Android and points on iOS.",
|
|
154
|
+
"complexTypes": [
|
|
155
|
+
"SafeAreaInsets"
|
|
156
|
+
],
|
|
157
|
+
"slug": "getsafeareainsets"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"properties": []
|
|
161
|
+
},
|
|
162
|
+
"interfaces": [],
|
|
163
|
+
"enums": [
|
|
164
|
+
{
|
|
165
|
+
"name": "Style",
|
|
166
|
+
"slug": "style",
|
|
167
|
+
"members": [
|
|
168
|
+
{
|
|
169
|
+
"name": "LIGHT",
|
|
170
|
+
"value": "'LIGHT'",
|
|
171
|
+
"tags": [],
|
|
172
|
+
"docs": ""
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"name": "DARK",
|
|
176
|
+
"value": "'DARK'",
|
|
177
|
+
"tags": [],
|
|
178
|
+
"docs": ""
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"name": "CUSTOM",
|
|
182
|
+
"value": "'CUSTOM'",
|
|
183
|
+
"tags": [],
|
|
184
|
+
"docs": ""
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"name": "StatusBarAnimation",
|
|
190
|
+
"slug": "statusbaranimation",
|
|
191
|
+
"members": [
|
|
192
|
+
{
|
|
193
|
+
"name": "NONE",
|
|
194
|
+
"value": "'none'",
|
|
195
|
+
"tags": [],
|
|
196
|
+
"docs": ""
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "FADE",
|
|
200
|
+
"value": "'fade'",
|
|
201
|
+
"tags": [],
|
|
202
|
+
"docs": ""
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"name": "SLIDE",
|
|
206
|
+
"value": "'slide'",
|
|
207
|
+
"tags": [],
|
|
208
|
+
"docs": ""
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
"typeAliases": [
|
|
214
|
+
{
|
|
215
|
+
"name": "StatusBarOptions",
|
|
216
|
+
"slug": "statusbaroptions",
|
|
217
|
+
"docs": "",
|
|
218
|
+
"types": [
|
|
219
|
+
{
|
|
220
|
+
"text": "StatusBarStyleOptions",
|
|
221
|
+
"complexTypes": [
|
|
222
|
+
"StatusBarStyleOptions"
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"name": "StatusBarStyleOptions",
|
|
229
|
+
"slug": "statusbarstyleoptions",
|
|
230
|
+
"docs": "",
|
|
231
|
+
"types": [
|
|
232
|
+
{
|
|
233
|
+
"text": "StatusBarStyleNoDefaultOptions",
|
|
234
|
+
"complexTypes": [
|
|
235
|
+
"StatusBarStyleNoDefaultOptions"
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"text": "{\n style: Style.CUSTOM;\n color: StatusBarColor;\n }",
|
|
240
|
+
"complexTypes": [
|
|
241
|
+
"Style",
|
|
242
|
+
"StatusBarColor"
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"name": "StatusBarStyleNoDefaultOptions",
|
|
249
|
+
"slug": "statusbarstylenodefaultoptions",
|
|
250
|
+
"docs": "",
|
|
251
|
+
"types": [
|
|
252
|
+
{
|
|
253
|
+
"text": "{\n style: Style;\n}",
|
|
254
|
+
"complexTypes": [
|
|
255
|
+
"Style"
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"name": "StatusBarColor",
|
|
262
|
+
"slug": "statusbarcolor",
|
|
263
|
+
"docs": "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\nNote: Short 3-digit format (#FFF) is NOT supported.",
|
|
264
|
+
"types": [
|
|
265
|
+
{
|
|
266
|
+
"text": "`#${string}`",
|
|
267
|
+
"complexTypes": []
|
|
268
|
+
}
|
|
269
|
+
]
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"name": "StatusBarShowOptions",
|
|
273
|
+
"slug": "statusbarshowoptions",
|
|
274
|
+
"docs": "",
|
|
275
|
+
"types": [
|
|
276
|
+
{
|
|
277
|
+
"text": "{\n animated: boolean;\n}",
|
|
278
|
+
"complexTypes": []
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"name": "StatusBarHideOptions",
|
|
284
|
+
"slug": "statusbarhideoptions",
|
|
285
|
+
"docs": "",
|
|
286
|
+
"types": [
|
|
287
|
+
{
|
|
288
|
+
"text": "{\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}",
|
|
289
|
+
"complexTypes": [
|
|
290
|
+
"StatusBarAnimation"
|
|
291
|
+
]
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"name": "StatusBarSetOverlaysWebViewOptions",
|
|
297
|
+
"slug": "statusbarsetoverlayswebviewoptions",
|
|
298
|
+
"docs": "",
|
|
299
|
+
"types": [
|
|
300
|
+
{
|
|
301
|
+
"text": "{\n value: boolean;\n}",
|
|
302
|
+
"complexTypes": []
|
|
303
|
+
}
|
|
304
|
+
]
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"name": "StatusBarSetBackgroundOptions",
|
|
308
|
+
"slug": "statusbarsetbackgroundoptions",
|
|
309
|
+
"docs": "",
|
|
310
|
+
"types": [
|
|
311
|
+
{
|
|
312
|
+
"text": "{\n color: StatusBarColor;\n}",
|
|
313
|
+
"complexTypes": [
|
|
314
|
+
"StatusBarColor"
|
|
315
|
+
]
|
|
316
|
+
}
|
|
317
|
+
]
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"name": "SafeAreaInsets",
|
|
321
|
+
"slug": "safeareainsets",
|
|
322
|
+
"docs": "",
|
|
323
|
+
"types": [
|
|
324
|
+
{
|
|
325
|
+
"text": "{\n top: number;\n bottom: number;\n left: number;\n right: number;\n}",
|
|
326
|
+
"complexTypes": []
|
|
327
|
+
}
|
|
328
|
+
]
|
|
329
|
+
}
|
|
330
|
+
],
|
|
331
|
+
"pluginConfigs": []
|
|
332
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export declare enum Style {
|
|
2
|
+
LIGHT = "LIGHT",
|
|
3
|
+
DARK = "DARK",
|
|
4
|
+
CUSTOM = "CUSTOM"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Full HEX color format only (6 or 8 digits).
|
|
8
|
+
* - 6 digits: #RRGGBB (e.g., #FFFFFF, #000000, #FF5733)
|
|
9
|
+
* - 8 digits: #RRGGBBAA with alpha channel (e.g., #FFFFFF00, #FF5733CC)
|
|
10
|
+
*
|
|
11
|
+
* Note: Short 3-digit format (#FFF) is NOT supported.
|
|
12
|
+
*/
|
|
13
|
+
export declare type StatusBarColor = `#${string}`;
|
|
14
|
+
export declare enum StatusBarAnimation {
|
|
15
|
+
NONE = "none",
|
|
16
|
+
FADE = "fade",
|
|
17
|
+
SLIDE = "slide"
|
|
18
|
+
}
|
|
19
|
+
declare type StatusBarStyleNoDefaultOptions = {
|
|
20
|
+
style: Style;
|
|
21
|
+
};
|
|
22
|
+
declare type StatusBarStyleOptions = StatusBarStyleNoDefaultOptions | {
|
|
23
|
+
style: Style.CUSTOM;
|
|
24
|
+
color: StatusBarColor;
|
|
25
|
+
};
|
|
26
|
+
export declare type StatusBarOptions = StatusBarStyleOptions;
|
|
27
|
+
export declare type StatusBarShowOptions = {
|
|
28
|
+
animated: boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare type StatusBarHideOptions = {
|
|
31
|
+
/**
|
|
32
|
+
* The animation type for hiding the status bar.
|
|
33
|
+
* - 'fade': Makes the background transparent without removing the status bar and navigation bar.
|
|
34
|
+
* - 'slide': Hides the status bar and navigation bar completely (default behavior).
|
|
35
|
+
*/
|
|
36
|
+
animation: StatusBarAnimation;
|
|
37
|
+
};
|
|
38
|
+
export declare type StatusBarSetOverlaysWebViewOptions = {
|
|
39
|
+
value: boolean;
|
|
40
|
+
};
|
|
41
|
+
export declare type StatusBarSetBackgroundOptions = {
|
|
42
|
+
color: StatusBarColor;
|
|
43
|
+
};
|
|
44
|
+
export declare type SafeAreaInsets = {
|
|
45
|
+
top: number;
|
|
46
|
+
bottom: number;
|
|
47
|
+
left: number;
|
|
48
|
+
right: number;
|
|
49
|
+
};
|
|
50
|
+
export interface StatusBarPlugin {
|
|
51
|
+
/**
|
|
52
|
+
* Set the status bar and navigation bar style and color.
|
|
53
|
+
* @param options - The options to set the status bar style and color.
|
|
54
|
+
* @param options.style - The style of the status bar.
|
|
55
|
+
* @param options.color - The color of the status bar.
|
|
56
|
+
*/
|
|
57
|
+
setStyle(options: StatusBarOptions): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Show the status bar.
|
|
60
|
+
* @param options - The options to show the status bar.
|
|
61
|
+
* @param options.animated - Whether to animate the status bar.
|
|
62
|
+
*/
|
|
63
|
+
show(options: StatusBarShowOptions): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Hide the status bar.
|
|
66
|
+
* @param options - The options to hide the status bar.
|
|
67
|
+
* @param options.animation - The animation type: 'fade' makes background transparent, 'slide' hides bars completely.
|
|
68
|
+
*/
|
|
69
|
+
hide(options: StatusBarHideOptions): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Set whether the status bar overlays the web view.
|
|
72
|
+
*
|
|
73
|
+
* **iOS only** - On Android this is a no-op (resolves without error).
|
|
74
|
+
*
|
|
75
|
+
* - `true`: Web content extends behind the status bar (transparent background),
|
|
76
|
+
* allowing content to be visible through the status bar area on scroll.
|
|
77
|
+
* - `false`: Restores the status bar background to the color set by `setStyle`
|
|
78
|
+
* or falls back to the default style from Capacitor config.
|
|
79
|
+
*
|
|
80
|
+
* @param options - The options to set the status bar overlays web view.
|
|
81
|
+
* @param options.value - Whether the status bar overlays the web view (required).
|
|
82
|
+
*/
|
|
83
|
+
setOverlaysWebView(options: StatusBarSetOverlaysWebViewOptions): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Set the window background color.
|
|
86
|
+
* @param options - The options to set the window background color.
|
|
87
|
+
* @param options.color - The background color in HEX format.
|
|
88
|
+
*/
|
|
89
|
+
setBackground(options: StatusBarSetBackgroundOptions): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Get the safe area insets.
|
|
92
|
+
* Returns the insets for status bar, navigation bar, and notch areas.
|
|
93
|
+
* Values are in pixels on Android and points on iOS.
|
|
94
|
+
*/
|
|
95
|
+
getSafeAreaInsets(): Promise<SafeAreaInsets>;
|
|
96
|
+
}
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export var Style;
|
|
2
|
+
(function (Style) {
|
|
3
|
+
Style["LIGHT"] = "LIGHT";
|
|
4
|
+
Style["DARK"] = "DARK";
|
|
5
|
+
Style["CUSTOM"] = "CUSTOM";
|
|
6
|
+
})(Style || (Style = {}));
|
|
7
|
+
export var StatusBarAnimation;
|
|
8
|
+
(function (StatusBarAnimation) {
|
|
9
|
+
StatusBarAnimation["NONE"] = "none";
|
|
10
|
+
StatusBarAnimation["FADE"] = "fade";
|
|
11
|
+
StatusBarAnimation["SLIDE"] = "slide";
|
|
12
|
+
})(StatusBarAnimation || (StatusBarAnimation = {}));
|
|
13
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +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 StatusBarPlugin {\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 pixels on Android and points on iOS.\n */\n getSafeAreaInsets(): Promise<SafeAreaInsets>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,SAAS,GAAG,cAAc,CAAkB,WAAW,EAAE;IAC7D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,CAAC;CAC7D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { StatusBarPlugin } from './definitions';\n\nconst StatusBar = registerPlugin<StatusBarPlugin>('StatusBar', {\n web: () => import('./web').then((m) => new m.StatusBarWeb()),\n});\n\nexport * from './definitions';\nexport { StatusBar };\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { StatusBarOptions, StatusBarPlugin, StatusBarSetOverlaysWebViewOptions, StatusBarShowOptions, StatusBarHideOptions, StatusBarSetBackgroundOptions, SafeAreaInsets } from './definitions';
|
|
3
|
+
export declare class StatusBarWeb extends WebPlugin implements StatusBarPlugin {
|
|
4
|
+
setStyle(options: StatusBarOptions): Promise<void>;
|
|
5
|
+
show(options: StatusBarShowOptions): Promise<void>;
|
|
6
|
+
hide(options: StatusBarHideOptions): Promise<void>;
|
|
7
|
+
setOverlaysWebView(options: StatusBarSetOverlaysWebViewOptions): Promise<void>;
|
|
8
|
+
setBackground(options: StatusBarSetBackgroundOptions): Promise<void>;
|
|
9
|
+
getSafeAreaInsets(): Promise<SafeAreaInsets>;
|
|
10
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class StatusBarWeb extends WebPlugin {
|
|
3
|
+
async setStyle(options) {
|
|
4
|
+
console.log('setStyle', options);
|
|
5
|
+
}
|
|
6
|
+
async show(options) {
|
|
7
|
+
console.log('show', options);
|
|
8
|
+
}
|
|
9
|
+
async hide(options) {
|
|
10
|
+
console.log('hide', options);
|
|
11
|
+
}
|
|
12
|
+
async setOverlaysWebView(options) {
|
|
13
|
+
console.log('setOverlaysWebView', options);
|
|
14
|
+
}
|
|
15
|
+
async setBackground(options) {
|
|
16
|
+
console.log('setBackground', options);
|
|
17
|
+
}
|
|
18
|
+
async getSafeAreaInsets() {
|
|
19
|
+
// On web, we can use CSS environment variables to get safe area insets
|
|
20
|
+
// These are set by the browser on devices with notches, etc.
|
|
21
|
+
const getInsetValue = (variable) => {
|
|
22
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(variable).trim();
|
|
23
|
+
return value ? parseInt(value, 10) : 0;
|
|
24
|
+
};
|
|
25
|
+
const insets = {
|
|
26
|
+
top: getInsetValue('env(safe-area-inset-top)') || getInsetValue('constant(safe-area-inset-top)') || 0,
|
|
27
|
+
bottom: getInsetValue('env(safe-area-inset-bottom)') || getInsetValue('constant(safe-area-inset-bottom)') || 0,
|
|
28
|
+
left: getInsetValue('env(safe-area-inset-left)') || getInsetValue('constant(safe-area-inset-left)') || 0,
|
|
29
|
+
right: getInsetValue('env(safe-area-inset-right)') || getInsetValue('constant(safe-area-inset-right)') || 0,
|
|
30
|
+
};
|
|
31
|
+
console.log('getSafeAreaInsets', insets);
|
|
32
|
+
return insets;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAY5C,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,KAAK,CAAC,QAAQ,CAAC,OAAyB;QACtC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAA6B;QACtC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAA6B;QACtC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,OAA2C;QAClE,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAsC;QACxD,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IACxC,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 StatusBarPlugin,\n StatusBarSetOverlaysWebViewOptions,\n StatusBarShowOptions,\n StatusBarHideOptions,\n StatusBarSetBackgroundOptions,\n SafeAreaInsets,\n} from './definitions';\n\nexport class StatusBarWeb extends WebPlugin implements StatusBarPlugin {\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 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"]}
|