UNPKG

expo-splash-screen

Version:

Provides a module to allow keeping the native Splash Screen visible until you choose to hide it.

37 lines (32 loc) 1.09 kB
import { addImports } from '@expo/config-plugins/build/android/codeMod'; import { mergeContents } from '@expo/config-plugins/build/utils/generateCode'; import { ConfigPlugin, withMainActivity } from 'expo/config-plugins'; export const withAndroidSplashMainActivity: ConfigPlugin = (config) => { return withMainActivity(config, (config) => { const { modResults } = config; const { language } = modResults; const withImports = addImports( modResults.contents.replace( /(\/\/ )?setTheme\(R\.style\.AppTheme\)/, '// setTheme(R.style.AppTheme)' ), ['expo.modules.splashscreen.SplashScreenManager'], language === 'java' ); const init = mergeContents({ src: withImports, comment: ' //', tag: 'expo-splashscreen', offset: 0, anchor: /super\.onCreate\(null\)/, newSrc: ' SplashScreenManager.registerOnActivity(this)' + (language === 'java' ? ';' : ''), }); return { ...config, modResults: { ...modResults, contents: init.contents, }, }; }); };