Files
discord-decomp/modules/themes/RootThemeContextProvider.native.tsx
T
2026-11-01 12:12:55 +02:00

53 lines
3.0 KiB
TypeScript

// Metro module 13623 (f13624).
import { useMemo } from "react";
import AccessibilityStore from "../a11y/AccessibilityStore";
import ThemeStore from "../user_settings/ThemeStore";
import { ThemeTypes } from "../../_bundle/Module505";
import { useStateFromStoresObject } from "../../_bundle/Module589";
import useColorThemeBackground from "../client_themes/native/useColorThemeBackground";
import { useMobileVisualRefreshConfig } from "./experiments/MobileVisualRefreshExperiment";
import { useManaTypeConsolidationExperiment } from "../design/ManaTypeConsolidationExperiment";
import { setThemeFlag, ThemeContextFlags } from "../../_bundle/Module3901";
import * as _RootThemeContextProvider_native from "../../design/components/ThemeContextProvider/native/RootThemeContextProvider.native";
export function RootThemeContextProvider(props) {
let enabled, chatInputFloating, chatInputLegacySendButton, manaTypeConsolidationExperiment;
const children = props.children;
enabled = void 0;
chatInputFloating = void 0;
chatInputLegacySendButton = void 0;
manaTypeConsolidationExperiment = void 0;
const stateFromStoresObject = useStateFromStoresObject([AccessibilityStore, ThemeStore], () => ({
saturation: AccessibilityStore.saturation,
contrast: AccessibilityStore.contrast,
theme: ThemeStore.theme
}));
const { saturation, contrast, theme } = stateFromStoresObject;
const colorThemeBackground = useColorThemeBackground();
const mobileVisualRefreshConfig = useMobileVisualRefreshConfig({
location: "RootThemeContextProvider"
});
enabled = mobileVisualRefreshConfig.enabled;
chatInputFloating = mobileVisualRefreshConfig.chatInputFloating;
chatInputLegacySendButton = mobileVisualRefreshConfig.chatInputLegacySendButton;
manaTypeConsolidationExperiment = useManaTypeConsolidationExperiment("RootThemeContextProvider");
const memo = useMemo(() => {
const r3 = [];
if (chatInputLegacySendButton) {
r3.push("mobile-visual-refresh-legacy-send-button");
}
if (chatInputFloating) {
r3.push("mobile-visual-refresh-floating");
}
if (enabled) {
r3.push("mobile-visual-refresh");
}
if (manaTypeConsolidationExperiment) {
r3.push("mana-type-consolidation");
}
return r3.length > 0 ? r3 : void 0;
}, [enabled, chatInputFloating, chatInputLegacySendButton, manaTypeConsolidationExperiment]);
const r43 = colorThemeBackground != null ? colorThemeBackground.theme === ThemeTypes.LIGHT ? setThemeFlag(0, ThemeContextFlags.MOBILE_LIGHT_GRADIENT_THEME_ENABLED) : setThemeFlag(0, ThemeContextFlags.MOBILE_DARK_GRADIENT_THEME_ENABLED) : 0;
const r63 = saturation !== 1 ? setThemeFlag(r43, ThemeContextFlags.REDUCE_SATURATION_ENABLED) : r43;
return <_RootThemeContextProvider_native.RootThemeContextProvider theme={theme} flags={contrast !== 1 ? setThemeFlag(r63, contrast > 1 ? ThemeContextFlags.INCREASED_CONTRAST_ENABLED : ThemeContextFlags.REDUCED_CONTRAST_ENABLED) : r63} saturation={saturation} contrast={contrast} enabledExperiments={memo}>{children}</_RootThemeContextProvider_native.RootThemeContextProvider>;
}