Skip to content

Commit

Permalink
adapt Themes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispader committed Nov 27, 2023
1 parent 31eb125 commit 0bfb705
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/styles/themes/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ThemeProviderProps = React.PropsWithChildren & {
function ThemeProvider({children, theme: staticThemePreference}: ThemeProviderProps) {
const themePreference = useThemePreferenceWithStaticOverride(staticThemePreference);

const theme = useMemo(() => Themes[themePreference], [themePreference]);
const theme = useMemo(() => Themes[themePreference].theme, [themePreference]);

return <ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>;
}
Expand Down
9 changes: 6 additions & 3 deletions src/styles/themes/Themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import darkTheme from './default';
import lightTheme from './light';
import {ThemeColors, ThemePreferenceWithoutSystem} from './types';

// There might be more themes than just "dark" and "light".
// Still, status bar, scrollbar and other components might need to adapt based on if the theme is overly light or dark
// e.g. the StatusBar displays either "light-content" or "dark-content" based on the theme
const Themes = {
[CONST.THEME.LIGHT]: lightTheme,
[CONST.THEME.DARK]: darkTheme,
} satisfies Record<ThemePreferenceWithoutSystem, ThemeColors>;
[CONST.THEME.LIGHT]: {theme: lightTheme, isLight: true},
[CONST.THEME.DARK]: {theme: darkTheme, isLight: false},
} satisfies Record<ThemePreferenceWithoutSystem, {theme: ThemeColors; isLight: boolean}>;

export default Themes;

0 comments on commit 0bfb705

Please sign in to comment.