@capacitor/status-bar 6.0.1 → 6.0.2-dev-2179-20240822T152050.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,9 +20,6 @@ The status bar visibility defaults to visible and the style defaults to
20
20
  `Style.Default`. You can change these defaults by adding
21
21
  `UIStatusBarHidden` and/or `UIStatusBarStyle` in `Info.plist`.
22
22
 
23
- `setBackgroundColor` and `setOverlaysWebView` are currently not supported on
24
- iOS devices.
25
-
26
23
  ## Example
27
24
 
28
25
  ```typescript
@@ -33,7 +30,7 @@ window.addEventListener('statusTap', function () {
33
30
  console.log('statusbar tapped');
34
31
  });
35
32
 
36
- // Display content under transparent status bar (Android only)
33
+ // Display content under transparent status bar
37
34
  StatusBar.setOverlaysWebView({ overlay: true });
38
35
 
39
36
  const setStatusBarStyleDark = async () => {
@@ -53,6 +50,57 @@ const showStatusBar = async () => {
53
50
  };
54
51
  ```
55
52
 
53
+ ## Configuration
54
+
55
+ <docgen-config>
56
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
57
+
58
+ These config values are available:
59
+
60
+ | Prop | Type | Description | Default | Since |
61
+ | --------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------- | -------------------- | ----- |
62
+ | **`overlaysWebView`** | <code>boolean</code> | Whether the statusbar is overlaid or not. | <code>true</code> | 1.0.0 |
63
+ | **`style`** | <code>string</code> | <a href="#style">Style</a> of the text of the status bar. | <code>default</code> | 1.0.0 |
64
+ | **`backgroundColor`** | <code>string</code> | Color of the background of the statusbar in hex format, #RRGGBB. Doesn't work if `overlaysWebView` is true. | <code>#000000</code> | 1.0.0 |
65
+
66
+ ### Examples
67
+
68
+ In `capacitor.config.json`:
69
+
70
+ ```json
71
+ {
72
+ "plugins": {
73
+ "StatusBar": {
74
+ "overlaysWebView": false,
75
+ "style": "DARK",
76
+ "backgroundColor": "#ffffffff"
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ In `capacitor.config.ts`:
83
+
84
+ ```ts
85
+ /// <reference types="@capacitor/status-bar" />
86
+
87
+ import { CapacitorConfig } from '@capacitor/cli';
88
+
89
+ const config: CapacitorConfig = {
90
+ plugins: {
91
+ StatusBar: {
92
+ overlaysWebView: false,
93
+ style: "DARK",
94
+ backgroundColor: "#ffffffff",
95
+ },
96
+ },
97
+ };
98
+
99
+ export default config;
100
+ ```
101
+
102
+ </docgen-config>
103
+
56
104
  ## API
57
105
 
58
106
  <docgen-index>
@@ -96,8 +144,6 @@ setBackgroundColor(options: BackgroundColorOptions) => Promise<void>
96
144
 
97
145
  Set the background color of the status bar.
98
146
 
99
- This method is only supported on Android.
100
-
101
147
  | Param | Type |
102
148
  | ------------- | ------------------------------------------------------------------------- |
103
149
  | **`options`** | <code><a href="#backgroundcoloroptions">BackgroundColorOptions</a></code> |
@@ -169,8 +215,6 @@ setOverlaysWebView(options: SetOverlaysWebViewOptions) => Promise<void>
169
215
  Set whether or not the status bar should overlay the webview to allow usage
170
216
  of the space underneath it.
171
217
 
172
- This method is only supported on Android.
173
-
174
218
  | Param | Type |
175
219
  | ------------- | ------------------------------------------------------------------------------- |
176
220
  | **`options`** | <code><a href="#setoverlayswebviewoptions">SetOverlaysWebViewOptions</a></code> |
@@ -192,9 +236,9 @@ This method is only supported on Android.
192
236
 
193
237
  #### BackgroundColorOptions
194
238
 
195
- | Prop | Type | Description | Since |
196
- | ----------- | ------------------- | ------------------------------------------------------------------------------------------- | ----- |
197
- | **`color`** | <code>string</code> | A hex color to which the status bar color is set. This option is only supported on Android. | 1.0.0 |
239
+ | Prop | Type | Description | Since |
240
+ | ----------- | ------------------- | ------------------------------------------------- | ----- |
241
+ | **`color`** | <code>string</code> | A hex color to which the status bar color is set. | 1.0.0 |
198
242
 
199
243
 
200
244
  #### AnimationOptions
@@ -206,12 +250,12 @@ This method is only supported on Android.
206
250
 
207
251
  #### StatusBarInfo
208
252
 
209
- | Prop | Type | Description | Since |
210
- | -------------- | --------------------------------------- | ----------------------------------------------------------------------------------- | ----- |
211
- | **`visible`** | <code>boolean</code> | Whether the status bar is visible or not. | 1.0.0 |
212
- | **`style`** | <code><a href="#style">Style</a></code> | The current status bar style. | 1.0.0 |
213
- | **`color`** | <code>string</code> | The current status bar color. This option is only supported on Android. | 1.0.0 |
214
- | **`overlays`** | <code>boolean</code> | Whether the statusbar is overlaid or not. This option is only supported on Android. | 1.0.0 |
253
+ | Prop | Type | Description | Since |
254
+ | -------------- | --------------------------------------- | ----------------------------------------- | ----- |
255
+ | **`visible`** | <code>boolean</code> | Whether the status bar is visible or not. | 1.0.0 |
256
+ | **`style`** | <code><a href="#style">Style</a></code> | The current status bar style. | 1.0.0 |
257
+ | **`color`** | <code>string</code> | The current status bar color. | 1.0.0 |
258
+ | **`overlays`** | <code>boolean</code> | Whether the statusbar is overlaid or not. | 1.0.0 |
215
259
 
216
260
 
217
261
  #### SetOverlaysWebViewOptions
@@ -3,6 +3,7 @@ ext {
3
3
  junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
4
4
  androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.12.0'
5
5
  androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
6
+ androidxLocalBroadcastManagerVersion = project.hasProperty('androidxLocalBroadcastManagerVersion') ? rootProject.ext.androidxLocalBroadcastManagerVersion : '1.1.0'
6
7
  androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
7
8
  androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
8
9
  }
@@ -75,6 +76,7 @@ dependencies {
75
76
 
76
77
  implementation "androidx.core:core:$androidxCoreVersion"
77
78
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
79
+ implementation "androidx.localbroadcastmanager:localbroadcastmanager:$androidxLocalBroadcastManagerVersion"
78
80
  testImplementation "junit:junit:$junitVersion"
79
81
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
80
82
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
@@ -1,6 +1,8 @@
1
1
  package com.capacitorjs.plugins.statusbar;
2
2
 
3
+ import android.content.Intent;
3
4
  import android.graphics.Color;
5
+ import android.util.DisplayMetrics;
4
6
  import android.view.View;
5
7
  import android.view.Window;
6
8
  import android.view.WindowManager;
@@ -9,6 +11,7 @@ import androidx.core.view.ViewCompat;
9
11
  import androidx.core.view.WindowCompat;
10
12
  import androidx.core.view.WindowInsetsCompat;
11
13
  import androidx.core.view.WindowInsetsControllerCompat;
14
+ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
12
15
 
13
16
  public class StatusBar {
14
17
 
@@ -16,11 +19,18 @@ public class StatusBar {
16
19
  private final AppCompatActivity activity;
17
20
  private final String defaultStyle;
18
21
 
19
- public StatusBar(AppCompatActivity activity) {
22
+ public static final String statusBarVisibilityChanged = "statusBarVisibilityChanged";
23
+ public static final String statusBarOverlayChanged = "statusBarOverlayChanged";
24
+
25
+ public StatusBar(AppCompatActivity activity, StatusBarConfig config) {
20
26
  // save initial color of the status bar
21
27
  this.activity = activity;
22
28
  this.currentStatusBarColor = activity.getWindow().getStatusBarColor();
23
29
  this.defaultStyle = getStyle();
30
+
31
+ setBackgroundColor(config.getBackgroundColor());
32
+ setStyle(config.getStyle());
33
+ setOverlaysWebView(config.isOverlaysWebView());
24
34
  }
25
35
 
26
36
  public void setStyle(String style) {
@@ -49,12 +59,20 @@ public class StatusBar {
49
59
  View decorView = activity.getWindow().getDecorView();
50
60
  WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(activity.getWindow(), decorView);
51
61
  windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.statusBars());
62
+ sendBroadcast(statusBarVisibilityChanged);
52
63
  }
53
64
 
54
65
  public void show() {
55
66
  View decorView = activity.getWindow().getDecorView();
56
67
  WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(activity.getWindow(), decorView);
57
68
  windowInsetsControllerCompat.show(WindowInsetsCompat.Type.statusBars());
69
+ sendBroadcast(statusBarVisibilityChanged);
70
+ }
71
+
72
+ private void sendBroadcast(String action) {
73
+ Intent intent = new Intent(action);
74
+ intent.putExtra("info", getInfo());
75
+ LocalBroadcastManager.getInstance(activity).sendBroadcast(intent);
58
76
  }
59
77
 
60
78
  @SuppressWarnings("deprecation")
@@ -74,6 +92,7 @@ public class StatusBar {
74
92
  // recover the previous color of the status bar
75
93
  activity.getWindow().setStatusBarColor(currentStatusBarColor);
76
94
  }
95
+ sendBroadcast(statusBarOverlayChanged);
77
96
  }
78
97
 
79
98
  @SuppressWarnings("deprecation")
@@ -93,6 +112,7 @@ public class StatusBar {
93
112
  info.setOverlays(getIsOverlaid());
94
113
  info.setVisible(isVisible);
95
114
  info.setColor(String.format("#%06X", (0xFFFFFF & window.getStatusBarColor())));
115
+ info.setHeight(getStatusBarHeight());
96
116
  return info;
97
117
  }
98
118
 
@@ -105,4 +125,17 @@ public class StatusBar {
105
125
  }
106
126
  return style;
107
127
  }
128
+
129
+ private int getStatusBarHeight() {
130
+ int statusbarHeight = 0;
131
+ int resourceId = activity.getApplicationContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
132
+ if (resourceId > 0) {
133
+ statusbarHeight = (int) activity.getApplicationContext().getResources().getDimension(resourceId);
134
+ }
135
+
136
+ DisplayMetrics metrics = activity.getApplicationContext().getResources().getDisplayMetrics();
137
+ float densityDpi = metrics.density;
138
+
139
+ return (int) (statusbarHeight / densityDpi);
140
+ }
108
141
  }
@@ -0,0 +1,34 @@
1
+ package com.capacitorjs.plugins.statusbar;
2
+
3
+ import com.getcapacitor.util.WebColor;
4
+
5
+ public class StatusBarConfig {
6
+
7
+ private boolean overlaysWebView = true;
8
+ private Integer backgroundColor = WebColor.parseColor("#000000");
9
+ private String style = "DEFAULT";
10
+
11
+ public boolean isOverlaysWebView() {
12
+ return overlaysWebView;
13
+ }
14
+
15
+ public void setOverlaysWebView(boolean overlaysWebView) {
16
+ this.overlaysWebView = overlaysWebView;
17
+ }
18
+
19
+ public Integer getBackgroundColor() {
20
+ return backgroundColor;
21
+ }
22
+
23
+ public void setBackgroundColor(Integer backgroundColor) {
24
+ this.backgroundColor = backgroundColor;
25
+ }
26
+
27
+ public String getStyle() {
28
+ return style;
29
+ }
30
+
31
+ public void setStyle(String style) {
32
+ this.style = style;
33
+ }
34
+ }
@@ -1,11 +1,14 @@
1
1
  package com.capacitorjs.plugins.statusbar;
2
2
 
3
- public class StatusBarInfo {
3
+ import java.io.Serializable;
4
+
5
+ public class StatusBarInfo implements Serializable {
4
6
 
5
7
  private boolean overlays;
6
8
  private boolean visible;
7
9
  private String style;
8
10
  private String color;
11
+ private int height;
9
12
 
10
13
  public boolean isOverlays() {
11
14
  return overlays;
@@ -38,4 +41,12 @@ public class StatusBarInfo {
38
41
  public void setColor(String color) {
39
42
  this.color = color;
40
43
  }
44
+
45
+ public int getHeight() {
46
+ return height;
47
+ }
48
+
49
+ public void setHeight(int height) {
50
+ this.height = height;
51
+ }
41
52
  }
@@ -1,6 +1,7 @@
1
1
  package com.capacitorjs.plugins.statusbar;
2
2
 
3
3
  import com.getcapacitor.JSObject;
4
+ import com.getcapacitor.Logger;
4
5
  import com.getcapacitor.Plugin;
5
6
  import com.getcapacitor.PluginCall;
6
7
  import com.getcapacitor.PluginMethod;
@@ -15,7 +16,37 @@ public class StatusBarPlugin extends Plugin {
15
16
 
16
17
  @Override
17
18
  public void load() {
18
- implementation = new StatusBar(getActivity());
19
+ StatusBarConfig config = getStatusBarConfig();
20
+ implementation = new StatusBar(getActivity(), config);
21
+ }
22
+
23
+ private StatusBarConfig getStatusBarConfig() {
24
+ StatusBarConfig config = new StatusBarConfig();
25
+ String backgroundColor = getConfig().getString("backgroundColor");
26
+ if (backgroundColor != null) {
27
+ try {
28
+ config.setBackgroundColor(WebColor.parseColor(backgroundColor));
29
+ } catch (IllegalArgumentException ex) {
30
+ Logger.debug("Background color not applied");
31
+ }
32
+ }
33
+ config.setStyle(styleFromConfig(getConfig().getString("style", config.getStyle())));
34
+ config.setOverlaysWebView(getConfig().getBoolean("overlaysWebView", config.isOverlaysWebView()));
35
+ return config;
36
+ }
37
+
38
+ private String styleFromConfig(String style) {
39
+ switch (style.toLowerCase()) {
40
+ case "lightcontent":
41
+ case "dark":
42
+ return "DARK";
43
+ case "darkcontent":
44
+ case "light":
45
+ return "LIGHT";
46
+ case "default":
47
+ default:
48
+ return "DEFAULT";
49
+ }
19
50
  }
20
51
 
21
52
  @PluginMethod
package/dist/docs.json CHANGED
@@ -45,7 +45,7 @@
45
45
  "text": "1.0.0"
46
46
  }
47
47
  ],
48
- "docs": "Set the background color of the status bar.\n\nThis method is only supported on Android.",
48
+ "docs": "Set the background color of the status bar.",
49
49
  "complexTypes": [
50
50
  "BackgroundColorOptions"
51
51
  ],
@@ -131,7 +131,7 @@
131
131
  "text": "1.0.0"
132
132
  }
133
133
  ],
134
- "docs": "Set whether or not the status bar should overlay the webview to allow usage\nof the space underneath it.\n\nThis method is only supported on Android.",
134
+ "docs": "Set whether or not the status bar should overlay the webview to allow usage\nof the space underneath it.",
135
135
  "complexTypes": [
136
136
  "SetOverlaysWebViewOptions"
137
137
  ],
@@ -179,7 +179,7 @@
179
179
  "name": "since"
180
180
  }
181
181
  ],
182
- "docs": "A hex color to which the status bar color is set.\n\nThis option is only supported on Android.",
182
+ "docs": "A hex color to which the status bar color is set.",
183
183
  "complexTypes": [],
184
184
  "type": "string"
185
185
  }
@@ -253,7 +253,7 @@
253
253
  "name": "since"
254
254
  }
255
255
  ],
256
- "docs": "The current status bar color.\n\nThis option is only supported on Android.",
256
+ "docs": "The current status bar color.",
257
257
  "complexTypes": [],
258
258
  "type": "string | undefined"
259
259
  },
@@ -265,7 +265,7 @@
265
265
  "name": "since"
266
266
  }
267
267
  ],
268
- "docs": "Whether the statusbar is overlaid or not.\n\nThis option is only supported on Android.",
268
+ "docs": "Whether the statusbar is overlaid or not.",
269
269
  "complexTypes": [],
270
270
  "type": "boolean | undefined"
271
271
  }
@@ -378,5 +378,73 @@
378
378
  }
379
379
  ],
380
380
  "typeAliases": [],
381
- "pluginConfigs": []
381
+ "pluginConfigs": [
382
+ {
383
+ "name": "StatusBar",
384
+ "slug": "statusbar",
385
+ "properties": [
386
+ {
387
+ "name": "overlaysWebView",
388
+ "tags": [
389
+ {
390
+ "text": "1.0.0",
391
+ "name": "since"
392
+ },
393
+ {
394
+ "text": "true",
395
+ "name": "default"
396
+ },
397
+ {
398
+ "text": "false",
399
+ "name": "example"
400
+ }
401
+ ],
402
+ "docs": "Whether the statusbar is overlaid or not.",
403
+ "complexTypes": [],
404
+ "type": "boolean | undefined"
405
+ },
406
+ {
407
+ "name": "style",
408
+ "tags": [
409
+ {
410
+ "text": "1.0.0",
411
+ "name": "since"
412
+ },
413
+ {
414
+ "text": "default",
415
+ "name": "default"
416
+ },
417
+ {
418
+ "text": "\"DARK\"",
419
+ "name": "example"
420
+ }
421
+ ],
422
+ "docs": "Style of the text of the status bar.",
423
+ "complexTypes": [],
424
+ "type": "string | undefined"
425
+ },
426
+ {
427
+ "name": "backgroundColor",
428
+ "tags": [
429
+ {
430
+ "text": "1.0.0",
431
+ "name": "since"
432
+ },
433
+ {
434
+ "text": "#000000",
435
+ "name": "default"
436
+ },
437
+ {
438
+ "text": "\"#ffffffff\"",
439
+ "name": "example"
440
+ }
441
+ ],
442
+ "docs": "Color of the background of the statusbar in hex format, #RRGGBB.\nDoesn't work if `overlaysWebView` is true.",
443
+ "complexTypes": [],
444
+ "type": "string | undefined"
445
+ }
446
+ ],
447
+ "docs": "These config values are available:"
448
+ }
449
+ ]
382
450
  }
@@ -1,3 +1,37 @@
1
+ declare module '@capacitor/cli' {
2
+ interface PluginsConfig {
3
+ /**
4
+ * These config values are available:
5
+ */
6
+ StatusBar?: {
7
+ /**
8
+ * Whether the statusbar is overlaid or not.
9
+ *
10
+ * @since 1.0.0
11
+ * @default true
12
+ * @example false
13
+ */
14
+ overlaysWebView?: boolean;
15
+ /**
16
+ * Style of the text of the status bar.
17
+ *
18
+ * @since 1.0.0
19
+ * @default default
20
+ * @example "DARK"
21
+ */
22
+ style?: string;
23
+ /**
24
+ * Color of the background of the statusbar in hex format, #RRGGBB.
25
+ * Doesn't work if `overlaysWebView` is true.
26
+ *
27
+ * @since 1.0.0
28
+ * @default #000000
29
+ * @example "#ffffffff"
30
+ */
31
+ backgroundColor?: string;
32
+ };
33
+ }
34
+ }
1
35
  export interface StyleOptions {
2
36
  /**
3
37
  * Style of the text of the status bar.
@@ -68,8 +102,6 @@ export interface BackgroundColorOptions {
68
102
  /**
69
103
  * A hex color to which the status bar color is set.
70
104
  *
71
- * This option is only supported on Android.
72
- *
73
105
  * @since 1.0.0
74
106
  */
75
107
  color: string;
@@ -90,16 +122,12 @@ export interface StatusBarInfo {
90
122
  /**
91
123
  * The current status bar color.
92
124
  *
93
- * This option is only supported on Android.
94
- *
95
125
  * @since 1.0.0
96
126
  */
97
127
  color?: string;
98
128
  /**
99
129
  * Whether the statusbar is overlaid or not.
100
130
  *
101
- * This option is only supported on Android.
102
- *
103
131
  * @since 1.0.0
104
132
  */
105
133
  overlays?: boolean;
@@ -122,8 +150,6 @@ export interface StatusBarPlugin {
122
150
  /**
123
151
  * Set the background color of the status bar.
124
152
  *
125
- * This method is only supported on Android.
126
- *
127
153
  * @since 1.0.0
128
154
  */
129
155
  setBackgroundColor(options: BackgroundColorOptions): Promise<void>;
@@ -153,8 +179,6 @@ export interface StatusBarPlugin {
153
179
  * Set whether or not the status bar should overlay the webview to allow usage
154
180
  * of the space underneath it.
155
181
  *
156
- * This method is only supported on Android.
157
- *
158
182
  * @since 1.0.0
159
183
  */
160
184
  setOverlaysWebView(options: SetOverlaysWebViewOptions): Promise<void>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="@capacitor/cli" />
1
2
  export var Style;
2
3
  (function (Style) {
3
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AASA,MAAM,CAAN,IAAY,KAwBX;AAxBD,WAAY,KAAK;IACf;;;;OAIG;IACH,sBAAa,CAAA;IAEb;;;;OAIG;IACH,wBAAe,CAAA;IAEf;;;;;;;OAOG;IACH,4BAAmB,CAAA;AACrB,CAAC,EAxBW,KAAK,KAAL,KAAK,QAwBhB;AAeD,MAAM,CAAN,IAAY,SAwBX;AAxBD,WAAY,SAAS;IACnB;;;;OAIG;IACH,0BAAa,CAAA;IAEb;;;;;;;OAOG;IACH,4BAAe,CAAA;IAEf;;;;OAIG;IACH,0BAAa,CAAA;AACf,CAAC,EAxBW,SAAS,KAAT,SAAS,QAwBpB;AA2ID;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC","sourcesContent":["export interface StyleOptions {\n /**\n * Style of the text of the status bar.\n *\n * @since 1.0.0\n */\n style: Style;\n}\n\nexport enum Style {\n /**\n * Light text for dark backgrounds.\n *\n * @since 1.0.0\n */\n Dark = 'DARK',\n\n /**\n * Dark text for light backgrounds.\n *\n * @since 1.0.0\n */\n Light = 'LIGHT',\n\n /**\n * The style is based on the device appearance.\n * If the device is using Dark mode, the statusbar text will be light.\n * If the device is using Light mode, the statusbar text will be dark.\n * On Android the default will be the one the app was launched with.\n *\n * @since 1.0.0\n */\n Default = 'DEFAULT',\n}\n\nexport interface AnimationOptions {\n /**\n * The type of status bar animation used when showing or hiding.\n *\n * This option is only supported on iOS.\n *\n * @default Animation.Fade\n *\n * @since 1.0.0\n */\n animation: Animation;\n}\n\nexport enum Animation {\n /**\n * No animation during show/hide.\n *\n * @since 1.0.0\n */\n None = 'NONE',\n\n /**\n * Slide animation during show/hide.\n * It doesn't work on iOS 15+.\n *\n * @deprecated Use Animation.Fade or Animation.None instead.\n *\n * @since 1.0.0\n */\n Slide = 'SLIDE',\n\n /**\n * Fade animation during show/hide.\n *\n * @since 1.0.0\n */\n Fade = 'FADE',\n}\n\nexport interface BackgroundColorOptions {\n /**\n * A hex color to which the status bar color is set.\n *\n * This option is only supported on Android.\n *\n * @since 1.0.0\n */\n color: string;\n}\n\nexport interface StatusBarInfo {\n /**\n * Whether the status bar is visible or not.\n *\n * @since 1.0.0\n */\n visible: boolean;\n\n /**\n * The current status bar style.\n *\n * @since 1.0.0\n */\n style: Style;\n\n /**\n * The current status bar color.\n *\n * This option is only supported on Android.\n *\n * @since 1.0.0\n */\n color?: string;\n\n /**\n * Whether the statusbar is overlaid or not.\n *\n * This option is only supported on Android.\n *\n * @since 1.0.0\n */\n overlays?: boolean;\n}\n\nexport interface SetOverlaysWebViewOptions {\n /**\n * Whether to overlay the status bar or not.\n *\n * @since 1.0.0\n */\n overlay: boolean;\n}\n\nexport interface StatusBarPlugin {\n /**\n * Set the current style of the status bar.\n *\n * @since 1.0.0\n */\n setStyle(options: StyleOptions): Promise<void>;\n\n /**\n * Set the background color of the status bar.\n *\n * This method is only supported on Android.\n *\n * @since 1.0.0\n */\n setBackgroundColor(options: BackgroundColorOptions): Promise<void>;\n\n /**\n * Show the status bar.\n * On iOS, if the status bar is initially hidden and the initial style is set to\n * `UIStatusBarStyleLightContent`, first show call might present a glitch on the\n * animation showing the text as dark and then transition to light. It's recommended\n * to use `Animation.None` as the animation on the first call.\n *\n * @since 1.0.0\n */\n show(options?: AnimationOptions): Promise<void>;\n\n /**\n * Hide the status bar.\n *\n * @since 1.0.0\n */\n hide(options?: AnimationOptions): Promise<void>;\n\n /**\n * Get info about the current state of the status bar.\n *\n * @since 1.0.0\n */\n getInfo(): Promise<StatusBarInfo>;\n\n /**\n * Set whether or not the status bar should overlay the webview to allow usage\n * of the space underneath it.\n *\n * This method is only supported on Android.\n *\n * @since 1.0.0\n */\n setOverlaysWebView(options: SetOverlaysWebViewOptions): Promise<void>;\n}\n\n/**\n * @deprecated Use `StyleOptions`.\n * @since 1.0.0\n */\nexport type StatusBarStyleOptions = StyleOptions;\n\n/**\n * @deprecated Use `BackgroundColorOptions`.\n * @since 1.0.0\n */\nexport type StatusBarBackgroundColorOptions = BackgroundColorOptions;\n\n/**\n * @deprecated Use `SetOverlaysWebViewOptions`.\n * @since 1.0.0\n */\nexport type StatusBarOverlaysWebviewOptions = SetOverlaysWebViewOptions;\n\n/**\n * @deprecated Use `StatusBarInfo`.\n * @since 1.0.0\n */\nexport type StatusBarInfoResult = StatusBarInfo;\n\n/**\n * @deprecated Use `AnimationOptions`.\n * @since 1.0.0\n */\nexport type StatusBarAnimationOptions = AnimationOptions;\n\n/**\n * @deprecated Use `Animation`.\n * @since 1.0.0\n */\nexport const StatusBarAnimation = Animation;\n\n/**\n * @deprecated Use `Style`.\n * @since 1.0.0\n */\nexport const StatusBarStyle = Style;\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAgDxC,MAAM,CAAN,IAAY,KAwBX;AAxBD,WAAY,KAAK;IACf;;;;OAIG;IACH,sBAAa,CAAA;IAEb;;;;OAIG;IACH,wBAAe,CAAA;IAEf;;;;;;;OAOG;IACH,4BAAmB,CAAA;AACrB,CAAC,EAxBW,KAAK,KAAL,KAAK,QAwBhB;AAeD,MAAM,CAAN,IAAY,SAwBX;AAxBD,WAAY,SAAS;IACnB;;;;OAIG;IACH,0BAAa,CAAA;IAEb;;;;;;;OAOG;IACH,4BAAe,CAAA;IAEf;;;;OAIG;IACH,0BAAa,CAAA;AACf,CAAC,EAxBW,SAAS,KAAT,SAAS,QAwBpB;AAiID;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * These config values are available:\n */\n StatusBar?: {\n /**\n * Whether the statusbar is overlaid or not.\n *\n * @since 1.0.0\n * @default true\n * @example false\n */\n overlaysWebView?: boolean;\n\n /**\n * Style of the text of the status bar.\n *\n * @since 1.0.0\n * @default default\n * @example \"DARK\"\n */\n style?: string;\n\n /**\n * Color of the background of the statusbar in hex format, #RRGGBB.\n * Doesn't work if `overlaysWebView` is true.\n *\n * @since 1.0.0\n * @default #000000\n * @example \"#ffffffff\"\n */\n backgroundColor?: string;\n };\n }\n}\n\nexport interface StyleOptions {\n /**\n * Style of the text of the status bar.\n *\n * @since 1.0.0\n */\n style: Style;\n}\n\nexport enum Style {\n /**\n * Light text for dark backgrounds.\n *\n * @since 1.0.0\n */\n Dark = 'DARK',\n\n /**\n * Dark text for light backgrounds.\n *\n * @since 1.0.0\n */\n Light = 'LIGHT',\n\n /**\n * The style is based on the device appearance.\n * If the device is using Dark mode, the statusbar text will be light.\n * If the device is using Light mode, the statusbar text will be dark.\n * On Android the default will be the one the app was launched with.\n *\n * @since 1.0.0\n */\n Default = 'DEFAULT',\n}\n\nexport interface AnimationOptions {\n /**\n * The type of status bar animation used when showing or hiding.\n *\n * This option is only supported on iOS.\n *\n * @default Animation.Fade\n *\n * @since 1.0.0\n */\n animation: Animation;\n}\n\nexport enum Animation {\n /**\n * No animation during show/hide.\n *\n * @since 1.0.0\n */\n None = 'NONE',\n\n /**\n * Slide animation during show/hide.\n * It doesn't work on iOS 15+.\n *\n * @deprecated Use Animation.Fade or Animation.None instead.\n *\n * @since 1.0.0\n */\n Slide = 'SLIDE',\n\n /**\n * Fade animation during show/hide.\n *\n * @since 1.0.0\n */\n Fade = 'FADE',\n}\n\nexport interface BackgroundColorOptions {\n /**\n * A hex color to which the status bar color is set.\n *\n * @since 1.0.0\n */\n color: string;\n}\n\nexport interface StatusBarInfo {\n /**\n * Whether the status bar is visible or not.\n *\n * @since 1.0.0\n */\n visible: boolean;\n\n /**\n * The current status bar style.\n *\n * @since 1.0.0\n */\n style: Style;\n\n /**\n * The current status bar color.\n *\n * @since 1.0.0\n */\n color?: string;\n\n /**\n * Whether the statusbar is overlaid or not.\n *\n * @since 1.0.0\n */\n overlays?: boolean;\n}\n\nexport interface SetOverlaysWebViewOptions {\n /**\n * Whether to overlay the status bar or not.\n *\n * @since 1.0.0\n */\n overlay: boolean;\n}\n\nexport interface StatusBarPlugin {\n /**\n * Set the current style of the status bar.\n *\n * @since 1.0.0\n */\n setStyle(options: StyleOptions): Promise<void>;\n\n /**\n * Set the background color of the status bar.\n *\n * @since 1.0.0\n */\n setBackgroundColor(options: BackgroundColorOptions): Promise<void>;\n\n /**\n * Show the status bar.\n * On iOS, if the status bar is initially hidden and the initial style is set to\n * `UIStatusBarStyleLightContent`, first show call might present a glitch on the\n * animation showing the text as dark and then transition to light. It's recommended\n * to use `Animation.None` as the animation on the first call.\n *\n * @since 1.0.0\n */\n show(options?: AnimationOptions): Promise<void>;\n\n /**\n * Hide the status bar.\n *\n * @since 1.0.0\n */\n hide(options?: AnimationOptions): Promise<void>;\n\n /**\n * Get info about the current state of the status bar.\n *\n * @since 1.0.0\n */\n getInfo(): Promise<StatusBarInfo>;\n\n /**\n * Set whether or not the status bar should overlay the webview to allow usage\n * of the space underneath it.\n *\n * @since 1.0.0\n */\n setOverlaysWebView(options: SetOverlaysWebViewOptions): Promise<void>;\n}\n\n/**\n * @deprecated Use `StyleOptions`.\n * @since 1.0.0\n */\nexport type StatusBarStyleOptions = StyleOptions;\n\n/**\n * @deprecated Use `BackgroundColorOptions`.\n * @since 1.0.0\n */\nexport type StatusBarBackgroundColorOptions = BackgroundColorOptions;\n\n/**\n * @deprecated Use `SetOverlaysWebViewOptions`.\n * @since 1.0.0\n */\nexport type StatusBarOverlaysWebviewOptions = SetOverlaysWebViewOptions;\n\n/**\n * @deprecated Use `StatusBarInfo`.\n * @since 1.0.0\n */\nexport type StatusBarInfoResult = StatusBarInfo;\n\n/**\n * @deprecated Use `AnimationOptions`.\n * @since 1.0.0\n */\nexport type StatusBarAnimationOptions = AnimationOptions;\n\n/**\n * @deprecated Use `Animation`.\n * @since 1.0.0\n */\nexport const StatusBarAnimation = Animation;\n\n/**\n * @deprecated Use `Style`.\n * @since 1.0.0\n */\nexport const StatusBarStyle = Style;\n"]}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@capacitor/core');
6
6
 
7
+ /// <reference types="@capacitor/cli" />
7
8
  exports.Style = void 0;
8
9
  (function (Style) {
9
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js"],"sourcesContent":["export var Style;\n(function (Style) {\n /**\n * Light text for dark backgrounds.\n *\n * @since 1.0.0\n */\n Style[\"Dark\"] = \"DARK\";\n /**\n * Dark text for light backgrounds.\n *\n * @since 1.0.0\n */\n Style[\"Light\"] = \"LIGHT\";\n /**\n * The style is based on the device appearance.\n * If the device is using Dark mode, the statusbar text will be light.\n * If the device is using Light mode, the statusbar text will be dark.\n * On Android the default will be the one the app was launched with.\n *\n * @since 1.0.0\n */\n Style[\"Default\"] = \"DEFAULT\";\n})(Style || (Style = {}));\nexport var Animation;\n(function (Animation) {\n /**\n * No animation during show/hide.\n *\n * @since 1.0.0\n */\n Animation[\"None\"] = \"NONE\";\n /**\n * Slide animation during show/hide.\n * It doesn't work on iOS 15+.\n *\n * @deprecated Use Animation.Fade or Animation.None instead.\n *\n * @since 1.0.0\n */\n Animation[\"Slide\"] = \"SLIDE\";\n /**\n * Fade animation during show/hide.\n *\n * @since 1.0.0\n */\n Animation[\"Fade\"] = \"FADE\";\n})(Animation || (Animation = {}));\n/**\n * @deprecated Use `Animation`.\n * @since 1.0.0\n */\nexport const StatusBarAnimation = Animation;\n/**\n * @deprecated Use `Style`.\n * @since 1.0.0\n */\nexport const StatusBarStyle = Style;\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst StatusBar = registerPlugin('StatusBar');\nexport * from './definitions';\nexport { StatusBar };\n//# sourceMappingURL=index.js.map"],"names":["Style","Animation","registerPlugin"],"mappings":";;;;;;AAAWA,uBAAM;AACjB,CAAC,UAAU,KAAK,EAAE;AAClB;AACA;AACA;AACA;AACA;AACA,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAC3B;AACA;AACA;AACA;AACA;AACA,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,KAAK,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AACjC,CAAC,EAAEA,aAAK,KAAKA,aAAK,GAAG,EAAE,CAAC,CAAC,CAAC;AACfC,2BAAU;AACrB,CAAC,UAAU,SAAS,EAAE;AACtB;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAC/B,CAAC,EAAEA,iBAAS,KAAKA,iBAAS,GAAG,EAAE,CAAC,CAAC,CAAC;AAClC;AACA;AACA;AACA;AACY,MAAC,kBAAkB,GAAGA,kBAAU;AAC5C;AACA;AACA;AACA;AACY,MAAC,cAAc,GAAGD;;ACxDzB,MAAC,SAAS,GAAGE,mBAAc,CAAC,WAAW;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js"],"sourcesContent":["/// <reference types=\"@capacitor/cli\" />\nexport var Style;\n(function (Style) {\n /**\n * Light text for dark backgrounds.\n *\n * @since 1.0.0\n */\n Style[\"Dark\"] = \"DARK\";\n /**\n * Dark text for light backgrounds.\n *\n * @since 1.0.0\n */\n Style[\"Light\"] = \"LIGHT\";\n /**\n * The style is based on the device appearance.\n * If the device is using Dark mode, the statusbar text will be light.\n * If the device is using Light mode, the statusbar text will be dark.\n * On Android the default will be the one the app was launched with.\n *\n * @since 1.0.0\n */\n Style[\"Default\"] = \"DEFAULT\";\n})(Style || (Style = {}));\nexport var Animation;\n(function (Animation) {\n /**\n * No animation during show/hide.\n *\n * @since 1.0.0\n */\n Animation[\"None\"] = \"NONE\";\n /**\n * Slide animation during show/hide.\n * It doesn't work on iOS 15+.\n *\n * @deprecated Use Animation.Fade or Animation.None instead.\n *\n * @since 1.0.0\n */\n Animation[\"Slide\"] = \"SLIDE\";\n /**\n * Fade animation during show/hide.\n *\n * @since 1.0.0\n */\n Animation[\"Fade\"] = \"FADE\";\n})(Animation || (Animation = {}));\n/**\n * @deprecated Use `Animation`.\n * @since 1.0.0\n */\nexport const StatusBarAnimation = Animation;\n/**\n * @deprecated Use `Style`.\n * @since 1.0.0\n */\nexport const StatusBarStyle = Style;\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst StatusBar = registerPlugin('StatusBar');\nexport * from './definitions';\nexport { StatusBar };\n//# sourceMappingURL=index.js.map"],"names":["Style","Animation","registerPlugin"],"mappings":";;;;;;AAAA;AACWA,uBAAM;AACjB,CAAC,UAAU,KAAK,EAAE;AAClB;AACA;AACA;AACA;AACA;AACA,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAC3B;AACA;AACA;AACA;AACA;AACA,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,KAAK,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AACjC,CAAC,EAAEA,aAAK,KAAKA,aAAK,GAAG,EAAE,CAAC,CAAC,CAAC;AACfC,2BAAU;AACrB,CAAC,UAAU,SAAS,EAAE;AACtB;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAC/B,CAAC,EAAEA,iBAAS,KAAKA,iBAAS,GAAG,EAAE,CAAC,CAAC,CAAC;AAClC;AACA;AACA;AACA;AACY,MAAC,kBAAkB,GAAGA,kBAAU;AAC5C;AACA;AACA;AACA;AACY,MAAC,cAAc,GAAGD;;ACzDzB,MAAC,SAAS,GAAGE,mBAAc,CAAC,WAAW;;;;;;"}
package/dist/plugin.js CHANGED
@@ -1,6 +1,7 @@
1
1
  var capacitorStatusBar = (function (exports, core) {
2
2
  'use strict';
3
3
 
4
+ /// <reference types="@capacitor/cli" />
4
5
  exports.Style = void 0;
5
6
  (function (Style) {
6
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js"],"sourcesContent":["export var Style;\n(function (Style) {\n /**\n * Light text for dark backgrounds.\n *\n * @since 1.0.0\n */\n Style[\"Dark\"] = \"DARK\";\n /**\n * Dark text for light backgrounds.\n *\n * @since 1.0.0\n */\n Style[\"Light\"] = \"LIGHT\";\n /**\n * The style is based on the device appearance.\n * If the device is using Dark mode, the statusbar text will be light.\n * If the device is using Light mode, the statusbar text will be dark.\n * On Android the default will be the one the app was launched with.\n *\n * @since 1.0.0\n */\n Style[\"Default\"] = \"DEFAULT\";\n})(Style || (Style = {}));\nexport var Animation;\n(function (Animation) {\n /**\n * No animation during show/hide.\n *\n * @since 1.0.0\n */\n Animation[\"None\"] = \"NONE\";\n /**\n * Slide animation during show/hide.\n * It doesn't work on iOS 15+.\n *\n * @deprecated Use Animation.Fade or Animation.None instead.\n *\n * @since 1.0.0\n */\n Animation[\"Slide\"] = \"SLIDE\";\n /**\n * Fade animation during show/hide.\n *\n * @since 1.0.0\n */\n Animation[\"Fade\"] = \"FADE\";\n})(Animation || (Animation = {}));\n/**\n * @deprecated Use `Animation`.\n * @since 1.0.0\n */\nexport const StatusBarAnimation = Animation;\n/**\n * @deprecated Use `Style`.\n * @since 1.0.0\n */\nexport const StatusBarStyle = Style;\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst StatusBar = registerPlugin('StatusBar');\nexport * from './definitions';\nexport { StatusBar };\n//# sourceMappingURL=index.js.map"],"names":["Style","Animation","registerPlugin"],"mappings":";;;AAAWA,2BAAM;IACjB,CAAC,UAAU,KAAK,EAAE;IAClB;IACA;IACA;IACA;IACA;IACA,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC3B;IACA;IACA;IACA;IACA;IACA,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC7B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,KAAK,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IACjC,CAAC,EAAEA,aAAK,KAAKA,aAAK,GAAG,EAAE,CAAC,CAAC,CAAC;AACfC,+BAAU;IACrB,CAAC,UAAU,SAAS,EAAE;IACtB;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC/B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACjC;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC/B,CAAC,EAAEA,iBAAS,KAAKA,iBAAS,GAAG,EAAE,CAAC,CAAC,CAAC;IAClC;IACA;IACA;IACA;AACY,UAAC,kBAAkB,GAAGA,kBAAU;IAC5C;IACA;IACA;IACA;AACY,UAAC,cAAc,GAAGD;;ACxDzB,UAAC,SAAS,GAAGE,mBAAc,CAAC,WAAW;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js"],"sourcesContent":["/// <reference types=\"@capacitor/cli\" />\nexport var Style;\n(function (Style) {\n /**\n * Light text for dark backgrounds.\n *\n * @since 1.0.0\n */\n Style[\"Dark\"] = \"DARK\";\n /**\n * Dark text for light backgrounds.\n *\n * @since 1.0.0\n */\n Style[\"Light\"] = \"LIGHT\";\n /**\n * The style is based on the device appearance.\n * If the device is using Dark mode, the statusbar text will be light.\n * If the device is using Light mode, the statusbar text will be dark.\n * On Android the default will be the one the app was launched with.\n *\n * @since 1.0.0\n */\n Style[\"Default\"] = \"DEFAULT\";\n})(Style || (Style = {}));\nexport var Animation;\n(function (Animation) {\n /**\n * No animation during show/hide.\n *\n * @since 1.0.0\n */\n Animation[\"None\"] = \"NONE\";\n /**\n * Slide animation during show/hide.\n * It doesn't work on iOS 15+.\n *\n * @deprecated Use Animation.Fade or Animation.None instead.\n *\n * @since 1.0.0\n */\n Animation[\"Slide\"] = \"SLIDE\";\n /**\n * Fade animation during show/hide.\n *\n * @since 1.0.0\n */\n Animation[\"Fade\"] = \"FADE\";\n})(Animation || (Animation = {}));\n/**\n * @deprecated Use `Animation`.\n * @since 1.0.0\n */\nexport const StatusBarAnimation = Animation;\n/**\n * @deprecated Use `Style`.\n * @since 1.0.0\n */\nexport const StatusBarStyle = Style;\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst StatusBar = registerPlugin('StatusBar');\nexport * from './definitions';\nexport { StatusBar };\n//# sourceMappingURL=index.js.map"],"names":["Style","Animation","registerPlugin"],"mappings":";;;IAAA;AACWA,2BAAM;IACjB,CAAC,UAAU,KAAK,EAAE;IAClB;IACA;IACA;IACA;IACA;IACA,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC3B;IACA;IACA;IACA;IACA;IACA,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC7B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,KAAK,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IACjC,CAAC,EAAEA,aAAK,KAAKA,aAAK,GAAG,EAAE,CAAC,CAAC,CAAC;AACfC,+BAAU;IACrB,CAAC,UAAU,SAAS,EAAE;IACtB;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC/B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACjC;IACA;IACA;IACA;IACA;IACA,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC/B,CAAC,EAAEA,iBAAS,KAAKA,iBAAS,GAAG,EAAE,CAAC,CAAC,CAAC;IAClC;IACA;IACA;IACA;AACY,UAAC,kBAAkB,GAAGA,kBAAU;IAC5C;IACA;IACA;IACA;AACY,UAAC,cAAc,GAAGD;;ACzDzB,UAAC,SAAS,GAAGE,mBAAc,CAAC,WAAW;;;;;;;;;;;;;;"}
@@ -0,0 +1,14 @@
1
+ import Capacitor
2
+
3
+ extension CAPBridgeViewController {
4
+
5
+ open override func viewDidAppear(_ animated: Bool) {
6
+ super.viewDidAppear(animated)
7
+ NotificationCenter.default.post(Notification(name: .capacitorViewDidAppear))
8
+ }
9
+
10
+ open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
11
+ super.viewWillTransition(to: size, with: coordinator)
12
+ NotificationCenter.default.post(Notification(name: .capacitorViewWillTransition))
13
+ }
14
+ }
@@ -0,0 +1,6 @@
1
+ import Capacitor
2
+
3
+ extension Notification.Name {
4
+ public static let capacitorViewDidAppear = Notification.Name(rawValue: "CapacitorViewDidAppear")
5
+ public static let capacitorViewWillTransition = Notification.Name(rawValue: "CapacitorViewWillTransition")
6
+ }
@@ -0,0 +1,175 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ public extension Notification.Name {
5
+ static let statusBarVisibilityChanged = Notification.Name("statusBarVisibilityChanged")
6
+ static let statusBarOverlayChanged = Notification.Name("statusBarOverlayChanged")
7
+ }
8
+
9
+ @objc public class StatusBar: NSObject {
10
+
11
+ private var bridge: CAPBridgeProtocol
12
+ private var isOverlayingWebview = true
13
+ private var backgroundColor = UIColor.black
14
+ private var backgroundView: UIView?
15
+ private var observers: [NSObjectProtocol] = []
16
+
17
+ init(bridge: CAPBridgeProtocol, config: StatusBarConfig) {
18
+ self.bridge = bridge
19
+ super.init()
20
+ setupObservers(with: config)
21
+ }
22
+
23
+ deinit {
24
+ observers.forEach { NotificationCenter.default.removeObserver($0) }
25
+ }
26
+
27
+ private func setupObservers(with config: StatusBarConfig) {
28
+ observers.append(NotificationCenter.default.addObserver(forName: .capacitorViewDidAppear, object: .none, queue: .none) { [weak self] _ in
29
+ self?.handleViewDidAppear(config: config)
30
+ })
31
+ observers.append(NotificationCenter.default.addObserver(forName: .capacitorStatusBarTapped, object: .none, queue: .none) { [weak self] _ in
32
+ self?.bridge.triggerJSEvent(eventName: "statusTap", target: "window")
33
+ })
34
+ observers.append(NotificationCenter.default.addObserver(forName: .capacitorViewWillTransition, object: .none, queue: .none) { [weak self] _ in
35
+ self?.handleViewWillTransition()
36
+ })
37
+ }
38
+
39
+ private func handleViewDidAppear(config: StatusBarConfig) {
40
+ setStyle(config.style)
41
+ setBackgroundColor(config.backgroundColor)
42
+ setOverlaysWebView(config.overlaysWebView)
43
+ }
44
+
45
+ private func handleViewWillTransition() {
46
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
47
+ self?.resizeStatusBarBackgroundView()
48
+ self?.resizeWebView()
49
+ }
50
+ }
51
+
52
+ func setStyle(_ style: UIStatusBarStyle) {
53
+ bridge.statusBarStyle = style
54
+ }
55
+
56
+ func setBackgroundColor(_ color : UIColor) {
57
+ backgroundColor = color
58
+ backgroundView?.backgroundColor = color
59
+ }
60
+
61
+ func setAnimation(_ animation: String) {
62
+ if animation == "SLIDE" {
63
+ bridge.statusBarAnimation = .slide
64
+ } else if animation == "NONE" {
65
+ bridge.statusBarAnimation = .none
66
+ } else {
67
+ bridge.statusBarAnimation = .fade
68
+ }
69
+ }
70
+
71
+ func hide(animation: String) {
72
+ setAnimation(animation)
73
+ if bridge.statusBarVisible {
74
+ bridge.statusBarVisible = false
75
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
76
+ self?.resizeWebView()
77
+ self?.backgroundView?.removeFromSuperview()
78
+ self?.backgroundView?.isHidden = true
79
+ }
80
+ NotificationCenter.default.post(name: .statusBarVisibilityChanged, object: getInfo())
81
+ }
82
+ }
83
+
84
+ func show(animation: String) {
85
+ setAnimation(animation)
86
+ if !bridge.statusBarVisible {
87
+ bridge.statusBarVisible = true
88
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [self] in
89
+ resizeWebView()
90
+ if !isOverlayingWebview {
91
+ resizeStatusBarBackgroundView()
92
+ bridge.webView?.superview?.addSubview(backgroundView!)
93
+ }
94
+ backgroundView?.isHidden = false
95
+ }
96
+ NotificationCenter.default.post(name: .statusBarVisibilityChanged, object: getInfo())
97
+ }
98
+ }
99
+
100
+ func getInfo() -> StatusBarInfo {
101
+ let style: String
102
+ switch bridge.statusBarStyle {
103
+ case .default:
104
+ style = "DEFAULT"
105
+ case .lightContent:
106
+ style = "DARK"
107
+ case .darkContent:
108
+ style = "LIGHT"
109
+ @unknown default:
110
+ style = "DEFAULT"
111
+ }
112
+
113
+ return StatusBarInfo(
114
+ overlays: isOverlayingWebview,
115
+ visible: bridge.statusBarVisible,
116
+ style: style,
117
+ color: UIColor.capacitor.hex(fromColor: backgroundColor),
118
+ height: getStatusBarFrame().size.height
119
+ )
120
+ }
121
+
122
+ func setOverlaysWebView(_ overlay: Bool) {
123
+ if overlay == isOverlayingWebview { return }
124
+ isOverlayingWebview = overlay
125
+ if overlay {
126
+ backgroundView?.removeFromSuperview()
127
+ } else {
128
+ initializeBackgroundViewIfNeeded()
129
+ bridge.webView?.superview?.addSubview(backgroundView!)
130
+ }
131
+ resizeWebView()
132
+ NotificationCenter.default.post(name: .statusBarOverlayChanged, object: getInfo())
133
+ }
134
+
135
+ private func resizeWebView() {
136
+ guard
137
+ let webView = bridge.webView,
138
+ let bounds = bridge.viewController?.view.window?.windowScene?.screen.bounds
139
+ else { return }
140
+ bridge.viewController?.view.frame = bounds
141
+ webView.frame = bounds
142
+ let statusBarHeight = getStatusBarFrame().size.height;
143
+ var webViewFrame = webView.frame;
144
+
145
+ if isOverlayingWebview {
146
+ let safeAreaTop = webView.safeAreaInsets.top;
147
+ if (statusBarHeight >= safeAreaTop && safeAreaTop > 0) {
148
+ webViewFrame.origin.y = safeAreaTop == 40 ? 20 : statusBarHeight - safeAreaTop
149
+ } else {
150
+ webViewFrame.origin.y = 0
151
+ }
152
+ } else {
153
+ webViewFrame.origin.y = statusBarHeight;
154
+ }
155
+ webViewFrame.size.height -= webViewFrame.origin.y
156
+ webView.frame = webViewFrame
157
+ }
158
+
159
+ private func resizeStatusBarBackgroundView() {
160
+ backgroundView?.frame = getStatusBarFrame()
161
+ }
162
+
163
+ private func getStatusBarFrame() -> CGRect {
164
+ return UIApplication.shared.windows.first(where: { $0.isKeyWindow })?.windowScene?.statusBarManager?.statusBarFrame ?? .zero
165
+ }
166
+
167
+ private func initializeBackgroundViewIfNeeded() {
168
+ if backgroundView == nil {
169
+ backgroundView = UIView(frame: getStatusBarFrame())
170
+ backgroundView!.backgroundColor = backgroundColor
171
+ backgroundView!.autoresizingMask = [.flexibleWidth, .flexibleBottomMargin]
172
+ backgroundView!.isHidden = !bridge.statusBarVisible
173
+ }
174
+ }
175
+ }
@@ -0,0 +1,7 @@
1
+ import UIKit
2
+
3
+ public struct StatusBarConfig {
4
+ var overlaysWebView = true
5
+ var backgroundColor: UIColor = .black
6
+ var style: UIStatusBarStyle = .default
7
+ }
@@ -0,0 +1,9 @@
1
+ import Foundation
2
+
3
+ public struct StatusBarInfo {
4
+ public var overlays: Bool?
5
+ public var visible: Bool?
6
+ public var style: String?
7
+ public var color: String?
8
+ public var height: CGFloat?
9
+ }
@@ -15,92 +15,93 @@ public class StatusBarPlugin: CAPPlugin, CAPBridgedPlugin {
15
15
  CAPPluginMethod(name: "show", returnType: CAPPluginReturnPromise),
16
16
  CAPPluginMethod(name: "hide", returnType: CAPPluginReturnPromise),
17
17
  CAPPluginMethod(name: "getInfo", returnType: CAPPluginReturnPromise),
18
- CAPPluginMethod(name: "setOverlaysWebView", returnType: CAPPluginReturnPromise)
18
+ CAPPluginMethod(name: "setOverlaysWebView", returnType: CAPPluginReturnPromise),
19
19
  ]
20
- private var observer: NSObjectProtocol?
21
-
20
+ private var statusBar: StatusBar?
21
+
22
22
  override public func load() {
23
- observer = NotificationCenter.default.addObserver(forName: Notification.Name.capacitorStatusBarTapped, object: .none, queue: .none) { [weak self] _ in
24
- self?.bridge?.triggerJSEvent(eventName: "statusTap", target: "window")
23
+ guard let bridge = bridge else { return }
24
+ statusBar = StatusBar(bridge: bridge, config: statusBarConfig())
25
+ }
26
+
27
+ private func statusBarConfig() -> StatusBarConfig {
28
+ var config = StatusBarConfig()
29
+ config.overlaysWebView = getConfig().getBoolean("overlaysWebView", config.overlaysWebView)
30
+ if let colorConfig = getConfig().getString("backgroundColor"), let color = UIColor.capacitor.color(fromHex: colorConfig)
31
+ {
32
+ config.backgroundColor = color
33
+ }
34
+ if let configStyle = getConfig().getString("style") {
35
+ config.style = style(fromString: configStyle)
25
36
  }
37
+ return config
26
38
  }
27
-
28
- deinit {
29
- if let observer = observer {
30
- NotificationCenter.default.removeObserver(observer)
39
+
40
+ private func style(fromString: String) -> UIStatusBarStyle {
41
+ switch fromString.lowercased() {
42
+ case "dark", "lightcontent":
43
+ return .lightContent
44
+ case "light", "darkcontent":
45
+ return .darkContent
46
+ case "default":
47
+ return .default
48
+ default:
49
+ return .default
31
50
  }
32
51
  }
33
52
 
34
53
  @objc func setStyle(_ call: CAPPluginCall) {
35
54
  let options = call.options!
36
-
37
- if let style = options["style"] as? String {
38
- if style == "DARK" {
39
- bridge?.statusBarStyle = .lightContent
40
- } else if style == "LIGHT" {
41
- bridge?.statusBarStyle = .darkContent
42
- } else if style == "DEFAULT" {
43
- bridge?.statusBarStyle = .default
44
- }
55
+ if let styleString = options["style"] as? String {
56
+ statusBar?.setStyle(style(fromString: styleString))
45
57
  }
46
-
47
58
  call.resolve([:])
48
59
  }
49
60
 
50
61
  @objc func setBackgroundColor(_ call: CAPPluginCall) {
51
- call.unimplemented()
52
- }
53
-
54
- func setAnimation(_ call: CAPPluginCall) {
55
- let animation = call.getString("animation", "FADE")
56
- if animation == "SLIDE" {
57
- bridge?.statusBarAnimation = .slide
58
- } else if animation == "NONE" {
59
- bridge?.statusBarAnimation = .none
60
- } else {
61
- bridge?.statusBarAnimation = .fade
62
+ guard
63
+ let hexString = call.options["color"] as? String,
64
+ let color = UIColor.capacitor.color(fromHex: hexString)
65
+ else { return }
66
+ DispatchQueue.main.async { [weak self] in
67
+ self?.statusBar?.setBackgroundColor(color)
62
68
  }
69
+ call.resolve()
63
70
  }
64
-
71
+
65
72
  @objc func hide(_ call: CAPPluginCall) {
66
- setAnimation(call)
67
- bridge?.statusBarVisible = false
73
+ let animation = call.getString("animation", "FADE")
74
+ DispatchQueue.main.async { [weak self] in
75
+ self?.statusBar?.hide(animation: animation)
76
+ }
68
77
  call.resolve()
69
78
  }
70
79
 
71
80
  @objc func show(_ call: CAPPluginCall) {
72
- setAnimation(call)
73
- bridge?.statusBarVisible = true
81
+ let animation = call.getString("animation", "FADE")
82
+ DispatchQueue.main.async { [weak self] in
83
+ self?.statusBar?.show(animation: animation)
84
+ }
74
85
  call.resolve()
75
86
  }
76
-
87
+
77
88
  @objc func getInfo(_ call: CAPPluginCall) {
78
89
  DispatchQueue.main.async { [weak self] in
79
- guard let bridge = self?.bridge else {
80
- return
81
- }
82
- let style: String
83
- switch bridge.statusBarStyle {
84
- case .default:
85
- if bridge.userInterfaceStyle == UIUserInterfaceStyle.dark {
86
- style = "DARK"
87
- } else {
88
- style = "LIGHT"
89
- }
90
- case .lightContent:
91
- style = "DARK"
92
- default:
93
- style = "LIGHT"
94
- }
95
-
90
+ guard let info = self?.statusBar?.getInfo() else { return }
96
91
  call.resolve([
97
- "visible": bridge.statusBarVisible,
98
- "style": style
92
+ "visible": info.visible!,
93
+ "style": info.style!,
94
+ "color": info.color!,
95
+ "overlays": info.overlays!
99
96
  ])
100
97
  }
101
98
  }
102
99
 
103
100
  @objc func setOverlaysWebView(_ call: CAPPluginCall) {
104
- call.unimplemented()
101
+ guard let overlay = call.options["overlay"] as? Bool else { return }
102
+ DispatchQueue.main.async { [weak self] in
103
+ self?.statusBar?.setOverlaysWebView(overlay)
104
+ }
105
+ call.resolve()
105
106
  }
106
107
  }
@@ -0,0 +1,40 @@
1
+ import Capacitor
2
+
3
+ public extension CapacitorExtensionTypeWrapper where T: UIColor {
4
+
5
+ static func hex(fromColor: UIColor) -> String? {
6
+ var red: CGFloat = 0
7
+ var green: CGFloat = 0
8
+ var blue: CGFloat = 0
9
+ var alpha: CGFloat = 0
10
+
11
+ guard fromColor.getRed(&red, green: &green, blue: &blue, alpha: &alpha) else {
12
+ assertionFailure("Failed to get RGBA components from UIColor")
13
+ return nil
14
+ }
15
+
16
+ red = max(0, min(1, red))
17
+ green = max(0, min(1, green))
18
+ blue = max(0, min(1, blue))
19
+ alpha = max(0, min(1, alpha))
20
+
21
+ if alpha == 1 {
22
+ // RGB
23
+ return String(
24
+ format: "#%02lX%02lX%02lX",
25
+ Int(round(red * 255)),
26
+ Int(round(green * 255)),
27
+ Int(round(blue * 255))
28
+ )
29
+ } else {
30
+ // RGBA
31
+ return String(
32
+ format: "#%02lX%02lX%02lX%02lX",
33
+ Int(round(red * 255)),
34
+ Int(round(green * 255)),
35
+ Int(round(blue * 255)),
36
+ Int(round(alpha * 255))
37
+ )
38
+ }
39
+ }
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/status-bar",
3
- "version": "6.0.1",
3
+ "version": "6.0.2-dev-2179-20240822T152050.0",
4
4
  "description": "The StatusBar API Provides methods for configuring the style of the Status Bar, along with showing or hiding it.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -80,6 +80,5 @@
80
80
  },
81
81
  "publishConfig": {
82
82
  "access": "public"
83
- },
84
- "gitHead": "4fa3245a6f82aa7ccec734c50e7d82ea0a624b16"
83
+ }
85
84
  }