diff --git a/status-bar/README.md b/status-bar/README.md index c7b1c0a13..e5f23fae9 100644 --- a/status-bar/README.md +++ b/status-bar/README.md @@ -127,7 +127,10 @@ export default config; * [`hide(...)`](#hide) * [`getInfo()`](#getinfo) * [`setOverlaysWebView(...)`](#setoverlayswebview) +* [`addListener('statusBarVisibilityChanged', ...)`](#addlistenerstatusbarvisibilitychanged-) +* [`addListener('statusBarOverlayChanged', ...)`](#addlistenerstatusbaroverlaychanged-) * [Interfaces](#interfaces) +* [Type Aliases](#type-aliases) * [Enums](#enums) @@ -243,6 +246,48 @@ Not available on Android 15+. -------------------- +### addListener('statusBarVisibilityChanged', ...) + +```typescript +addListener(eventName: 'statusBarVisibilityChanged', listenerFunc: VisibilityChangeListener) => Promise +``` + +Listen for status bar visibility changes. +Fired when hide or show methods get called. + +| Param | Type | +| ------------------ | ----------------------------------------------------------------------------- | +| **`eventName`** | 'statusBarVisibilityChanged' | +| **`listenerFunc`** | VisibilityChangeListener | + +**Returns:** Promise<PluginListenerHandle> + +**Since:** 7.0.0 + +-------------------- + + +### addListener('statusBarOverlayChanged', ...) + +```typescript +addListener(eventName: 'statusBarOverlayChanged', listenerFunc: OverlayChangeListener) => Promise +``` + +Listen for status bar overlay changes. +Fired when setOverlaysWebView gets called. + +| Param | Type | +| ------------------ | ----------------------------------------------------------------------- | +| **`eventName`** | 'statusBarOverlayChanged' | +| **`listenerFunc`** | OverlayChangeListener | + +**Returns:** Promise<PluginListenerHandle> + +**Since:** 7.0.0 + +-------------------- + + ### Interfaces @@ -269,12 +314,13 @@ Not available on Android 15+. #### StatusBarInfo -| Prop | Type | Description | Since | -| -------------- | --------------------------------------- | ----------------------------------------- | ----- | -| **`visible`** | boolean | Whether the status bar is visible or not. | 1.0.0 | -| **`style`** | Style | The current status bar style. | 1.0.0 | -| **`color`** | string | The current status bar color. | 1.0.0 | -| **`overlays`** | boolean | Whether the statusbar is overlaid or not. | 1.0.0 | +| Prop | Type | Description | Since | +| -------------- | --------------------------------------- | ------------------------------------------ | ----- | +| **`visible`** | boolean | Whether the status bar is visible or not. | 1.0.0 | +| **`style`** | Style | The current status bar style. | 1.0.0 | +| **`color`** | string | The current status bar color. | 1.0.0 | +| **`overlays`** | boolean | Whether the status bar is overlaid or not. | 1.0.0 | +| **`height`** | number | The height of the status bar. | 7.0.0 | #### SetOverlaysWebViewOptions @@ -284,6 +330,26 @@ Not available on Android 15+. | **`overlay`** | boolean | Whether to overlay the status bar or not. | 1.0.0 | +#### PluginListenerHandle + +| Prop | Type | +| ------------ | ----------------------------------------- | +| **`remove`** | () => Promise<void> | + + +### Type Aliases + + +#### VisibilityChangeListener + +(info: StatusBarInfo): void + + +#### OverlayChangeListener + +(info: StatusBarInfo): void + + ### Enums diff --git a/status-bar/src/definitions.ts b/status-bar/src/definitions.ts index 3b35b76f3..fb903d9e5 100644 --- a/status-bar/src/definitions.ts +++ b/status-bar/src/definitions.ts @@ -1,5 +1,7 @@ /// +import type { PluginListenerHandle } from '@capacitor/core'; + declare module '@capacitor/cli' { export interface PluginsConfig { /** @@ -141,14 +143,21 @@ export interface StatusBarInfo { * * @since 1.0.0 */ - color?: string; + color: string; /** - * Whether the statusbar is overlaid or not. + * Whether the status bar is overlaid or not. * * @since 1.0.0 */ - overlays?: boolean; + overlays: boolean; + + /** + * The height of the status bar. + * + * @since 7.0.0 + */ + height: number; } export interface SetOverlaysWebViewOptions { @@ -160,6 +169,9 @@ export interface SetOverlaysWebViewOptions { overlay: boolean; } +export type VisibilityChangeListener = (info: StatusBarInfo) => void; +export type OverlayChangeListener = (info: StatusBarInfo) => void; + export interface StatusBarPlugin { /** * Set the current style of the status bar. @@ -210,6 +222,25 @@ export interface StatusBarPlugin { * @since 1.0.0 */ setOverlaysWebView(options: SetOverlaysWebViewOptions): Promise; + + /** + * Listen for status bar visibility changes. + * Fired when hide or show methods get called. + * + * @since 7.0.0 + */ + addListener( + eventName: 'statusBarVisibilityChanged', + listenerFunc: VisibilityChangeListener, + ): Promise; + + /** + * Listen for status bar overlay changes. + * Fired when setOverlaysWebView gets called. + * + * @since 7.0.0 + */ + addListener(eventName: 'statusBarOverlayChanged', listenerFunc: OverlayChangeListener): Promise; } /**