Skip to content

Instantly share code, notes, and snippets.

@wodin

wodin/app.json Secret

Created February 2, 2023 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wodin/7cd3fcc90eb14f14374c99813aea256e to your computer and use it in GitHub Desktop.
Save wodin/7cd3fcc90eb14f14374c99813aea256e to your computer and use it in GitHub Desktop.
Config Plugin for adding `supports-screens` to `AndroidManifest.xml`
{
"expo": {
// [...]
"plugins": [
[
"./withAndroidSupportsScreens",
{
"resizeable": true,
"smallScreens": false,
"normalScreens": true,
"largeScreens": true,
"xlargeScreens": false,
"anyDensity": true,
"requiresSmallestWidthDp": 123,
"compatibleWidthLimitDp": 456,
"largestWidthLimitDp": 789
}
]
]
}
}
const { withAndroidManifest } = require("@expo/config-plugins");
function namespacedAttributes(attributes) {
let namespacedObj = {};
for (const [key, value] of Object.entries(attributes)) {
namespacedObj[`android:${key}`] = value;
}
return namespacedObj;
}
function addSupportsScreens(androidManifest, attributes) {
const { manifest } = androidManifest;
manifest["supports-screens"] = [
{
$: namespacedAttributes(attributes),
},
];
return androidManifest;
}
module.exports = function withAndroidSupportsScreens(config, attributes) {
return withAndroidManifest(config, (config) => {
config.modResults = addSupportsScreens(config.modResults, attributes);
return config;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment