Files
paseo/packages/app/plugins/with-android-fold-configuration.js
Mohamed Boudra aa50151fa1 fix(app): handle Android fold configuration in place
Android fold transitions change smallestScreenWidthDp. Without declaring that configuration change, MainActivity is recreated and the foreground History route is lost. Keep the activity mounted so the existing responsive runtime receives the new geometry.

(cherry picked from commit ad3394ea5e582119ab5e907f0e614fe54c535428)
2026-09-30 15:42:15 +02:00

22 lines
894 B
JavaScript

const { withAndroidManifest } = require("expo/config-plugins");
function withAndroidFoldConfiguration(config) {
return withAndroidManifest(config, (modConfig) => {
const activity = modConfig.modResults.manifest.application?.[0]?.activity?.find(
(entry) => entry.$?.["android:name"] === ".MainActivity",
);
if (!activity) {
throw new Error("Could not configure fold changes without MainActivity");
}
// A fold changes smallestScreenWidthDp as well as screenSize. Let React Native and
// Unistyles receive the configuration change without Android recreating MainActivity.
const changes = new Set((activity.$["android:configChanges"] ?? "").split("|").filter(Boolean));
changes.add("smallestScreenSize");
activity.$["android:configChanges"] = [...changes].join("|");
return modConfig;
});
}
module.exports = withAndroidFoldConfiguration;