Created
July 3, 2025 14:54
-
-
Save vanGalilea/0ce6fba6458308ea93d9b0efae2625eb to your computer and use it in GitHub Desktop.
fixAdyenDropInAndroidStatusBarStyleFix.ts
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
import { ConfigPlugin, withDangerousMod } from "@expo/config-plugins"; | |
import * as fs from "fs"; | |
import * as path from "path"; | |
/** | |
* Expo config plugin to patch the Android `styles.xml` file | |
* to fix the Adyen DropIn status bar color bug (see: https://github.com/Adyen/adyen-react-native/issues/630). | |
*/ | |
const fixAdyenDropInAndroidStatusBarStyleFix: ConfigPlugin = (config) => { | |
return withDangerousMod(config, [ | |
"android", | |
(config) => { | |
const stylesPath = path.join( | |
config.modRequest.projectRoot, | |
"android", | |
"app", | |
"src", | |
"main", | |
"res", | |
"values", | |
"styles.xml", | |
); | |
if (!fs.existsSync(stylesPath)) { | |
throw new Error(`styles.xml not found at ${stylesPath}`); | |
} | |
let stylesXml = fs.readFileSync(stylesPath, "utf8"); | |
const styleId = "AdyenCheckout.Translucent"; | |
if (stylesXml.includes(styleId)) { | |
console.log(`Style "${styleId}" already exists. Skipping.`); | |
return config; | |
} | |
const styleBlock = ` | |
<style name="${styleId}"> | |
<item name="android:windowIsTranslucent">true</item> | |
<item name="android:backgroundDimEnabled">true</item> | |
<item name="android:windowBackground">@android:color/transparent</item> | |
<item name="windowNoTitle">true</item> | |
<item name="windowActionBar">false</item> | |
<item name="android:statusBarColor">@android:color/transparent</item> | |
</style>`; | |
stylesXml = stylesXml.replace( | |
"</resources>", | |
`${styleBlock}\n</resources>`, | |
); | |
fs.writeFileSync(stylesPath, stylesXml); | |
console.log(`✅ Injected Adyen style into styles.xml`); | |
return config; | |
}, | |
]); | |
}; | |
export default fixAdyenDropInAndroidStatusBarStyleFix; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment