Last active
May 21, 2025 13:32
-
-
Save hirbod/d6bb5d0fc946a12ba9e3cf01120c604a to your computer and use it in GitHub Desktop.
Expo Config Plugin to disable forced Dark mode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// disable forced dark mode to prevent weird color changes | |
// eslint-disable-next-line @typescript-eslint/no-var-requires | |
const { createRunOncePlugin, withAndroidStyles, AndroidConfig } = require('expo/config-plugins') | |
function setForceDarkModeToFalse(styles) { | |
const newStyles = AndroidConfig.Styles.assignStylesValue(styles, { | |
add: true, | |
// ############# FOLLOW IF YOU'RE ON SDK 52 ############# | |
// TODO: AndroidConfig.Styles.getAppThemeGroup() will be available in SDK 52 (or expo/config-plugins 9+), for now I just hardcoded AppTheme | |
// parent: AndroidConfig.Styles.getAppThemeGroup(), | |
parent: { name: 'AppTheme' }, | |
name: `android:forceDarkAllowed`, | |
value: 'false', | |
}) | |
return newStyles | |
} | |
const withDisableForcedDarkModeAndroid = (config) => { | |
return withAndroidStyles(config, (config) => { | |
config.modResults = setForceDarkModeToFalse(config.modResults) | |
return config | |
}) | |
} | |
module.exports = createRunOncePlugin( | |
withDisableForcedDarkModeAndroid, | |
'disable-forced-dark-mode', | |
'1.0.0' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same issues with 53 splash screen. Does any one prevented dark mode for splash screen.