Skip to content

Commit

Permalink
Fix annoying error from using capacitor statusbar in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
ttmx committed Sep 25, 2024
1 parent 7e5342d commit 4730dd8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
const updateTheme = () => {
document.documentElement.setAttribute('data-theme', $appSettings.theme === 'system' ? mediaQuery.matches ? 'dark' : 'light' : $appSettings.theme);
StatusBar.setStyle({ style: $appSettings.theme === 'system' ? mediaQuery.matches ? Style.Dark : Style.Light : $appSettings.theme === 'dark' ? Style.Dark : Style.Light });
if (Capacitor.getPlatform() === 'android' || Capacitor.getPlatform() === 'ios'){
StatusBar.setStyle({ style: $appSettings.theme === 'system' ? mediaQuery.matches ? Style.Dark : Style.Light : $appSettings.theme === 'dark' ? Style.Dark : Style.Light });
}
};
appSettings.subscribe(updateTheme);
mediaQuery.addEventListener('change', updateTheme);
Expand Down

0 comments on commit 4730dd8

Please sign in to comment.