build: d805a69a-e437-4a58-a083-30e34be74fcd
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { StatusBar, Style } from '@capacitor/status-bar';
|
||||
export { Style };
|
||||
|
||||
const _origin = (() => {
|
||||
try {
|
||||
if (document.referrer) return new URL(document.referrer).origin;
|
||||
} catch {}
|
||||
return window.location.origin;
|
||||
})();
|
||||
|
||||
/** Set status bar icon/text colour. Use instead of StatusBar.setStyle directly. */
|
||||
export async function setStatusBarStyle(style: Style): Promise<void> {
|
||||
try {
|
||||
await StatusBar.setStyle({ style });
|
||||
} catch {}
|
||||
if (window.parent !== window) {
|
||||
window.parent.postMessage({ type: '__apsuite_statusbar', style }, _origin);
|
||||
}
|
||||
}
|
||||
|
||||
/** Set status bar background colour (Android). Use instead of StatusBar.setBackgroundColor directly. */
|
||||
export async function setStatusBarBackground(color: string): Promise<void> {
|
||||
try {
|
||||
await (StatusBar as any).setBackgroundColor({ color });
|
||||
} catch {}
|
||||
if (window.parent !== window) {
|
||||
window.parent.postMessage(
|
||||
{ type: '__apsuite_statusbar_bg', color },
|
||||
_origin
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user