Skip to content

Commit 818d466

Browse files
feat: update theme handling and status bar integration
- Changed default status bar style to "DEFAULT" in capacitor.config.ts. - Updated index.html to dynamically set the theme based on user preference or system settings. - Enhanced App.tsx to synchronize the status bar style with the current theme during app initialization. - Modified main.tsx to adjust the status bar style based on the active theme, improving native app appearance.
1 parent be8aaa9 commit 818d466

5 files changed

Lines changed: 13 additions & 6 deletions

File tree

capacitor.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ const config: CapacitorConfig = {
2525
showSpinner: false,
2626
},
2727
StatusBar: {
28-
style: "DARK",
29-
backgroundColor: "#1A1D21",
28+
style: "DEFAULT",
3029
},
3130
Keyboard: {
3231
resize: "none",
-11 KB
Loading

packages/web/index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<!DOCTYPE html>
2-
<html lang="en" data-theme="dark">
2+
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
6+
<script>
7+
(function(){var s=localStorage.getItem("botschat_theme");var t=s==="light"||s==="dark"?s:window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark";document.documentElement.setAttribute("data-theme",t)})();
8+
</script>
69

710
<!-- PWA manifest -->
811
<link rel="manifest" href="/manifest.json" />
912

10-
<!-- Theme color — matches dark theme bg -->
1113
<meta name="theme-color" content="#1A1D21" />
1214

1315
<!-- iOS PWA support -->

packages/web/src/App.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,14 @@ export default function App() {
9797
useEffect(() => {
9898
document.documentElement.setAttribute("data-theme", theme);
9999
localStorage.setItem("botschat_theme", theme);
100-
// Sync PWA theme-color meta tag with current theme
101100
const meta = document.querySelector('meta[name="theme-color"]');
102101
if (meta) meta.setAttribute("content", theme === "dark" ? "#1A1D21" : "#FFFFFF");
102+
// Sync native status bar style on Capacitor
103+
if (Capacitor.isNativePlatform()) {
104+
import("@capacitor/status-bar").then(({ StatusBar, Style }) => {
105+
StatusBar.setStyle({ style: theme === "dark" ? Style.Dark : Style.Light }).catch(() => {});
106+
});
107+
}
103108
}, [theme]);
104109

105110
// Persist active view (messages / automations)

packages/web/src/main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ initAnalytics();
1111
if (Capacitor.isNativePlatform()) {
1212
// Configure status bar and keyboard for native app
1313
import("@capacitor/status-bar").then(({ StatusBar, Style }) => {
14-
StatusBar.setStyle({ style: Style.Dark }).catch(() => {});
14+
const isDark = document.documentElement.getAttribute("data-theme") !== "light";
15+
StatusBar.setStyle({ style: isDark ? Style.Dark : Style.Light }).catch(() => {});
1516
StatusBar.setOverlaysWebView({ overlay: true }).catch(() => {});
1617
});
1718
import("@capacitor/keyboard").then(({ Keyboard }) => {

0 commit comments

Comments
 (0)