mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
fix(native): catch the status bar style call where the app has no status bar plugin
An unanswered rejection from StatusBar.setStyle surfaced in the sign-in screen's tests, where the web build has no such plugin. Unimplemented is no failure; anything else is reported as the other native calls are.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { StatusBar, Style } from '@capacitor/status-bar';
|
||||
import { isNativeAndroid, isNativeApp } from './platform';
|
||||
import { reportNativeFailure } from './reportFailure';
|
||||
import { isUnimplemented } from './trekShell';
|
||||
|
||||
/**
|
||||
* The handover from the app's address screen to this server's UI.
|
||||
@@ -98,9 +100,16 @@ const ANDROID_WEBVIEW_UNDER_BARS = 140;
|
||||
*/
|
||||
export function lightStatusBarIcons(): () => void {
|
||||
if (!isNativeApp() || !pageUnderStatusBar()) return () => undefined;
|
||||
void StatusBar.setStyle({ style: Style.Dark });
|
||||
setStatusBarStyle(Style.Dark);
|
||||
return () => {
|
||||
const dark = document.documentElement.classList.contains('dark');
|
||||
void StatusBar.setStyle({ style: dark ? Style.Dark : Style.Light });
|
||||
setStatusBarStyle(dark ? Style.Dark : Style.Light);
|
||||
};
|
||||
}
|
||||
|
||||
/** Where there is no status bar to style (a build without the plugin) nothing is wrong. */
|
||||
function setStatusBarStyle(style: Style): void {
|
||||
StatusBar.setStyle({ style }).catch((err: unknown) => {
|
||||
if (!isUnimplemented(err)) reportNativeFailure(err);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user