Skip to content

Commit

Permalink
mobile: fix flash on launch on ios
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Sep 4, 2023
1 parent d5038ac commit 1775e0b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions apps/mobile/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ const App = () => {
);
};

let currTheme =
useThemeStore.getState().colorScheme === "dark"
? SettingsService.getProperty("darkTheme")
: SettingsService.getProperty("lightTheme");
useThemeEngineStore.getState().setTheme(currTheme);

export const withTheme = (Element) => {
return function AppWithThemeProvider() {
const [colorScheme, darkTheme, lightTheme] = useThemeStore((state) => [
Expand Down Expand Up @@ -125,11 +131,13 @@ export const withTheme = (Element) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
const nextTheme = colorScheme === "dark" ? darkTheme : lightTheme;
if (JSON.stringify(nextTheme) !== JSON.stringify(currTheme)) {
useThemeEngineStore
.getState()
.setTheme(colorScheme === "dark" ? darkTheme : lightTheme);
}, [colorScheme, darkTheme, lightTheme]);
currTheme = nextTheme;
}

return <Element />;
};
Expand Down

0 comments on commit 1775e0b

Please sign in to comment.