Skip to content

Commit 9574e4f

Browse files
committed
Reduce risk of flash bang when opening the app in dark mode
Changelog: fix
1 parent f01a501 commit 9574e4f

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

apps/polycentric/app/_layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ function RootStack() {
5252
...); deep-linked profile/post views stay public everywhere. On
5353
web the tabs stay routable and get granular guards instead. */}
5454
<Stack.Protected guard={isWeb || accountGuard}>
55-
<Stack.Screen name="(tabs)" />
55+
<Stack.Screen name="(tabs)" options={{ animation: 'none' }} />
5656
</Stack.Protected>
5757

58-
<Stack.Screen name="(onboarding)" />
58+
<Stack.Screen name="(onboarding)" options={{ animation: 'none' }} />
5959

6060
{/* Account-only on every platform. Routes are auto-registered from
6161
the filesystem; the explicit declarations here exist to place

apps/polycentric/src/common/theme/provider.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
type PropsWithChildren,
1515
} from 'react';
1616
import { Appearance, useColorScheme } from 'react-native';
17+
import * as SystemUI from 'expo-system-ui';
1718
import { useSettings } from '@/src/common/settings';
1819
import { themes, type Theme, type ThemeKey } from './themes';
1920

@@ -55,6 +56,13 @@ export function ThemeProvider({ children }: PropsWithChildren) {
5556

5657
const theme = useMemo(() => themes[activeThemeName], [activeThemeName]);
5758

59+
// Keep the native window background in sync with the theme so the
60+
// moments where no surface has painted (splash dismissal, stack
61+
// transitions) don't flash the default white window.
62+
useEffect(() => {
63+
void SystemUI.setBackgroundColorAsync(theme.palette.neutral_0);
64+
}, [theme]);
65+
5866
const value = useMemo(
5967
() => ({ theme, activeThemeName, setActiveThemeName }),
6068
[theme, activeThemeName, setActiveThemeName],

0 commit comments

Comments
 (0)