Skip to content
Source
Sign inSign up

withAndroidInputBackground.cjs

25 lines839 Bytes

1const { withAndroidStyles } = require("expo/config-plugins");
2​
3module.exports = function withAndroidInputBackground(config) {
4 return withAndroidStyles(config, (config) => {
5 const appTheme = config.modResults.resources.style?.find(
6 (style) => style.$?.name === "AppTheme",
7 );
8 if (!appTheme) {
9 throw new Error("withAndroidInputBackground: AppTheme is missing from styles.xml.");
10 }
11​
12 // Set both attributes for AppCompat and framework EditText implementations.
13 appTheme.item ??= [];
14 for (const name of ["editTextBackground", "android:editTextBackground"]) {
15 const existing = appTheme.item.find((item) => item.$?.name === name);
16 if (existing) {
17 existing._ = "@null";
18 } else {
19 appTheme.item.push({ $: { name }, _: "@null" });
20 }
21 }
22​
23 return config;
24 });
25};