diff options
author | SnackpackWayne <49062420+snackpackwayne@users.noreply.github.com> | 2023-12-27 22:38:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-27 22:38:01 +0100 |
commit | 52cb777c9432354302b3285e141aa96632af34d5 (patch) | |
tree | 0b823b5816f040990af0ee2fc7815a2f1a063fca /src/lib/ThemeContext.tsx | |
parent | 538c67cc332a6b909f83dd382843667dcced0fe9 (diff) | |
parent | f402f33a024ea59ea9bd2decfc0444e6836a934c (diff) | |
download | voidsky-52cb777c9432354302b3285e141aa96632af34d5.tar.zst |
Merge branch 'main' into patch-1
Diffstat (limited to 'src/lib/ThemeContext.tsx')
-rw-r--r-- | src/lib/ThemeContext.tsx | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/src/lib/ThemeContext.tsx b/src/lib/ThemeContext.tsx index 483c50c42..38bd199cb 100644 --- a/src/lib/ThemeContext.tsx +++ b/src/lib/ThemeContext.tsx @@ -1,9 +1,7 @@ -import {isWeb} from 'platform/detection' import React, {ReactNode, createContext, useContext} from 'react' import { - AppState, TextStyle, - useColorScheme as useColorScheme_BUGGY, + useColorScheme, ViewStyle, ColorSchemeName, } from 'react-native' @@ -97,37 +95,11 @@ function getTheme(theme: ColorSchemeName) { return theme === 'dark' ? darkTheme : defaultTheme } -/** - * With RN iOS, we can only "trust" the color scheme reported while the app is - * active. This is a workaround until the bug is fixed upstream. - * - * @see https://github.com/bluesky-social/social-app/pull/1417#issuecomment-1719868504 - * @see https://github.com/facebook/react-native/pull/39439 - */ -function useColorScheme_FIXED() { - const colorScheme = useColorScheme_BUGGY() - const [currentColorScheme, setCurrentColorScheme] = - React.useState<ColorSchemeName>(colorScheme) - - React.useEffect(() => { - // we don't need to be updating state on web - if (isWeb) return - const subscription = AppState.addEventListener('change', state => { - const isActive = state === 'active' - if (!isActive) return - setCurrentColorScheme(colorScheme) - }) - return () => subscription.remove() - }, [colorScheme]) - - return isWeb ? colorScheme : currentColorScheme -} - export const ThemeProvider: React.FC<ThemeProviderProps> = ({ theme, children, }) => { - const colorScheme = useColorScheme_FIXED() + const colorScheme = useColorScheme() const themeValue = getTheme(theme === 'system' ? colorScheme : theme) return ( |