diff --git a/src/app/theme/colorScheme.ts b/src/app/theme/colorScheme.ts index 527fa2d0c..e169bfdcd 100644 --- a/src/app/theme/colorScheme.ts +++ b/src/app/theme/colorScheme.ts @@ -2,11 +2,6 @@ import { useEffect } from 'react' import { Appearance, ColorSchemeName } from 'react-native' import { useSettings } from 'cozy-client' -import flag from 'cozy-flags' - -interface GetColorSchemeOptions { - useUserColorScheme?: boolean -} export const setColorScheme = ( colorScheme: ColorSchemeName | string | undefined @@ -15,19 +10,8 @@ export const setColorScheme = ( Appearance.setColorScheme(formattedColorScheme) } -export const getColorScheme = ({ - useUserColorScheme = false -}: GetColorSchemeOptions = {}): ColorSchemeName => { - if (!useUserColorScheme) { - return Appearance.getColorScheme() - } - - if (flag('ui.darkmode.enabled')) { - return Appearance.getColorScheme() - } - - // Force light if flag disabled - return 'light' +export const getColorScheme = (): ColorSchemeName => { + return Appearance.getColorScheme() } const formatColorSchemeName = ( diff --git a/src/app/theme/themeManager.ts b/src/app/theme/themeManager.ts index b1388f1b5..797dc26a1 100644 --- a/src/app/theme/themeManager.ts +++ b/src/app/theme/themeManager.ts @@ -42,14 +42,8 @@ export function setHomeTheme(params: HomeThemeParams): void { flagshipUIEvents.SET_COMPONENT_COLORS, componentId, { - topTheme: - getColorScheme({ useUserColorScheme: true }) === 'dark' - ? 'dark' - : 'light', - bottomTheme: - getColorScheme({ useUserColorScheme: true }) === 'dark' - ? 'dark' - : 'light' + topTheme: getColorScheme() === 'dark' ? 'dark' : 'light', + bottomTheme: getColorScheme() === 'dark' ? 'dark' : 'light' } ) } else { @@ -57,14 +51,8 @@ export function setHomeTheme(params: HomeThemeParams): void { flagshipUIEvents.SET_COMPONENT_COLORS, componentId, { - topTheme: - getColorScheme({ useUserColorScheme: true }) === 'dark' - ? 'light' - : 'dark', - bottomTheme: - getColorScheme({ useUserColorScheme: true }) === 'dark' - ? 'light' - : 'dark' + topTheme: getColorScheme() === 'dark' ? 'light' : 'dark', + bottomTheme: getColorScheme() === 'dark' ? 'light' : 'dark' } ) } diff --git a/src/screens/cozy-app/CozyAppScreen.Animation.tsx b/src/screens/cozy-app/CozyAppScreen.Animation.tsx index 929ffd094..e0b70d6aa 100644 --- a/src/screens/cozy-app/CozyAppScreen.Animation.tsx +++ b/src/screens/cozy-app/CozyAppScreen.Animation.tsx @@ -34,7 +34,7 @@ export const Animation = ({ ).current const animateFadeOut = useRef(new Animated.Value(1)).current const animateBarOpacity = useRef(new Animated.Value(0)).current - const colors = getColors({ useUserColorScheme: true }) + const colors = getColors() const { setFlagshipColors } = useFlagshipUI( 'CozyAppScreenAnimation', @@ -70,14 +70,8 @@ export const Animation = ({ ]).start(() => { onFirstHalf(true) setFlagshipColors({ - topTheme: - getColorScheme({ useUserColorScheme: true }) === 'dark' - ? 'light' - : 'dark', - bottomTheme: - getColorScheme({ useUserColorScheme: true }) === 'dark' - ? 'light' - : 'dark' + topTheme: getColorScheme() === 'dark' ? 'light' : 'dark', + bottomTheme: getColorScheme() === 'dark' ? 'light' : 'dark' }) Animated.timing(animateBarOpacity, progressBarAnimConfig.fadeIn).start() diff --git a/src/screens/cozy-app/CozyAppScreen.functions.ts b/src/screens/cozy-app/CozyAppScreen.functions.ts index 2ff8eca8b..7e298b883 100644 --- a/src/screens/cozy-app/CozyAppScreen.functions.ts +++ b/src/screens/cozy-app/CozyAppScreen.functions.ts @@ -25,7 +25,7 @@ export const config = { // Width has to be null at start even if it's not a valid value (was set to undefined and it broke the progress bar) // At the time of this fix we want to go back the previously working value but we have to investigate why it has to be null export const progressBarConfig = (): ProgressBarProps => { - const colors = getColors({ useUserColorScheme: true }) + const colors = getColors() return { width: null as unknown as number | undefined, diff --git a/src/screens/cozy-app/CozyAppScreen.tsx b/src/screens/cozy-app/CozyAppScreen.tsx index 24772ca4c..21aa95877 100644 --- a/src/screens/cozy-app/CozyAppScreen.tsx +++ b/src/screens/cozy-app/CozyAppScreen.tsx @@ -23,20 +23,14 @@ import { CozyAppScreenProps } from './CozyAppScreen.types' import { getColors } from '/ui/colors' const getDefaultFlagshipUI = (): FlagshipUI => { - const colors = getColors({ useUserColorScheme: true }) + const colors = getColors() return { bottomBackground: colors.paperBackgroundColor, - bottomTheme: - getColorScheme({ useUserColorScheme: true }) === 'dark' - ? 'light' - : 'dark', + bottomTheme: getColorScheme() === 'dark' ? 'light' : 'dark', bottomOverlay: 'transparent', topBackground: colors.paperBackgroundColor, - topTheme: - getColorScheme({ useUserColorScheme: true }) === 'dark' - ? 'light' - : 'dark', + topTheme: getColorScheme() === 'dark' ? 'light' : 'dark', topOverlay: 'transparent' } } @@ -51,7 +45,7 @@ export const CozyAppScreen = ({ const [isFirstHalf, setFirstHalf] = useState(false) const [shouldExitAnimation, setShouldExitAnimation] = useState(false) const { setShouldWaitCozyApp } = useHomeStateContext() - const colors = getColors({ useUserColorScheme: true }) + const colors = getColors() const { componentId } = useFlagshipUI( 'CozyAppScreen', diff --git a/src/ui/colors.ts b/src/ui/colors.ts index dc248defb..cc7d39265 100644 --- a/src/ui/colors.ts +++ b/src/ui/colors.ts @@ -130,14 +130,12 @@ export type CozyThemeColors = typeof lightNormalColors export interface GetColorsOptions { variant?: CozyThemeVariant - useUserColorScheme?: boolean } export const getColors = ({ - variant = 'normal', - useUserColorScheme = false + variant = 'normal' }: GetColorsOptions = {}): CozyThemeColors => { - const colorScheme = getColorScheme({ useUserColorScheme }) + const colorScheme = getColorScheme() if (colorScheme === 'light') { return variant === 'normal' ? lightNormalColors : lightInvertedColors diff --git a/white_label/brands/cozy/js/ui/colors.ts b/white_label/brands/cozy/js/ui/colors.ts index dc248defb..cc7d39265 100644 --- a/white_label/brands/cozy/js/ui/colors.ts +++ b/white_label/brands/cozy/js/ui/colors.ts @@ -130,14 +130,12 @@ export type CozyThemeColors = typeof lightNormalColors export interface GetColorsOptions { variant?: CozyThemeVariant - useUserColorScheme?: boolean } export const getColors = ({ - variant = 'normal', - useUserColorScheme = false + variant = 'normal' }: GetColorsOptions = {}): CozyThemeColors => { - const colorScheme = getColorScheme({ useUserColorScheme }) + const colorScheme = getColorScheme() if (colorScheme === 'light') { return variant === 'normal' ? lightNormalColors : lightInvertedColors diff --git a/white_label/brands/mabulle/js/ui/colors.ts b/white_label/brands/mabulle/js/ui/colors.ts index 755e31693..e96564095 100644 --- a/white_label/brands/mabulle/js/ui/colors.ts +++ b/white_label/brands/mabulle/js/ui/colors.ts @@ -122,14 +122,12 @@ export type CozyThemeColors = typeof lightNormalColors export interface GetColorsOptions { variant?: CozyThemeVariant - useUserColorScheme?: boolean } export const getColors = ({ - variant = 'normal', - useUserColorScheme = false + variant = 'normal' }: GetColorsOptions = {}): CozyThemeColors => { - const colorScheme = getColorScheme({ useUserColorScheme }) + const colorScheme = getColorScheme() if (colorScheme === 'light') { return variant === 'normal' ? lightNormalColors : lightInvertedColors