Merge remote-tracking branch 'oxen/unstable' into userconfig_disappearingmessage
commit
a203ea79cd
@ -1,8 +1,9 @@
|
||||
import { ThemeStateType } from '../../themes/constants/colors';
|
||||
import { StateType } from '../reducer';
|
||||
import { checkDarkTheme, checkLightTheme } from '../../util/theme';
|
||||
|
||||
export const getTheme = (state: StateType): ThemeStateType => state.theme;
|
||||
|
||||
export const isDarkTheme = (state: StateType): boolean => state.theme.includes('dark');
|
||||
export const isDarkTheme = (state: StateType): boolean => checkDarkTheme(state.theme);
|
||||
|
||||
export const isLightTheme = (state: StateType): boolean => state.theme.includes('light');
|
||||
export const isLightTheme = (state: StateType): boolean => checkLightTheme(state.theme);
|
||||
|
@ -0,0 +1,21 @@
|
||||
import { ThemeStateType } from '../themes/constants/colors';
|
||||
|
||||
export const checkDarkTheme = (theme: ThemeStateType): boolean => theme.includes('dark');
|
||||
export const checkLightTheme = (theme: ThemeStateType): boolean => theme.includes('light');
|
||||
|
||||
export function getOppositeTheme(themeName: ThemeStateType): ThemeStateType {
|
||||
if (checkDarkTheme(themeName)) {
|
||||
return themeName.replace('dark', 'light') as ThemeStateType;
|
||||
}
|
||||
if (checkLightTheme(themeName)) {
|
||||
return themeName.replace('light', 'dark') as ThemeStateType;
|
||||
}
|
||||
// If neither 'dark' nor 'light' is in the theme name, return the original theme name.
|
||||
return themeName as ThemeStateType;
|
||||
}
|
||||
|
||||
export function isThemeMismatched(themeName: ThemeStateType, prefersDark: boolean): boolean {
|
||||
const systemLightTheme = checkLightTheme(themeName);
|
||||
const systemDarkTheme = checkDarkTheme(themeName);
|
||||
return (prefersDark && systemLightTheme) || (!prefersDark && systemDarkTheme);
|
||||
}
|
Loading…
Reference in New Issue