diff options
author | Eiichi Yoshikawa <edo@bari-ikutsu.com> | 2024-03-06 14:28:27 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-05 21:28:27 -0800 |
commit | 26fc0cf66d0cde33e8105495785a1ce4248fb9f7 (patch) | |
tree | 6e794e2911231a9b27368152703351135071e4de | |
parent | 317e0cda7a30d21f35229c096b6ef3284819d19a (diff) | |
download | voidsky-26fc0cf66d0cde33e8105495785a1ce4248fb9f7.tar.zst |
Improve splash display on android (#3105)
* Set window background during startup on android * Set statusbar color to transparent and fine-tune it
-rw-r--r-- | app.config.js | 20 | ||||
-rw-r--r-- | plugins/withAndroidStylesWindowBackgroundPlugin.js | 20 | ||||
-rw-r--r-- | src/App.native.tsx | 3 |
3 files changed, 39 insertions, 4 deletions
diff --git a/app.config.js b/app.config.js index 9691cab23..530e07b9b 100644 --- a/app.config.js +++ b/app.config.js @@ -11,6 +11,17 @@ const DARK_SPLASH_CONFIG = { resizeMode: 'cover', } +const SPLASH_CONFIG_ANDROID = { + backgroundColor: '#0c7cff', + image: './assets/splash.png', + resizeMode: 'cover', +} +const DARK_SPLASH_CONFIG_ANDROID = { + backgroundColor: '#0f141b', + image: './assets/splash-dark.png', + resizeMode: 'cover', +} + module.exports = function (config) { /** * App version number. Should be incremented as part of a release cycle. @@ -70,8 +81,8 @@ module.exports = function (config) { }, }, androidStatusBar: { - barStyle: 'dark-content', - backgroundColor: '#ffffff', + barStyle: 'light-content', + backgroundColor: '#00000000', }, android: { icon: './assets/icon.png', @@ -101,8 +112,8 @@ module.exports = function (config) { }, ], splash: { - ...SPLASH_CONFIG, - dark: DARK_SPLASH_CONFIG, + ...SPLASH_CONFIG_ANDROID, + dark: DARK_SPLASH_CONFIG_ANDROID, }, }, web: { @@ -146,6 +157,7 @@ module.exports = function (config) { }, ], './plugins/withAndroidManifestPlugin.js', + './plugins/withAndroidStylesWindowBackgroundPlugin.js', './plugins/shareExtension/withShareExtensions.js', ].filter(Boolean), extra: { diff --git a/plugins/withAndroidStylesWindowBackgroundPlugin.js b/plugins/withAndroidStylesWindowBackgroundPlugin.js new file mode 100644 index 000000000..427f43df0 --- /dev/null +++ b/plugins/withAndroidStylesWindowBackgroundPlugin.js @@ -0,0 +1,20 @@ +const {withAndroidStyles, AndroidConfig} = require('@expo/config-plugins') + +module.exports = function withAndroidStylesWindowBackgroundPlugin(appConfig) { + return withAndroidStyles(appConfig, function (decoratedAppConfig) { + try { + decoratedAppConfig.modResults = AndroidConfig.Styles.assignStylesValue( + decoratedAppConfig.modResults, + { + add: true, + parent: AndroidConfig.Styles.getAppThemeLightNoActionBarGroup(), + name: 'android:windowBackground', + value: '@drawable/splashscreen', + }, + ) + } catch (e) { + console.error(`withAndroidStylesWindowBackgroundPlugin failed`, e) + } + return decoratedAppConfig + }) +} diff --git a/src/App.native.tsx b/src/App.native.tsx index f08a6235b..4da3f85f0 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -46,6 +46,8 @@ import {Provider as PortalProvider} from '#/components/Portal' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useIntentHandler} from 'lib/hooks/useIntentHandler' +import {StatusBar} from 'expo-status-bar' +import {isAndroid} from 'platform/detection' SplashScreen.preventAutoHideAsync() @@ -69,6 +71,7 @@ function InnerApp() { return ( <SafeAreaProvider initialMetrics={initialWindowMetrics}> + {isAndroid && <StatusBar />} <Alf theme={theme}> <Splash isReady={!isInitialLoad}> <React.Fragment |