diff --git a/src/lib/addons/themes/colors/index.ts b/src/lib/addons/themes/colors/index.ts index 1da31dc..5d4ade2 100644 --- a/src/lib/addons/themes/colors/index.ts +++ b/src/lib/addons/themes/colors/index.ts @@ -3,6 +3,7 @@ import patchDefinitionAndResolver from "./patches/resolver"; import patchStorage from "./patches/storage"; import { ColorManifest } from "./types"; import { updateBunnyColor } from "./updater"; +import fixStatusBar from "./statusbar"; /** @internal */ export default function initColors(manifest: ColorManifest | null) { @@ -11,8 +12,9 @@ export default function initColors(manifest: ColorManifest | null) { const patches = [ patchStorage(), patchDefinitionAndResolver(), - patchChatBackground() + patchChatBackground(), + fixStatusBar() ]; - return () => patches.forEach(p => p()); -} \ No newline at end of file + return () => patches.forEach(p => p && (typeof p === "function" ? p() : null)); +} diff --git a/src/lib/addons/themes/colors/statusbar.ts b/src/lib/addons/themes/colors/statusbar.ts index 22f0f38..614e141 100644 --- a/src/lib/addons/themes/colors/statusbar.ts +++ b/src/lib/addons/themes/colors/statusbar.ts @@ -1,4 +1,4 @@ -import { StatusBar, TextInput, Platform } from "react-native"; +import { StatusBar, Platform } from "react-native"; import { findByStoreNameLazy } from "@metro/wrappers"; import { _colorRef } from "./updater"; @@ -7,15 +7,8 @@ const ThemeStore = findByStoreNameLazy("ThemeStore"); function getBarStyle() { // Check for custom theme const custom = _colorRef.current; - if (custom) { - // Bunny theme (spec 3) - if (custom.spec === 3 && custom.reference) { - return custom.reference === "light" ? "dark-content" : "light-content"; - } - // Vendetta theme (spec 2) - if (custom.spec === 2 && custom.reference) { - return custom.reference === "light" ? "dark-content" : "light-content"; - } + if (custom?.reference) { + return custom.reference === "light" ? "dark-content" : "light-content"; } // Fallback to Discord theme string @@ -25,33 +18,35 @@ function getBarStyle() { return (lowerTheme.includes("dark") || lowerTheme.includes("midnight")) ? "light-content" : "dark-content"; } - return "dark-content"; + return "light-content"; } export default function fixStatusBar() { + function applyStatusBar() { + const style = getBarStyle(); + StatusBar.setBarStyle(style, true); - if (Platform.OS == "android") { + if (Platform.OS === "android") { + StatusBar.setTranslucent?.(true); + StatusBar.setBackgroundColor?.("#00000000", true); + } + } + + if (Platform.OS === "android") { const origSetBarStyle = StatusBar.setBarStyle; StatusBar.setBarStyle = function (_style: any, ...args: any[]) { return origSetBarStyle.call(this, getBarStyle(), ...args); }; } - if (Platform.OS == "ios") { - function applyStatusBar() { - const style = getBarStyle(); - StatusBar.setBarStyle(style, true); - } + const unsubscribe = ThemeStore?.addChangeListener?.(applyStatusBar); - const unsubscribe = ThemeStore?.addChangeListener?.(applyStatusBar); + applyStatusBar(); - StatusBar.setBarStyle(getBarStyle()); - - let delay = 200; - for (let i = 0; i < 5; i++, delay *= 2) { - setTimeout(applyStatusBar, delay); - } - - return unsubscribe; + let delay = 200; + for (let i = 0; i < 5; i++, delay *= 2) { + setTimeout(applyStatusBar, delay); } + + return unsubscribe; }