Skip to content

Commit

Permalink
fix(native): 🔨 temp work around for the [double splash screen issue](z…
Browse files Browse the repository at this point in the history
…oontek/react-native-bootsplash#496).

This is until [expo-splash-screen addresses the issue in sdk 52](expo/expo#29440)
  • Loading branch information
mikib0 committed Aug 31, 2024
1 parent e00da43 commit a17efd5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/expo/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
}
}
}
]
],
["./translucent-default-splash-screen-config"]
],
"extra": {
"eas": {
Expand Down
39 changes: 39 additions & 0 deletions apps/expo/translucent-default-splash-screen-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* @module withSplashWindowIsTranslucent
* @description Custom expo plugin that makes the {@link https://developer.android.com/develop/ui/views/launch/splash-screen/migrate|default splash screen (android 12+)} transparent.
* This is a temporary work around for the {@link https://github.com/zoontek/react-native-bootsplash/issues/496|double splash screen issue}.
*
*
* Credits: {@link https://github.com/expo/expo/issues/16084#issuecomment-1261330440}
*/

const { AndroidConfig, withAndroidStyles } = require('@expo/config-plugins');

const withSplashWindowIsTranslucent = (config) => {
return withAndroidStyles(config, async (config) => {
config.modResults = await configureFullScreenDialog(config.modResults);
return config;
});
};

async function configureFullScreenDialog(styles) {
const splashScreen = styles.resources.style.find(
(style) => style.$.name === 'Theme.App.SplashScreen',
);

if (splashScreen) {
splashScreen.item = splashScreen.item.filter(
(item) => item.$.name !== 'android:windowIsTranslucent',
);
splashScreen.item.push(
AndroidConfig.Resources.buildResourceItem({
name: 'android:windowIsTranslucent',
value: true,
}),
);
}

return styles;
}

module.exports = withSplashWindowIsTranslucent;

0 comments on commit a17efd5

Please sign in to comment.